diff --git a/README.md b/README.md index b50682b..075d50a 100644 --- a/README.md +++ b/README.md @@ -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 . ``` diff --git a/client/client.go b/client/client.go index b470cff..f3994d5 100644 --- a/client/client.go +++ b/client/client.go @@ -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), } } diff --git a/client/client_test.go b/client/client_test.go index 4370510..6300377 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -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( @@ -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)), @@ -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( @@ -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)), @@ -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( @@ -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)), @@ -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( @@ -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, @@ -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( @@ -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, @@ -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( @@ -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, @@ -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( @@ -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, @@ -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( @@ -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, @@ -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, @@ -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( @@ -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, @@ -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( @@ -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, diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b6e62d7..e91f66b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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: diff --git a/docker/initializer.json b/docker/initializer.json index 36fb2e0..29ef260 100644 --- a/docker/initializer.json +++ b/docker/initializer.json @@ -2,7 +2,7 @@ { "httpRequest": { "method": "Put", - "path": "/api/Topic", + "path": "/public/v1/Topic", "headers": { "Authorization": "Bearer yo" } @@ -18,7 +18,7 @@ { "httpRequest": { "method": "Get", - "path": "/api/Topic", + "path": "/public/v1/Topic", "headers": { "Authorization": "Bearer yo" } @@ -34,7 +34,7 @@ { "httpRequest": { "method": "Get", - "path": "/api/Topic/yolo", + "path": "/public/v1/Topic/yolo", "headers": { "Authorization": "Bearer yo" } @@ -50,7 +50,7 @@ { "httpRequest": { "method": "Delete", - "path": "/api/Topic/yolo", + "path": "/public/v1/Topic/yolo", "headers": { "Authorization": "Bearer yo" }