diff --git a/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/BaseSteps.java b/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/BaseSteps.java index 38d6a6b88..3c5794d80 100644 --- a/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/BaseSteps.java +++ b/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/BaseSteps.java @@ -142,9 +142,9 @@ public void theResponseStatusCodeShouldBe(int expectedStatusCode) throws IOExcep Assert.assertEquals(actualStatusCode, expectedStatusCode); } - @Then("the grpc error response status code should be {int}") - public void theGrpcErrorResponseStatusCodeShouldBe(int expectedStatusCode) throws IOException { - int actualStatusCode = sharedContext.getGrpcErrorCode(); + @Then("the gRPC response status code should be {int}") + public void theGrpcResponseStatusCodeShouldBe(int expectedStatusCode) throws IOException { + int actualStatusCode = sharedContext.getGrpcStatusCode(); Assert.assertEquals(actualStatusCode, expectedStatusCode); } @@ -176,20 +176,10 @@ public void GetStudent(String arg0, int arg1) throws StatusRuntimeException { try { SimpleGRPCStudentClient grpcStudentClient = new SimpleGRPCStudentClient(arg0, arg1); sharedContext.setStudentResponse(grpcStudentClient.GetStudent(sharedContext.getHeaders())); + sharedContext.setGrpcStatusCode(0); } catch (StatusRuntimeException e) { - if (e.getStatus().getCode()== Status.Code.PERMISSION_DENIED){ - sharedContext.setGrpcErrorCode(403); - } else if (e.getStatus().getCode()== Status.Code.UNIMPLEMENTED){ - sharedContext.setGrpcErrorCode(501); - } else if (e.getStatus().getCode()== Status.Code.UNAVAILABLE){ - sharedContext.setGrpcErrorCode(503); - } else if (e.getStatus().getCode()== Status.Code.NOT_FOUND){ - sharedContext.setGrpcErrorCode(404); - } else if (e.getStatus().getCode()== Status.Code.UNAUTHENTICATED){ - sharedContext.setGrpcErrorCode(401); - } else { - logger.error(e.getMessage() + "code: " + e.getStatus().getCode()); - } + sharedContext.setGrpcStatusCode(e.getStatus().getCode().value()); + logger.error(e.getMessage() + " Status code: " + e.getStatus().getCode().value()) ; } } @@ -198,12 +188,10 @@ public void GetStudentDefaultVersion(String arg0, int arg1) throws StatusRuntime try { SimpleGRPCStudentClient grpcStudentClient = new SimpleGRPCStudentClient(arg0, arg1); sharedContext.setStudentResponse(grpcStudentClient.GetStudentDefaultVersion(sharedContext.getHeaders())); + sharedContext.setGrpcStatusCode(0); } catch (StatusRuntimeException e) { - if (e.getStatus().getCode()== Status.Code.PERMISSION_DENIED){ - sharedContext.setGrpcErrorCode(403); - } else { - logger.error(e.getMessage()); - } + sharedContext.setGrpcStatusCode(e.getStatus().getCode().value()); + logger.error(e.getMessage() + " Status code: " + e.getStatus().getCode().value()) ; } } diff --git a/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/SharedContext.java b/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/SharedContext.java index e82adb2e5..396fb010c 100644 --- a/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/SharedContext.java +++ b/test/cucumber-tests/src/test/java/org/wso2/apk/integration/api/SharedContext.java @@ -37,7 +37,7 @@ public class SharedContext { private String accessToken; private HttpResponse response; private String responseBody; - private int grpcErrorCode; + private int grpcStatusCode; private String publisherAccessToken; private String devportalAccessToken; private String adminportalAccessToken; @@ -77,11 +77,11 @@ public void setAccessToken(String accessToken) { this.accessToken = accessToken; } - public int getGrpcErrorCode() { - return grpcErrorCode; + public int getGrpcStatusCode() { + return grpcStatusCode; } - public void setGrpcErrorCode(int grpcErrorCode) { - this.grpcErrorCode = grpcErrorCode; + public void setGrpcStatusCode(int grpcStatusCode) { + this.grpcStatusCode = grpcStatusCode; } public HttpResponse getResponse() { diff --git a/test/cucumber-tests/src/test/resources/tests/api/GRPC.feature b/test/cucumber-tests/src/test/resources/tests/api/GRPC.feature index 8ebc10e4d..873ad7c48 100644 --- a/test/cucumber-tests/src/test/resources/tests/api/GRPC.feature +++ b/test/cucumber-tests/src/test/resources/tests/api/GRPC.feature @@ -15,9 +15,7 @@ Feature: Generating APK conf for gRPC API Then I set headers | Authorization | bearer ${accessToken} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 429 | - | 500 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Scenario: Undeploy API @@ -57,9 +55,7 @@ Feature: Generating APK conf for gRPC API And make the API deployment request Then the response status code should be 200 And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 429 | - | 500 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Scenario: Undeploy API @@ -78,15 +74,13 @@ Feature: Generating APK conf for gRPC API Then I set headers | Authorization | bearer ${accessToken} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And the grpc error response status code should be 403 + And the gRPC response status code should be 7 Given I have a valid subscription with scopes | wso2 | Then I set headers | Authorization | bearer ${accessToken} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 429 | - | 500 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Scenario: Undeploy API @@ -105,17 +99,13 @@ Feature: Generating APK conf for gRPC API Then I set headers | Authorization | bearer ${accessToken} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 429 | - | 500 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Given I have a valid subscription Then I set headers | Authorization | bearer ${accessToken} | And I make grpc request GetStudent default version to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 429 | - | 500 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Scenario: Undeploy API diff --git a/test/cucumber-tests/src/test/resources/tests/api/GRPCMTLS.feature b/test/cucumber-tests/src/test/resources/tests/api/GRPCMTLS.feature index 05548f7ca..87fa0fac0 100644 --- a/test/cucumber-tests/src/test/resources/tests/api/GRPCMTLS.feature +++ b/test/cucumber-tests/src/test/resources/tests/api/GRPCMTLS.feature @@ -9,8 +9,7 @@ Feature: Test mTLS between client and gateway with client certificate sent in he Then I set headers | X-WSO2-CLIENT-CERTIFICATE | ${clientCertificate} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And I eventually receive 200 response code, not accepting - | 401 | + And the gRPC response status code should be 0 And the student response body should contain name: "Dineth" age: 10 Scenario: Undeploy API @@ -30,7 +29,7 @@ Feature: Test mTLS between client and gateway with client certificate sent in he | X-WSO2-CLIENT-CERTIFICATE | ${clientCertificate} | | Authorization | bearer {accessToken} | And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 - And the grpc error response status code should be 401 + And the gRPC response status code should be 16 Scenario: Undeploy API Given The system is ready