From 5fe8c016e84c8288021df9162ed154713576b78f Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:49:08 +0300 Subject: [PATCH 1/6] TAS-893 getSite with Manager role --- .../java/org/alfresco/rest/GetSiteTests.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/GetSiteTests.java diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java new file mode 100644 index 000000000..48b4226ed --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -0,0 +1,61 @@ +package org.alfresco.rest; + +import java.util.Arrays; +import java.util.HashMap; + +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.requests.RestSitesApi; +import org.alfresco.utility.data.DataSite; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.data.UserRole; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ + +@Test(groups = { "rest-api", "sites", "sanity" }) +public class GetSiteTests extends RestTest +{ + + @Autowired + DataUser dataUser; + + @Autowired + RestSitesApi siteAPI; + + @Autowired + DataSite dataSite; + + private UserModel adminUserModel; + private HashMap usersWithRoles; + private SiteModel siteModel; + + @BeforeClass + public void initTest() throws DataPreparationException + { + adminUserModel = dataUser.createRandomTestUser(); + restClient.authenticateUser(adminUserModel); + siteAPI.useRestClient(restClient); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, + Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); + } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") + public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } +} From c4a3a3f6d0b35a75874705f52672fcd61768d847 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:50:10 +0300 Subject: [PATCH 2/6] TAS-894 getSite with Collaborator role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 48b4226ed..01b43814b 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -58,4 +58,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") + public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 8992be8755688f43c4df66aa4186cd945fbfb8f2 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:50:51 +0300 Subject: [PATCH 3/6] TAS-895 getSite with Contributor role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 01b43814b..25d8da11e 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -67,4 +67,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") + public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 4f6107294f8b463da1c591167b6a25805d5ba974 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:51:51 +0300 Subject: [PATCH 4/6] TAS-896 getSite with Consumer role --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 25d8da11e..1788490e2 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -76,4 +76,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From 16758317b886e52ec7e86ce13fe22b6c2b424215 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:52:30 +0300 Subject: [PATCH 5/6] TAS-897 getSite with admin user --- e2e-test/java/org/alfresco/rest/GetSiteTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteTests.java index 1788490e2..9da55c4ab 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteTests.java @@ -85,4 +85,13 @@ public class GetSiteTests extends RestTest siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception + { + + restClient.authenticateUser(adminUserModel); + siteAPI.getSite(siteModel.getId()); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); + } } From a316935c77f5335aa7b6dfa1f7de14b042b71bb1 Mon Sep 17 00:00:00 2001 From: Iulia Nechita Date: Tue, 27 Sep 2016 16:54:49 +0300 Subject: [PATCH 6/6] TAS-898 getSite status code 401 with Manager role --- ...SiteTests.java => GetSiteSanityTests.java} | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) rename e2e-test/java/org/alfresco/rest/{GetSiteTests.java => GetSiteSanityTests.java} (69%) diff --git a/e2e-test/java/org/alfresco/rest/GetSiteTests.java b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java similarity index 69% rename from e2e-test/java/org/alfresco/rest/GetSiteTests.java rename to e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java index 9da55c4ab..32076dc28 100644 --- a/e2e-test/java/org/alfresco/rest/GetSiteTests.java +++ b/e2e-test/java/org/alfresco/rest/GetSiteSanityTests.java @@ -23,7 +23,7 @@ import org.testng.annotations.Test; */ @Test(groups = { "rest-api", "sites", "sanity" }) -public class GetSiteTests extends RestTest +public class GetSiteSanityTests extends RestTest { @Autowired @@ -37,12 +37,13 @@ public class GetSiteTests extends RestTest private UserModel adminUserModel; private HashMap usersWithRoles; + private UserModel userModel; private SiteModel siteModel; @BeforeClass public void initTest() throws DataPreparationException { - adminUserModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); restClient.authenticateUser(adminUserModel); siteAPI.useRestClient(restClient); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); @@ -50,48 +51,60 @@ public class GetSiteTests extends RestTest Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor)); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site information and gets status code OK (200)") public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Collaborator role gets site information and gets status code OK (200)") public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Contributor role gets site information and gets status code OK (200)") public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with Consumer role gets site information and gets status code OK (200)") public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer)); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } - @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets site information and gets status code OK (200)") + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Verify user with admin role gets site information and gets status code OK (200)") public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel); siteAPI.getSite(siteModel.getId()); siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString()); } + + @TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site call returns status code 401 with Manager role") + public void getSiteWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception + { + userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); + restClient.authenticateUser(userModel); + siteAPI.getAllSites(); + siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString()); + } }