From d5be0fe1da98ed2e17da13ab3af73983b84a00a7 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Thu, 12 Jan 2017 15:42:46 +0200 Subject: [PATCH] Add missing sanity tests for Get network membership --- .../RestGetNetworksForPersonSanityTests.java | 69 +++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index b045e101c..d1d4bb596 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -2,6 +2,9 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -14,8 +17,9 @@ import org.testng.annotations.Test; public class RestGetNetworksForPersonSanityTests extends RestTest { private UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; + private UserModel adminTenantUser; + private UserModel tenantUser; + private SiteModel siteModel; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception @@ -25,11 +29,12 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.authenticateUser(adminUserModel); restClient.usingTenant().createTenant(adminTenantUser); tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); } @Bug(id = "MNT-16904") @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") + description = "Verify non existing user gets another exisiting network with Rest API and checks the unauthorized status") @Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception { @@ -73,4 +78,60 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.withCoreAPI().usingAuthUser().getNetworks(secondTenantUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } -} + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant manager user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void managerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("managerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, siteModel, UserRole.SiteManager); + + restClient.authenticateUser(managerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(managerTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void collaboratorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("collaboratorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, siteModel, UserRole.SiteCollaborator); + + restClient.authenticateUser(collaboratorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(collaboratorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void contributorTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contributorTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, siteModel, UserRole.SiteContributor); + + restClient.authenticateUser(contributorTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(contributorTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY, TestGroup.COMMENTS, TestGroup.NETWORKS }) + public void consumerTenantChecksIfNetworkIsPresent() throws Exception + { + UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consumerTenant"); + dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, siteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumerTenantUser); + RestNetworkModelsCollection networks = restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(consumerTenantUser.getDomain().toLowerCase()); + } +} \ No newline at end of file