diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java deleted file mode 100644 index cdb116035..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkCoreTests.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class RestGetNetworkCoreTests extends RestTest -{ - UserModel adminTenantUser; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - UserModel adminuser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminuser); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java deleted file mode 100644 index 7c5bab860..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonCoreTests.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonCoreTests extends RestTest -{ - UserModel adminUser; - UserModel adminTenantUser; - UserModel tenantUser; - UserModel randomTestUser; - RestNetworkModel restNetworkModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyGetNetworkByAUserForAnotherUser() throws Exception - { - restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a personId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); - invalidUser.setUsername("invalidUsername"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that getNetwork status code is 404 for a networkId that does not exist") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception - { - UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); - invalidUser.setDomain("invalidNetworkId"); - - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request that is made using -me- instead of personId") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE }) - public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java deleted file mode 100644 index 3ce6393f9..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonFullTests.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.alfresco.rest.networks; - -import java.util.ArrayList; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.rest.model.RestNetworkQuotaModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonFullTests extends RestTest -{ - UserModel adminUser; - UserModel adminTenantUser; - UserModel secondAdminTenantUser; - UserModel tenantUser; - RestNetworkModel restNetworkModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); - restClient.usingTenant().createTenant(secondAdminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request response entry details") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyGetNetworkRequestResponseEntryDetails() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("quotas").is(new ArrayList()) - .assertThat().field("isEnabled").is("true") - .assertThat().field("homeNetwork").is("true") - .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify that properties parameter is applied to getNetwork request") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception - { - restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); - // TODO add assert that entry has only 1 field - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify getNetwork request status code is 404 for a network to which user does not belong") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java similarity index 52% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java index 908d7991f..11d744596 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonTests.java @@ -1,125 +1,210 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -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; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests for /people/{personId}/networks - */ -public class RestGetNetworkForPersonSanityTests extends RestTest -{ - UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; - UserModel tenantSiteManager; - UserModel tenantSiteCollaborator; - UserModel tenantSiteContributor; - UserModel tenantSiteConsumer; - SiteModel tenantSite; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); - tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); - tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); - tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); - tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); - dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); - } - - @Bug(id = "MNT-16904") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Bug(id = "needs to be checked") - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user check network of admin user with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site manager user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteManagerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site collaborator user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site contributor user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteContributorChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify site consumer user gets specific network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) - public void siteConsumerChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} +package org.alfresco.rest.networks; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.rest.model.RestNetworkQuotaModel; +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; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; + +/** + * Tests for /people/{personId}/networks + */ +public class RestGetNetworkForPersonTests extends RestTest +{ + UserModel adminUserModel; + UserModel adminTenantUser; + UserModel tenantUser; + UserModel tenantSiteManager; + UserModel tenantSiteCollaborator; + UserModel tenantSiteContributor; + UserModel tenantSiteConsumer; + SiteModel tenantSite; + RestNetworkModel restNetworkModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel); + restClient.usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager"); + tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator"); + tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor"); + tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer"); + tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite(); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor); + dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer); + } + + @Bug(id = "MNT-16904") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user check network of admin user with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify site manager user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + public void siteManagerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site contributor user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteContributorChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify site consumer user gets specific network with Rest API and response is not empty") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void siteConsumerChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Bug(id = "needs to be checked") + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkByAUserForAnotherUser() throws Exception + { + UserModel randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser"); + restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(tenantUser.getDomain()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a personId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername"); + invalidUser.setUsername("invalidUsername"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that getNetwork status code is 404 for a networkId that does not exist") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception + { + UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId"); + invalidUser.setDomain("invalidNetworkId"); + + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request that is made using -me- instead of personId") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("quotas").is(new ArrayList()) + .assertThat().field("isEnabled").is("true") + .assertThat().field("homeNetwork").is("true") + .assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify that properties parameter is applied to getNetwork request") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception + { + restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork(); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase()); + restNetworkModel.assertThat().fieldsCount().is(1); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify getNetwork request status code is 404 for a network to which user does not belong") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(secondAdminTenantUser); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } +} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java deleted file mode 100644 index 4b39e7d72..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkFullTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.alfresco.rest.networks; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestNetworkModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.report.Bug; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.http.HttpStatus; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Cristina Axinte - * - */ -public class RestGetNetworkFullTests extends RestTest -{ - UserModel adminTenantUser, adminuser; - UserModel adminAnotherTenantUser; - SiteModel site; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminuser = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminuser); - restClient.usingTenant().createTenant(adminTenantUser); - - adminAnotherTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(adminAnotherTenantUser); - - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant1"); - site = dataSite.usingUser(adminTenantUser).createPublicRandomSite(); - } - - @Bug(id = "ACE-5738") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminTenantGetsInvalidNetwork() throws Exception - { - restClient.authenticateUser(adminAnotherTenantUser); - adminAnotherTenantUser.setDomain("tenant.@%"); - - restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Bug(id = "ACE-5745") - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify admin user gets an existing network successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminUserGetsExistingNetwork() throws Exception - { - RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - restNetworkModel.assertThat().fieldsCount().is("1"); - restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) - .and().field("homeNetwork").isNull() - .and().field("isEnabled").is("true"); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL }) - public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception - { - JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.OK); - Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); - assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); - assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); - } - - private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) - { - try{ - entryResponse.get(field); - } - catch(JSONException ex) - { - Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); - } - } - - -} diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java similarity index 66% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java index a56e2cc0b..fb4b99c3c 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkTests.java @@ -1,6 +1,8 @@ package org.alfresco.rest.networks; import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestNetworkModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; @@ -8,24 +10,28 @@ import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; +import org.json.JSONException; +import org.json.JSONObject; import org.springframework.http.HttpStatus; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** * Created by Cristina Axinte on 9/26/2016. */ -public class RestGetNetworkSanityTests extends RestTest +public class RestGetNetworkTests extends RestTest { UserModel adminTenantUser; UserModel adminAnotherTenantUser; SiteModel site; UserModel tenantUser; + UserModel adminuser; @BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception { - UserModel adminuser = dataUser.getAdminUser(); + adminuser = dataUser.getAdminUser(); adminTenantUser = UserModel.getAdminTenantUser(); restClient.authenticateUser(adminuser); restClient.usingTenant().createTenant(adminTenantUser); @@ -68,9 +74,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(adminTenantUser); @@ -97,9 +103,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser).assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled(); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify any tenant user gets non existing network with Rest API and checks the not found status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception { restClient.authenticateUser(tenantUser); @@ -107,9 +113,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception { restClient.authenticateUser(tenantUser); @@ -117,9 +123,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify manager tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception { UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant"); @@ -130,9 +136,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception { UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant"); @@ -143,9 +149,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify consumer tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception { UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant"); @@ -156,9 +162,9 @@ public class RestGetNetworkSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, description = "Verify contributor tenant user gets its network with Rest API and response is not empty") - @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY }) + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception { UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant"); @@ -168,4 +174,68 @@ public class RestGetNetworkSanityTests extends RestTest restClient.withCoreAPI().usingNetworks().getNetwork(adminTenantUser); restClient.assertStatusCodeIs(HttpStatus.OK); } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @Bug(id = "ACE-5738") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsInvalidNetwork() throws Exception + { + restClient.authenticateUser(adminAnotherTenantUser); + adminAnotherTenantUser.setDomain("tenant.@%"); + + restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Bug(id = "ACE-5745") + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets an existing network successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminUserGetsExistingNetwork() throws Exception + { + RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + restNetworkModel.assertThat().fieldsCount().is("1"); + restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain()) + .and().field("homeNetwork").isNull() + .and().field("isEnabled").is("true"); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant admin user gets network using properties parameter successfully with Rest API") + @Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.REGRESSION }) + public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception + { + JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase())); + assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork"); + assertJsonResponseDoesnotContainField(entryResponse, "isEnabled"); + } + + private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field) + { + try{ + entryResponse.get(field); + } + catch(JSONException ex) + { + Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field))); + } + } } diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java deleted file mode 100644 index 8f1bd55fe..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonCoreTests.java +++ /dev/null @@ -1,80 +0,0 @@ -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.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonCoreTests extends RestTest -{ - private UserModel adminUserModel; - UserModel adminTenantUser; - UserModel tenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for skipCount") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void invalidValueForSkipCountTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using invalid value for maxItems") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void invalidValueForMaxItemsTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using personId that does not exist") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void inexistentTenantTest() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks using -me- instead of personId") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void specifyMeInsteadOfPersonIdTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Get tenant user networks and validate network entry") - @Test(groups = {TestGroup.REST_API, TestGroup.CORE, TestGroup.NETWORKS }) - public void checkNetworkEntryTest() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) - .and().field("quotas").is("[]") - .and().field("homeNetwork").is("false"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java deleted file mode 100644 index 6a4232416..000000000 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonFullTests.java +++ /dev/null @@ -1,88 +0,0 @@ -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.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonFullTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel adminTenantUser; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - restClient.authenticateUser(adminUserModel); - restClient.usingTenant().createTenant(adminTenantUser); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void getNetworksAndCheckErrorSchema() throws Exception - { - restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidUser", "invalidPassword")).getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidUser")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check default error schema for get networks for member") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void getNetworksAndCheckPropertiesParameter() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").isNull() - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that high skipCount parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatHighSkipCountParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.assertThat().entriesListIsEmpty(); - networks.assertThat().paginationField("skipCount").is("100"); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, - description = "Check that maxItems parameter is applied") - @Test(groups = { TestGroup.REST_API, TestGroup.FULL, TestGroup.NETWORKS }) - public void checkThatMaxItemsParameterIsApplied() throws Exception - { - RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") - .and().field("quotas").is("[]") - .and().field("isEnabled").is("true") - .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); - networks.assertThat().paginationField("maxItems").is("1"); - } - -} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java similarity index 50% rename from e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java rename to e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java index 4f46e7402..0bb738882 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonTests.java @@ -1,137 +1,238 @@ -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; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class RestGetNetworksForPersonSanityTests extends RestTest -{ - private UserModel adminUserModel; - private UserModel adminTenantUser; - private UserModel tenantUser; - private SiteModel siteModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUserModel = dataUser.getAdminUser(); - adminTenantUser = UserModel.getAdminTenantUser(); - 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 unauthorized status") - @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception - { - UserModel tenantUser = new UserModel("nonexisting", "password"); - tenantUser.setDomain(adminTenantUser.getDomain()); - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() - .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant admin user gets specific network with Rest API and response is not empty") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantChecksIfNetworkIsPresent() throws Exception - { - restClient.authenticateUser(adminTenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception - { - restClient.authenticateUser(tenantUser); - restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, - description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") - @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) - public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception - { - UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); - restClient.usingTenant().createTenant(secondAdminTenantUser); - UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); - restClient.authenticateUser(secondAdminTenantUser); - 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.SANITY, 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.SANITY, 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.SANITY, 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.SANITY, 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()); - } +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; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RestGetNetworksForPersonTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel adminTenantUser; + private UserModel tenantUser; + private SiteModel siteModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + 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 unauthorized status") + @Test(groups = { TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception + { + UserModel tenantUser = new UserModel("nonexisting", "password"); + tenantUser.setDomain(adminTenantUser.getDomain()); + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError() + .containsSummary(RestErrorModel.AUTHENTICATION_FAILED); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, + description = "Verify tenant admin user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.SANITY, TestGroup.NETWORKS }) + public void adminTenantChecksIfNetworkIsPresent() throws Exception + { + restClient.authenticateUser(adminTenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception + { + restClient.authenticateUser(tenantUser); + restClient.withCoreAPI().usingAuthUser().getNetworks(adminTenantUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception + { + UserModel secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.usingTenant().createTenant(secondAdminTenantUser); + UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant"); + restClient.authenticateUser(secondAdminTenantUser); + 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.SANITY, 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.REGRESSION, + description = "Verify tenant collaborator user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, 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.REGRESSION, + description = "Verify tenant contributor user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, 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.REGRESSION, + description = "Verify tenant consumer user gets specific network with Rest API and response is not empty") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, 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()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for skipCount") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForSkipCountTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("skipCount=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using invalid value for maxItems") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void invalidValueForMaxItemsTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withParams("maxItems=abc").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using personId that does not exist") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void inexistentTenantTest() throws Exception + { + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(new UserModel("invalidTenantUser", "password")).getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidTenantUser")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks using -me- instead of personId") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void specifyMeInsteadOfPersonIdTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled().and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Get tenant user networks and validate network entry") + @Test(groups = {TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkNetworkEntryTest() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertNetworkIsEnabled() + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()) + .and().field("quotas").is("[]") + .and().field("homeNetwork").is("false"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check default error schema for get networks for member") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void getNetworksAndCheckPropertiesParameter() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("properties=isEnabled,id").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").isNull() + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that high skipCount parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatHighSkipCountParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("skipCount=100").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.assertThat().entriesListIsEmpty(); + networks.assertThat().paginationField("skipCount").is("100"); + } + + @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION, + description = "Check that maxItems parameter is applied") + @Test(groups = { TestGroup.REST_API, TestGroup.REGRESSION, TestGroup.NETWORKS }) + public void checkThatMaxItemsParameterIsApplied() throws Exception + { + RestNetworkModelsCollection networks = restClient.authenticateUser(adminTenantUser).withParams("maxItems=1").withCoreAPI().usingAuthUser().getNetworks(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networks.getOneRandomEntry().onModel().assertThat().field("homeNetwork").is("false") + .and().field("quotas").is("[]") + .and().field("isEnabled").is("true") + .and().field("id").is(adminTenantUser.getDomain().toLowerCase()); + networks.assertThat().paginationField("maxItems").is("1"); + } } \ No newline at end of file