diff --git a/modules/distribution/product/src/main/resources/conf/templates/repository/conf/registry.xml.j2 b/modules/distribution/product/src/main/resources/conf/templates/repository/conf/registry.xml.j2 index 6996e0d091..ff2f553484 100644 --- a/modules/distribution/product/src/main/resources/conf/templates/repository/conf/registry.xml.j2 +++ b/modules/distribution/product/src/main/resources/conf/templates/repository/conf/registry.xml.j2 @@ -330,6 +330,9 @@ + + + diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/ContentSearchTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/ContentSearchTestCase.java index ccffa3e5b6..d2487ac180 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/ContentSearchTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/restapi/ContentSearchTestCase.java @@ -111,23 +111,11 @@ public void setEnvironment() throws Exception { userManagementClient1.updateRolesOfUser(user.getUserNameWithoutDomain(), newRoleList); } - userManagementClient1 - .addUser(user1, password, new String[] { role1, "Internal/publisher", "Internal/subscriber" }, user1); - userManagementClient1 - .addUser(user2, password, new String[] { role2, "Internal/publisher", "Internal/subscriber" }, user2); - APIRequest apiRequest = createAPIRequest(contentSearchTestAPI, contentSearchTestAPI, endpointURL, version, user.getUserName(), description); apiId = createAndPublishAPIUsingRest(apiRequest, restAPIPublisher, false); - //Login to API Publisher adn Store with CarbonSuper normal user1 - restAPIPublisherFirstUser = new RestAPIPublisherImpl(user1, password, user.getUserDomain(), publisherURLHttps); - restAPIPublisherSecondUser = new RestAPIPublisherImpl(user2, password, user.getUserDomain(), publisherURLHttps); - - restAPIStoreFirstUser = new RestAPIStoreImpl(user1, password, user.getUserDomain(), storeURLHttps); - restAPIStoreSecondUser = new RestAPIStoreImpl(user2, password, user.getUserDomain(), storeURLHttps); - } @Test(groups = { "wso2.am" }, description = "Test basic content Search") @@ -137,7 +125,7 @@ public void testBasicContentSearch() throws Exception { //check in publisher for (int i = 0; i <= retries; i++) { SearchResultListDTO searchResultListDTO = restAPIPublisher.searchAPIs(description); - if (searchResultListDTO.getCount() == 1) { + if (searchResultListDTO.getCount() >= 1) { Assert.assertTrue(true); break; } else { @@ -156,7 +144,7 @@ public void testBasicContentSearch() throws Exception { //search term : UnifiedSearchFeature, created api has this in description filed org.wso2.am.integration.clients.store.api.v1.dto.SearchResultListDTO searchResultListDTO = restAPIStore .searchAPIs(description); - if (searchResultListDTO.getCount() == 1) { + if (searchResultListDTO.getCount() >= 1) { // API and API Definitions Assert.assertTrue(true); break; } else { @@ -252,35 +240,40 @@ public void testDocumentContentSearch() throws Exception { @Test(groups = { "wso2.am" }, description = "Test content Search with access control", dependsOnMethods = "testBasicContentSearch") public void testContentSearchWithAccessControl() throws Exception { - + // Set API publisher access control to role1 HttpResponse httpResponse = restAPIPublisher.getAPI(apiId); - Gson g = new Gson(); - APIDTO apiDto = g.fromJson(httpResponse.getData(), APIDTO.class); + APIDTO apiDto = new Gson().fromJson(httpResponse.getData(), APIDTO.class); apiDto.setAccessControl(APIDTO.AccessControlEnum.RESTRICTED); List roles = new ArrayList<>(); roles.add(role1); apiDto.setAccessControlRoles(roles); - apiDto.setVisibility(APIDTO.VisibilityEnum.RESTRICTED); - apiDto.setVisibleRoles(roles); - restAPIPublisher.updateAPI(apiDto); - restAPIPublisher.changeAPILifeCycleStatus(apiId, APILifeCycleAction.PUBLISH.getAction()); + // Add users for test + userManagementClient1 + .addUser(user1, password, new String[] { role1, "Internal/publisher"}, user1); + userManagementClient1 + .addUser(user2, password, new String[] { role2, "Internal/publisher"}, user2); + + //Login to API Publisher adn Store with CarbonSuper normal user1 + restAPIPublisherFirstUser = new RestAPIPublisherImpl(user1, password, user.getUserDomain(), publisherURLHttps); + restAPIPublisherSecondUser = new RestAPIPublisherImpl(user2, password, user.getUserDomain(), publisherURLHttps); + //check with user1 for (int i = 0; i <= retries; i++) { SearchResultListDTO searchResultListDTO = restAPIPublisherFirstUser.searchAPIs(description); - if (searchResultListDTO.getCount() == 1) { + if (searchResultListDTO.getCount() == 2) { // API and API Definition Assert.assertTrue(true); break; } else { if (i == retries) { - Assert.fail("Content search with access control failed. 1 result expected. Received response : " + Assert.fail("Content search with access control failed. 2 result expected. Received response : " + searchResultListDTO.getCount()); } else { - log.warn("Content search with access control failed. 1 results expected. Received response : " + log.warn("Content search with access control failed. 2 results expected. Received response : " + searchResultListDTO.getCount() + " Retrying..."); Thread.sleep(3000); } @@ -314,19 +307,38 @@ public void testContentSearchWithAccessControl() throws Exception { "wso2.am" }, description = "Test content Search with store visibility", dependsOnMethods = "testContentSearchWithAccessControl") public void testContentSearchWithStoreVisibility() throws Exception { + // Set store visibility to role1 + HttpResponse httpResponse = restAPIPublisher.getAPI(apiId); + APIDTO apiDto = new Gson().fromJson(httpResponse.getData(), APIDTO.class); + apiDto.setAccessControl(APIDTO.AccessControlEnum.NONE); + + List roles = new ArrayList<>(); + roles.add(role1); + apiDto.setVisibility(APIDTO.VisibilityEnum.RESTRICTED); + apiDto.setVisibleRoles(roles); + + restAPIPublisher.updateAPI(apiDto); + + // Update user for tests + userManagementClient1.updateRolesOfUser(user1, new String[] { role1, "Internal/subscriber" }); + userManagementClient1.updateRolesOfUser(user2, new String[] { role2, "Internal/subscriber" }); + + restAPIStoreFirstUser = new RestAPIStoreImpl(user1, password, user.getUserDomain(), storeURLHttps); + restAPIStoreSecondUser = new RestAPIStoreImpl(user2, password, user.getUserDomain(), storeURLHttps); + //check with user1 for (int i = 0; i <= retries; i++) { org.wso2.am.integration.clients.store.api.v1.dto.SearchResultListDTO searchResultListDTO = restAPIStoreFirstUser .searchAPIs(description); - if (searchResultListDTO.getCount() == 1) { + if (searchResultListDTO.getCount() == 2) { // API and API Definition Assert.assertTrue(true); break; } else { if (i == retries) { - Assert.fail("Content search with visibility failed. 1 result expected. Received response : " + Assert.fail("Content search with visibility failed. 2 result expected. Received response : " + searchResultListDTO.getCount()); } else { - log.warn("Content search with visibility failed. 1 results expected. Received response : " + log.warn("Content search with visibility failed. 2 results expected. Received response : " + searchResultListDTO.getCount() + " Retrying..."); Thread.sleep(5000); }