Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Nov 8, 2023
1 parent 2bf769e commit 7a1ac4d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
2 changes: 1 addition & 1 deletion adapter/internal/operator/synchronizer/data_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (ods *OperatorDataStore) processGatewayState(gatewayDef *gwapiv1b1.Gateway,
customRateLimitPolicies map[string]*dpv1alpha1.RateLimitPolicy) (GatewayState, []string, bool) {
ods.mu.Lock()
defer ods.mu.Unlock()
var updated bool
updated := false
events := []string{}
cachedGateway := ods.gatewayStore[utils.NamespacedName(gatewayDef)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public void waitForSeconds(int seconds) throws InterruptedException {
Thread.sleep(seconds * 1000);
}

@Then("I wait for api deployment")
public void waitAPIDeployment() throws InterruptedException {
waitForSeconds(10);
}

@Then("the response headers contains key {string} and value {string}")
public void containsHeader(String key, String value) {
key = Utils.resolveVariables(key, sharedContext.getValueStore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Feature: API Definition Endpoint
And make the API deployment request
Then the response status code should be 200
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-default/3.14/api-definition" with body ""
And I eventually receive 200 response code, not accepting
|429|
| 429 |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-default/api-definition" with body ""
And I eventually receive 200 response code, not accepting
|429|
| 429 |

Scenario: Testing custom API definition endpoint
Given The system is ready
Expand All @@ -23,19 +23,19 @@ Feature: API Definition Endpoint
And make the API deployment request
Then the response status code should be 200
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-custom/3.14/docs" with body ""
And I eventually receive 200 response code, not accepting
|429|
| 429 |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-custom/docs" with body ""
And I eventually receive 200 response code, not accepting
|429|
| 429 |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-custom/api-definition" with body ""
And I eventually receive 404 response code, not accepting
|429|
| 429 |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-custom/3.14/api-definition" with body ""
And I eventually receive 404 response code, not accepting
|429|
| 429 |

Scenario: Testing a deleted production endpoint
Given The system is ready
Expand All @@ -44,14 +44,14 @@ Feature: API Definition Endpoint
And the definition file "artifacts/definitions/employees_api.json"
And make the API deployment request
Then the response status code should be 200
And I wait for 1 minute
And I wait for api deployment
Then I set headers
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-default/3.14/api-definition" with body ""
Then the response status code should be 404
And I send "GET" request to "https://default.gw.wso2.com:9095/test-definition-default/api-definition" with body ""
Then the response status code should be 404

Scenario: Testing a deleted production endpoint
Given The system is ready
And I have a valid subscription
Expand All @@ -63,7 +63,7 @@ Feature: API Definition Endpoint
And the definition file "artifacts/definitions/employees_api.json"
And make the API deployment request
Then the response status code should be 200
And I wait for 1 minute
And I wait for api deployment
Then I set headers
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.sandbox.gw.wso2.com:9095/test-definition-default/3.14/api-definition" with body ""
Expand All @@ -79,6 +79,6 @@ Feature: API Definition Endpoint
Then the response status code should be <expectedStatusCode>

Examples:
| apiID | expectedStatusCode |
| custom-api-definition-endpoint-test | 202 |
| default-api-definition-endpoint-test | 202 |
| apiID | expectedStatusCode |
| custom-api-definition-endpoint-test | 202 |
| default-api-definition-endpoint-test | 202 |
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: API Deployment with Global Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "579ba27a1e03e2fdf099d1b6745e265f2d495606"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/globalinterceptor/1.0.0/get" with body ""
Then the response status code should be 200
And the response body should contain "\"Gw-Header\": \"GW-header-value\""
Expand All @@ -21,5 +21,5 @@ Feature: API Deployment with Global Interceptor
Then the response status code should be <expectedStatusCode>

Examples:
| apiID | expectedStatusCode |
| 579ba27a1e03e2fdf099d1b6745e265f2d495606 | 202 |
| apiID | expectedStatusCode |
| 579ba27a1e03e2fdf099d1b6745e265f2d495606 | 202 |
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Then the response status code should be 200
And the response body should not contain "\"Interceptor-Header\""
Expand All @@ -18,9 +18,9 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Then the response status code should be 200
And the response body should contain "\"Interceptor-Header\": \"Interceptor-header-value\""
Expand All @@ -29,9 +29,9 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Then the response status code should be 200
Then the response headers contains key "interceptor-response-header" and value "Interceptor-Response-header-value"
Expand All @@ -41,9 +41,9 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Then the response status code should be 200
Then the response headers contains key "interceptor-response-header" and value "Interceptor-Response-header-value"
Expand All @@ -53,7 +53,7 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Expand All @@ -65,7 +65,7 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Expand All @@ -77,7 +77,7 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
Expand All @@ -89,9 +89,9 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
And the response body should contain "\"Interceptor-Header\": \"Interceptor-header-value\""
Then the response status code should be 200
Expand All @@ -101,30 +101,30 @@ Feature: API Deployment with Interceptor
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
And the response body should not contain "\"Interceptor-Header\""
Then the response status code should be 200
Then the response headers not contains key "interceptor-response-header"
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/headers" with body ""
And the response body should contain
|"Interceptor-Header": "Interceptor-header-value"|
|"Interceptor-Header-Apigroup": "Gold"|
|"Interceptor-Header-Apitier": "Unlimited"|
| "Interceptor-Header": "Interceptor-header-value" |
| "Interceptor-Header-Apigroup": "Gold" |
| "Interceptor-Header-Apitier": "Unlimited" |
Then the response status code should be 200
Then the response headers contains key "interceptor-response-header" and value "Interceptor-Response-header-value"
Then I use the APK Conf file "artifacts/apk-confs/interceptors/withRequestAndResponsetls.apk-conf"
And the definition file "artifacts/definitions/cors_api.yaml"
And make the API deployment request
Then the response status code should be 200
And the response body should contain "547961eeaafed989119c45ffc13f8b87bfda821d"
And I wait for 1 minute
And I wait for api deployment
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I send "GET" request to "https://default.gw.wso2.com:9095/interceptor/1.0.0/get" with body ""
And the response body should contain "\"Interceptor-Header\": \"Interceptor-header-value\""
Then the response status code should be 200
Expand All @@ -136,5 +136,5 @@ Feature: API Deployment with Interceptor
Then the response status code should be <expectedStatusCode>

Examples:
| apiID | expectedStatusCode |
| 547961eeaafed989119c45ffc13f8b87bfda821d | 202 |
| apiID | expectedStatusCode |
| 547961eeaafed989119c45ffc13f8b87bfda821d | 202 |

0 comments on commit 7a1ac4d

Please sign in to comment.