From d37da565f1ceb065a65cdb2ddcbc626a8e197183 Mon Sep 17 00:00:00 2001 From: tharikaGitHub Date: Fri, 2 Jul 2021 21:23:16 +0530 Subject: [PATCH 1/2] Add integration test for preventing on prem API Renaming --- .../test/utils/bean/APIRequest.java | 4 ++ ...APIThroughThePublisherRestAPITestCase.java | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/bean/APIRequest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/bean/APIRequest.java index 74d1a78142..51e694f404 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/bean/APIRequest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/utils/bean/APIRequest.java @@ -435,6 +435,10 @@ public String getName() { return name; } + public void setName(String name) { + this.name = name; + } + public org.json.simple.JSONObject getEndpointConfig() { return endpoint; } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM520UpdateAnAPIThroughThePublisherRestAPITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM520UpdateAnAPIThroughThePublisherRestAPITestCase.java index dd0ec20573..cd8417f364 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM520UpdateAnAPIThroughThePublisherRestAPITestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/publisher/APIM520UpdateAnAPIThroughThePublisherRestAPITestCase.java @@ -47,6 +47,8 @@ public class APIM520UpdateAnAPIThroughThePublisherRestAPITestCase extends APIMIntegrationBaseTest { private final String apiNameTest = "APIM520PublisherTest"; + private final String apiUpdatedNameTest = "PublisherTestRenameAPI"; + private final String updatedApiName = "PublisherNewTestRenameAPI"; private final String apiVersion = "1.0.0"; private APIPublisherRestClient apiPublisher; private String apiProviderName; @@ -138,6 +140,46 @@ public void testUpdateAnAPIThroughThePublisherRest() throws Exception { } + @Test(groups = {"wso2.am"}, description = "Update an API Through the Publisher Rest API after renaming the API") + public void testUpdateAnAPIThroughThePublisherRestAfterRename() throws Exception { + + String apiContextTest = "apiRenamingContext"; + String apiDescription = "This is Test API Created by API Manager Integration Test for API Renaming"; + + //Create an API + APIRequest apiCreationRequestBean = new APIRequest(apiUpdatedNameTest, apiContextTest, + new URL(apiProductionEndPointUrl)); + apiCreationRequestBean.setVersion(apiVersion); + apiCreationRequestBean.setProvider(apiProviderName); + apiCreationRequestBean.setDescription(apiDescription); + apiCreationRequestBean.setTiersCollection("Gold,Bronze"); + + HttpResponse apiCreationResponse = restAPIPublisher.addAPI(apiCreationRequestBean); + id = apiCreationResponse.getData(); + assertEquals(apiCreationResponse.getResponseCode(), Response.Status.CREATED.getStatusCode(), + "Response Code miss matched when creating the API"); + + //Check availability of the API in publisher + HttpResponse apiResponsePublisher = restAPIPublisher.getAPI(id); + assertTrue(apiResponsePublisher.getData().contains(apiUpdatedNameTest), + apiUpdatedNameTest + " is not visible in publisher"); + + //Update API with name change + apiCreationRequestBean.setName(updatedApiName); + + HttpResponse apiUpdateResponse = restAPIPublisher.updateAPI(apiCreationRequestBean, id); + assertEquals(apiUpdateResponse.getResponseCode(), Response.Status.OK.getStatusCode(), + "Response Code miss matched when creating the API"); + waitForAPIDeployment(); + + // Check whether API is updated from the above request. This API Name should not get updated + // when not in a cloud scenario + HttpResponse apiUpdateResponsePublisher = restAPIPublisher.getAPI(id); + + assertTrue(apiUpdateResponsePublisher.getData().contains(apiUpdatedNameTest), + apiUpdatedNameTest + " is updated"); + } + @AfterClass(alwaysRun = true) public void destroyAPIs() throws Exception { restAPIPublisher.deleteAPI(id); From 97a381bc428d7ca45eda49a022d1606b940c0962 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 2 Jul 2021 15:55:03 +0000 Subject: [PATCH 2/2] [Security] Bump synapse-core from 2.1.7-wso2v168 to 3.0.1 Bumps synapse-core from 2.1.7-wso2v168 to 3.0.1. **This update includes a security fix.** Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00397f06f4..d65ec8751b 100644 --- a/pom.xml +++ b/pom.xml @@ -1340,7 +1340,7 @@ 1.8 3.0-FINAL 1.0.0.M8-wso2v1 - 2.1.7-wso2v227 + 3.0.1 1.0.2 1.6.1-wso2v63 1.2.11-wso2v16