package org.alfresco.rest; import org.alfresco.rest.model.RestSiteMemberModel; 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.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 FunctionalCasesTests extends RestTest { private UserModel adminUserModel; private SiteModel siteModel; private RestSiteMemberModel updatedMember; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); } /** * Scenario: * 1. Add a site member as Manager * 2. Update it's role to Collaborator * 3. Update it's role to Contributor * 4. Update it's role to Consumer */ @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update manager with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateManagerWithDifferentRoles() throws Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteCollaborator); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteContributor); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteConsumer); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } /** * Scenario: * 1. Add a site member as Consumer * 2. Update it's role to Contributor * 3. Update it's role to Collaborator * 4. Update it's role to Manager */ @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager is able to update consumer with different roles and gets status code CREATED (201)") public void managerIsAbleToUpdateConsumerWithDifferentRoles() throws Exception { UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser) .assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); restClient.assertStatusCodeIs(HttpStatus.CREATED); testUser.setUserRole(UserRole.SiteContributor); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteCollaborator); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); testUser.setUserRole(UserRole.SiteManager); updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI() .usingSite(siteModel).updateSiteMember(testUser); restClient.assertStatusCodeIs(HttpStatus.OK); updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole()); } }