Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Oct 16, 2023
1 parent 25ff132 commit 6fb607c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,4 @@ private static SSLSocketFactory createSslSocketFactory(String redisCaCertPath) t
}
}

public static void main(String[] args) throws EnforcerException {
retrieveAndSubscribe();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ spec:
ports:
- name: web-server
protocol: TCP
port: 8443
targetPort: 8443
port: 9543
targetPort: 9543
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ data:
authKeyHeader = "stsAuthKey"
[commoncontroller.webServer]
port = 8443
port = 9543
{{- end -}}
1 change: 1 addition & 0 deletions test/cucumber-tests/scripts/setup-hosts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ kubectl wait --timeout=15m -n apk-integration-test deployment/apk-test-setup-wso
IP=$(kubectl get svc apk-test-setup-wso2-apk-gateway-service -n apk-integration-test --output jsonpath='{.status.loadBalancer.ingress[0].ip}')
sudo echo "$IP localhost" | sudo tee -a /etc/hosts
sudo echo "$IP idp.am.wso2.com" | sudo tee -a /etc/hosts
sudo echo "$IP apk-test-setup-wso2-apk-common-controller-service.apk-integration-test.svc" | sudo tee -a /etc/hosts
sudo echo "$IP api.am.wso2.com" | sudo tee -a /etc/hosts
sudo echo "$IP default.gw.wso2.com" | sudo tee -a /etc/hosts
sudo echo "$IP org1.gw.wso2.com" | sudo tee -a /etc/hosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void theResponseStatusCodeShouldBe(int expectedStatusCode) throws IOExcep

@Then("I send {string} request to {string} with body {string}")
public void sendHttpRequest(String httpMethod, String url, String body) throws IOException {
body = Utils.resolveVariables(body, sharedContext.getValueStore());
if (sharedContext.getResponse() instanceof CloseableHttpResponse) {
((CloseableHttpResponse) sharedContext.getResponse()).close();
}
Expand All @@ -141,6 +142,7 @@ public void sendHttpRequest(String httpMethod, String url, String body) throws I
// It will send request using a new thread and forget about the response
@Then("I send {string} async request to {string} with body {string}")
public void sendAsyncHttpRequest(String httpMethod, String url, String body) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
String finalBody = Utils.resolveVariables(body, sharedContext.getValueStore());
if (sharedContext.getResponse() instanceof CloseableHttpResponse) {
((CloseableHttpResponse) sharedContext.getResponse()).close();
}
Expand All @@ -150,11 +152,11 @@ public void sendAsyncHttpRequest(String httpMethod, String url, String body) thr
if (CurlOption.HttpMethod.GET.toString().toLowerCase().equals(httpMethod.toLowerCase())) {
simpleHTTPClient.doGet(url, sharedContext.getHeaders());
} else if (CurlOption.HttpMethod.POST.toString().toLowerCase().equals(httpMethod.toLowerCase())) {
simpleHTTPClient.doPost(url, sharedContext.getHeaders(), body, null);
simpleHTTPClient.doPost(url, sharedContext.getHeaders(), finalBody, null);
} else if (CurlOption.HttpMethod.PUT.toString().toLowerCase().equals(httpMethod.toLowerCase())) {
simpleHTTPClient.doPut(url, sharedContext.getHeaders(), body, null);
simpleHTTPClient.doPut(url, sharedContext.getHeaders(), finalBody, null);
} else if (CurlOption.HttpMethod.DELETE.toString().toLowerCase().equals(httpMethod.toLowerCase())) {
simpleHTTPClient.doPut(url, sharedContext.getHeaders(), body, null);
simpleHTTPClient.doPut(url, sharedContext.getHeaders(), finalBody, null);
} else if (CurlOption.HttpMethod.OPTIONS.toString().toLowerCase().equals(httpMethod.toLowerCase())) {
simpleHTTPClient.doOptions(url, sharedContext.getHeaders(), null, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Token revocation
Scenario: Testing token revocation
Given The system is ready
And I have a valid subscription
When I use the APK Conf file "artifacts/apk-confs/jwt_basic_conf.yaml"
And the definition file "artifacts/definitions/employees_api.json"
And make the API deployment request
Then the response status code should be 200
Then I set headers
|Authorization|bearer ${accessToken}|
And I send "GET" request to "https://default.gw.wso2.com:9095/jwt-basic/3.14/employee/" with body ""
And I eventually receive 200 response code, not accepting
|429|
|401|
Then I set headers
|stsAuthKey|2jrmypak391zsqz974ugdddebf812ofx1b9t1oq27530ir02tc815eemrx435qvcp41ucgy7v5uuawzi4qcmjrx0k1zgox2s28cr|
And I send "GET" request to "https://default.gw.wso2.com:9095/jwt-basic/3.14/employee/" with body ""
And the response status code should be 200
And I send "POST" request to "https://apk-test-setup-wso2-apk-common-controller-service.apk-integration-test.svc:9543/revoke" with body "{\"token\": \"${accessToken}\"}"
And the response status code should be 200
And I wait for 5 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/jwt-basic/3.14/employee/" with body ""
And the response status code should be 401


Scenario Outline: Undeploy API
Given The system is ready
And I have a valid subscription
When I undeploy the API whose ID is "<apiID>"
Then the response status code should be <expectedStatusCode>

Examples:
| apiID | expectedStatusCode |
| jwt-basic-test | 202 |

0 comments on commit 6fb607c

Please sign in to comment.