Merge branch 'TAS-2805' into 'master'

Tas 2805

See merge request !395
This commit is contained in:
Valentin Popa
2017-01-26 10:00:13 +00:00
2 changed files with 282 additions and 6 deletions
@@ -0,0 +1,279 @@
package org.alfresco.rest.sites;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestRequest;
import org.alfresco.rest.model.RestErrorModel;
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.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class UpdateSiteMemberFullTests extends RestTest
{
private UserModel adminUser, anotherManager;
private SiteModel publicSite, moderatedSite, privateSite;
private RestSiteMemberModel updatedMember;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
publicSite = dataSite.usingUser(adminUser).createPublicRandomSite();
moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite();
privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite();
anotherManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(anotherManager, publicSite, UserRole.SiteManager);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update another site manager to site contributor")
public void managerUpdateSiteManagerToSiteContributor() throws Exception
{
UserModel siteManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager);
siteManager.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteManager);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update another site manager to site consumer")
public void managerUpdateSiteManagerToSiteConsumer() throws Exception
{
UserModel siteManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager);
siteManager.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteManager);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site contributor to site collaborator")
public void managerUpdateSiteContributorToSiteCollaborator() throws Exception
{
UserModel siteContributor = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor);
siteContributor.setUserRole(UserRole.SiteCollaborator);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteContributor);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site contributor to site consumer")
public void managerUpdateSiteContributorToSiteConsumer() throws Exception
{
UserModel siteContributor = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor);
siteContributor.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteContributor);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site collaborator to site contributor")
public void managerUpdateSiteCollaboratorToSiteContributor() throws Exception
{
UserModel siteCollaborator = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator);
siteCollaborator.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteCollaborator);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site collaborator to site consumer")
public void managerUpdateSiteCollaboratorToSiteConsumer() throws Exception
{
UserModel siteCollaborator = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator);
siteCollaborator.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteCollaborator);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site consumer to site collaborator")
public void managerUpdateSiteConsumerToSiteCollaborator() throws Exception
{
UserModel siteConsumer = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer);
siteConsumer.setUserRole(UserRole.SiteCollaborator);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteConsumer);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site consumer to site contributor")
public void managerUpdateSiteConsumerToSiteContributor() throws Exception
{
UserModel siteConsumer = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer);
siteConsumer.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteConsumer);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update another site manager to site manager")
public void managerUpdateSiteManagerToSiteManager() throws Exception
{
UserModel siteManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteManager, publicSite, UserRole.SiteManager);
siteManager.setUserRole(UserRole.SiteManager);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteManager);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site collaborator to site collaborator")
public void managerUpdateSiteCollaboratorToSiteCollaborator() throws Exception
{
UserModel siteCollaborator = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator);
siteCollaborator.setUserRole(UserRole.SiteCollaborator);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteCollaborator);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteCollaborator.getUsername()).and().field("role").is(siteCollaborator.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site contributor to site contributor")
public void managerUpdateSiteContributorToSiteContributor() throws Exception
{
UserModel siteContributor = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteContributor, publicSite, UserRole.SiteContributor);
siteContributor.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteContributor);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteContributor.getUsername()).and().field("role").is(siteContributor.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update site consumer to site consumer")
public void managerUpdateSiteConsumerToSiteConsumer() throws Exception
{
UserModel siteConsumer = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteConsumer, publicSite, UserRole.SiteConsumer);
siteConsumer.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(publicSite).updateSiteMember(siteConsumer);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteConsumer.getUsername()).and().field("role").is(siteConsumer.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager of a private site is able to downgrade his role")
public void privateSiteManagerDowngradesRole() throws Exception
{
UserModel siteManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteManager, privateSite, UserRole.SiteManager);
siteManager.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(siteManager).withCoreAPI()
.usingSite(privateSite).updateSiteMember(siteManager);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole());
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager of a moderated site is able to downgrade his role")
public void moderatedSiteManagerDowngradesRole() throws Exception
{
UserModel siteManager = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteManager, moderatedSite, UserRole.SiteManager);
siteManager.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(siteManager).withCoreAPI()
.usingSite(moderatedSite).updateSiteMember(siteManager);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(siteManager.getUsername()).and().field("role").is(siteManager.getUserRole());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION,
description = "Verify the response of updating a site member with empty body at request")
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL })
public void verifyManagerCanNotUpdateSiteMemberWithEmptyBody() throws Exception
{
restClient.authenticateUser(anotherManager).withCoreAPI();
UserModel siteCollaborator = dataUser.createRandomTestUser();
dataUser.addUserToSite(siteCollaborator, publicSite, UserRole.SiteCollaborator);
siteCollaborator.setUserRole(UserRole.SiteConsumer);
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, "", "sites/{siteId}/members/{personId}", publicSite.getId(), siteCollaborator.getUsername());
restClient.processModel(RestSiteMemberModel.class, request);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"))
.containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map to Object due to end of input"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.FULL })
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify if manager is able to update a user that has created a site membership request, but it's not a member of the site yet")
public void verifyManagerCanNotUpdateUserWithSiteMembershipRequest() throws Exception
{
UserModel siteConsumer = dataUser.createRandomTestUser();
siteConsumer.setUserRole(UserRole.SiteConsumer);
restClient.authenticateUser(siteConsumer).withCoreAPI().usingUser(siteConsumer).addSiteMembershipRequest(moderatedSite);
updatedMember = restClient.authenticateUser(anotherManager).withCoreAPI()
.usingSite(moderatedSite).updateSiteMember(siteConsumer);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary(RestErrorModel.NOT_A_MEMBER);
}
}
@@ -45,7 +45,6 @@ public class UpdateSiteMemberSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Bug(id="ACE-5444")
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify that collaborator is not able to update site member and gets status code FORBIDDEN (403)")
@@ -54,12 +53,11 @@ public class UpdateSiteMemberSanityTests extends RestTest
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
testUserModel.setUserRole(UserRole.SiteCollaborator);
restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY);
restClient.assertLastError()
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
}
@Bug(id="ACE-5444")
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify that contributor is not able to update site member and gets status code FORBIDDEN (403)")
@@ -68,12 +66,11 @@ public class UpdateSiteMemberSanityTests extends RestTest
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
testUserModel.setUserRole(UserRole.SiteCollaborator);
restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY);
restClient.assertLastError()
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
}
@Bug(id="ACE-5444")
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify that consumer is not able to update site member and gets status code FORBIDDEN (403)")
@@ -84,7 +81,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUserModel);
restClient.assertLastError()
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })