Skip to content

Commit

Permalink
Merge pull request #22 from conduktor/cons-859-base-url
Browse files Browse the repository at this point in the history
fix base url
  • Loading branch information
strokyl authored Mar 20, 2024
2 parents 23d0d38 + ff1f651 commit 204b7e0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ How to run:
```
read CDK_TOKEN
export CDK_TOKEN
export CDK_BASE_URL=http://localhost:8080/public/v1
export CDK_BASE_URL=http://localhost:8080
go run .
```

Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Make(token string, baseUrl string, debug bool, key, cert string) Client {
certificate, _ := tls.LoadX509KeyPair(cert, key)
return Client{
token: token,
baseUrl: baseUrl,
baseUrl: baseUrl + "/public/v1",
client: resty.New().SetDebug(debug).SetHeader("Authorization", "Bearer "+token).SetCertificates(certificate),
}
}
Expand Down
42 changes: 21 additions & 21 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestApplyShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -26,7 +26,7 @@ func TestApplyShouldWork(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"PUT",
"http://baseUrl/api/topic",
"http://baseUrl/public/v1/topic",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token).
And(httpmock.BodyContainsBytes(topic.Json)),
Expand All @@ -44,7 +44,7 @@ func TestApplyShouldWork(t *testing.T) {

func TestApplyWithDryModeShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -61,7 +61,7 @@ func TestApplyWithDryModeShouldWork(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"PUT",
"http://baseUrl/api/topic",
"http://baseUrl/public/v1/topic",
"dryMode=true",
httpmock.HeaderIs("Authorization", "Bearer "+token).
And(httpmock.BodyContainsBytes(topic.Json)),
Expand All @@ -79,7 +79,7 @@ func TestApplyWithDryModeShouldWork(t *testing.T) {

func TestApplyShouldFailIfNo2xx(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -99,7 +99,7 @@ func TestApplyShouldFailIfNo2xx(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"PUT",
"http://baseUrl/api/topic",
"http://baseUrl/public/v1/topic",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token).
And(httpmock.BodyContainsBytes(topic.Json)),
Expand All @@ -114,7 +114,7 @@ func TestApplyShouldFailIfNo2xx(t *testing.T) {

func TestGetShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -127,7 +127,7 @@ func TestGetShouldWork(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application",
"http://baseUrl/public/v1/application",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -141,7 +141,7 @@ func TestGetShouldWork(t *testing.T) {

func TestGetShouldApplyCaseTransformation(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -154,7 +154,7 @@ func TestGetShouldApplyCaseTransformation(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application-instance",
"http://baseUrl/public/v1/application-instance",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -168,7 +168,7 @@ func TestGetShouldApplyCaseTransformation(t *testing.T) {

func TestGetShouldKeepCase(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -181,7 +181,7 @@ func TestGetShouldKeepCase(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application-instance",
"http://baseUrl/public/v1/application-instance",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -195,7 +195,7 @@ func TestGetShouldKeepCase(t *testing.T) {

func TestGetShouldFailIfN2xx(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -208,7 +208,7 @@ func TestGetShouldFailIfN2xx(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application",
"http://baseUrl/public/v1/application",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -222,7 +222,7 @@ func TestGetShouldFailIfN2xx(t *testing.T) {

func TestDescribeShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -235,7 +235,7 @@ func TestDescribeShouldWork(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application/yo",
"http://baseUrl/public/v1/application/yo",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -262,7 +262,7 @@ func TestDescribeShouldFailIfNo2xx(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"GET",
"http://baseUrl/api/application/yo",
"http://baseUrl/public/v1/application/yo",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -276,7 +276,7 @@ func TestDescribeShouldFailIfNo2xx(t *testing.T) {

func TestDeleteShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -289,7 +289,7 @@ func TestDeleteShouldWork(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"DELETE",
"http://baseUrl/api/application/yo",
"http://baseUrl/public/v1/application/yo",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand All @@ -302,7 +302,7 @@ func TestDeleteShouldWork(t *testing.T) {
}
func TestDeleteShouldFailOnNot2XX(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl/api"
baseUrl := "http://baseUrl"
token := "aToken"
client := Make(token, baseUrl, false, "", "")
httpmock.ActivateNonDefault(
Expand All @@ -315,7 +315,7 @@ func TestDeleteShouldFailOnNot2XX(t *testing.T) {

httpmock.RegisterMatcherResponderWithQuery(
"DELETE",
"http://baseUrl/api/application/yo",
"http://baseUrl/public/v1/api/application/yo",
nil,
httpmock.HeaderIs("Authorization", "Bearer "+token),
responder,
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: ..
environment:
CDK_TOKEN: yo
CDK_BASE_URL: http://mock:1080/api
CDK_BASE_URL: http://mock:1080
volumes:
- ./test_resource.yml:/test_resource.yml
mock:
Expand Down
8 changes: 4 additions & 4 deletions docker/initializer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"httpRequest": {
"method": "Put",
"path": "/api/Topic",
"path": "/public/v1/Topic",
"headers": {
"Authorization": "Bearer yo"
}
Expand All @@ -18,7 +18,7 @@
{
"httpRequest": {
"method": "Get",
"path": "/api/Topic",
"path": "/public/v1/Topic",
"headers": {
"Authorization": "Bearer yo"
}
Expand All @@ -34,7 +34,7 @@
{
"httpRequest": {
"method": "Get",
"path": "/api/Topic/yolo",
"path": "/public/v1/Topic/yolo",
"headers": {
"Authorization": "Bearer yo"
}
Expand All @@ -50,7 +50,7 @@
{
"httpRequest": {
"method": "Delete",
"path": "/api/Topic/yolo",
"path": "/public/v1/Topic/yolo",
"headers": {
"Authorization": "Bearer yo"
}
Expand Down

0 comments on commit 204b7e0

Please sign in to comment.