diff --git a/gateway-service/src/main/java/org/zowe/apiml/gateway/conformance/ValidateAPIController.java b/gateway-service/src/main/java/org/zowe/apiml/gateway/conformance/ValidateAPIController.java index d43799c825..91753c5953 100644 --- a/gateway-service/src/main/java/org/zowe/apiml/gateway/conformance/ValidateAPIController.java +++ b/gateway-service/src/main/java/org/zowe/apiml/gateway/conformance/ValidateAPIController.java @@ -115,6 +115,12 @@ public ResponseEntity checkConformance(@PathVariable String serviceId) { @HystrixCommand public ResponseEntity checkValidateLegacy(@RequestBody String serviceId) { + System.out.println(serviceId); + + if (serviceId.startsWith("serviceID")) { + serviceId = serviceId.replace("serviceID=", ""); + } + System.out.println(serviceId); return checkConformance(serviceId); } diff --git a/integration-tests/src/test/java/org/zowe/apiml/functional/gateway/ValidateAPITest.java b/integration-tests/src/test/java/org/zowe/apiml/functional/gateway/ValidateAPITest.java index 81ad2871fe..6afec748bb 100644 --- a/integration-tests/src/test/java/org/zowe/apiml/functional/gateway/ValidateAPITest.java +++ b/integration-tests/src/test/java/org/zowe/apiml/functional/gateway/ValidateAPITest.java @@ -12,6 +12,7 @@ import io.restassured.RestAssured; import org.apache.http.HttpStatus; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.zowe.apiml.util.TestWithStartedInstances; import org.zowe.apiml.util.categories.GatewayTest; @@ -25,37 +26,72 @@ * This is an integration test class for ValidateAPIController.java * It tests ValidateAPIController with service verificationOnboardService.java *

- * The test senario is: + * The test scenario is: * Send serviceId to validateAPIController then the controller will call verificationOnboardService.java * to check if the service is registered and metadata can be retrieved then it will return appropriate message - * The controller recieve the response from the service and then will post response. + * The controller receive the response from the service and then will post response. */ @GatewayTest public class ValidateAPITest implements TestWithStartedInstances { - private String gatewayUrl; + @BeforeEach + public void relaxedHTTPS() { + RestAssured.useRelaxedHTTPSValidation(); + } + + @Test + @TestsNotMeantForZowe + void testPostEndpoint() { + given() + .log().all() + .param("serviceID","discoverableclient") + .when() + .post(getLegacyEndpointURLPost()) + .then() + .assertThat() + .statusCode(HttpStatus.SC_OK); - public ValidateAPITest() { - initGatewayService(); } @Test @TestsNotMeantForZowe - void givenValidServiceId() { + void testGetEndpoint() { given() .log().all() - .body("discoverableclient") .when() - .post(gatewayUrl) + .get(getEndpointURLGet() + "/discoverableclient") .then() .assertThat() .statusCode(HttpStatus.SC_OK); } + @Test + @TestsNotMeantForZowe + void testGetEndpointNonConformant() { + given() + .log().all() + .when() + .get(getEndpointURLGet() + "/nonConformantServiceBecauseNameIsTooLongAndContainsCapitalLettersqwertyuiop") + .then() + .assertThat() + .statusCode(HttpStatus.SC_BAD_REQUEST); + + } + + private String getEndpointURLGet() { + GatewayServiceConfiguration gatewayServiceConfiguration = ConfigReader.environmentConfiguration().getGatewayServiceConfiguration(); + String gatewayScheme = gatewayServiceConfiguration.getScheme(); + String gatewayHost = gatewayServiceConfiguration.getHost(); + int gatewayPort = gatewayServiceConfiguration.getExternalPort(); + RestAssured.port = gatewayPort; + RestAssured.useRelaxedHTTPSValidation(); + + return String.format("%s://%s:%d%s", gatewayScheme, gatewayHost, gatewayPort, "/gateway/api/v1/conformance"); + } - private void initGatewayService() { + private String getLegacyEndpointURLPost() { GatewayServiceConfiguration gatewayServiceConfiguration = ConfigReader.environmentConfiguration().getGatewayServiceConfiguration(); String gatewayScheme = gatewayServiceConfiguration.getScheme(); String gatewayHost = gatewayServiceConfiguration.getHost(); @@ -63,6 +99,6 @@ private void initGatewayService() { RestAssured.port = gatewayPort; RestAssured.useRelaxedHTTPSValidation(); - gatewayUrl = String.format("%s://%s:%d%s", gatewayScheme, gatewayHost, gatewayPort, "/validate"); + return String.format("%s://%s:%d%s", gatewayScheme, gatewayHost, gatewayPort, "/validate"); } }