Merge branch 'TAS-729' into 'master'

Tas 729

TAS-729 RestAPI: Automate: getSiteForMember (get /people/{personId}/sites/{siteId}) call

See merge request !36
This commit is contained in:
Corina Nechifor
2016-10-03 22:38:16 +01:00
4 changed files with 157 additions and 150 deletions
@@ -1,9 +1,9 @@
package org.alfresco.rest.sites;
package org.alfresco.rest.people;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.body.SiteMembership;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.requests.RestSitesApi;
import org.alfresco.rest.requests.RestPeopleApi;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
@@ -15,14 +15,15 @@ import org.alfresco.utility.report.Bug;
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;
@Test(groups = { "rest-api", "sites", "sanity" })
@Test(groups = { "rest-api", "people", "sanity" })
public class AddSiteMembershipRequestSanityTests extends RestTest
{
@Autowired
RestSitesApi siteAPI;
RestPeopleApi peopleApi;
@Autowired
DataUser dataUser;
@@ -43,20 +44,21 @@ public class AddSiteMembershipRequestSanityTests extends RestTest
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
siteAPI.useRestClient(restClient);
peopleApi.useRestClient(restClient);
}
@TestRail(section = { "rest-api","sites" }, executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request")
@Bug(id="MNT-16557")
@Test(enabled=false)
@TestRail(section = { "rest-api","people" },
executionType = ExecutionType.SANITY, description = "Verify site manager is able to create new site membership request")
@Bug(id="MNT-16557")
public void siteManagerCanCreateSiteMembershipRequest() throws JsonToModelConversionException, Exception
{
UserModel newMember = dataUser.createRandomTestUser();
SiteMembership siteMembership = new SiteMembership("Please accept me", siteModel.getId(), "New request");
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
siteAPI.addSiteMembershipRequest(newMember, siteMembership);
siteAPI.getSite(siteModel).assertResponseIsNotEmpty();
peopleApi.addSiteMembershipRequest(newMember, siteMembership);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
}
@@ -0,0 +1,109 @@
package org.alfresco.rest.people;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.requests.RestPeopleApi;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
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;
@Test(groups = { "rest-api", "people", "sanity" })
public class GetSiteMembershipSanityTests extends RestTest
{
@Autowired
RestPeopleApi peopleApi;
@Autowired
DataUser dataUser;
@Autowired
DataSite dataSite;
private SiteModel siteModel;
private UserModel adminUser;
private ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws DataPreparationException
{
adminUser = dataUser.getAdminUser();
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
peopleApi.useRestClient(restClient);
}
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify site manager is able to retrieve site membership information of another user")
public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
peopleApi.getSiteMembership(adminUser, siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api",
"people" }, executionType = ExecutionType.SANITY, description = "Verify site collaborator is able to retrieve site membership information of another user")
public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
peopleApi.getSiteMembership(adminUser, siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api",
"people" }, executionType = ExecutionType.SANITY, description = "Verify site contributor is able to retrieve site membership information of another user")
public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
peopleApi.getSiteMembership(adminUser, siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api",
"people" }, executionType = ExecutionType.SANITY, description = "Verify site consumer is able to retrieve site membership information of another user")
public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
peopleApi.getSiteMembership(adminUser, siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api",
"people" }, executionType = ExecutionType.SANITY, description = "Verify admin user is able to retrieve site membership information of another user")
public void adminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUser);
peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api",
"people" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to retrieve site membership information of another user")
public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(new UserModel("random user", "random password"));
peopleApi.getSiteMembership(usersWithRoles.getOneUserWithRole(UserRole.SiteManager), siteModel);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
}
@@ -1,8 +1,8 @@
package org.alfresco.rest.sites;
package org.alfresco.rest.people;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.requests.RestSitesApi;
import org.alfresco.rest.requests.RestPeopleApi;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
@@ -17,11 +17,11 @@ import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { "rest-api", "sites", "sanity" })
public class GetSiteMembershipInformationSanityTests extends RestTest
@Test(groups = { "rest-api", "people", "sanity" })
public class GetSitesMembershipInformationSanityTests extends RestTest
{
@Autowired
RestSitesApi siteAPI;
RestPeopleApi peopleApi;
@Autowired
DataUser dataUser;
@@ -40,73 +40,73 @@ public class GetSiteMembershipInformationSanityTests extends RestTest
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
siteAPI.useRestClient(restClient);
peopleApi.useRestClient(restClient);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify site manager is able to retrieve site membership information of another user")
public void siteManagerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify site manager is able to retrieve sites membership information of another user")
public void siteManagerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
siteAPI.getSiteMembershipInformation(adminUser);
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(adminUser);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify site collaborator is able to retrieve site membership information of another user")
public void siteCollaboratorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify site collaborator is able to retrieve sites membership information of another user")
public void siteCollaboratorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
siteAPI.getSiteMembershipInformation(adminUser);
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(adminUser);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify site contributor is able to retrieve site membership information of another user")
public void siteContributorCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify site contributor is able to retrieve sites membership information of another user")
public void siteContributorCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
siteAPI.getSiteMembershipInformation(adminUser);
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(adminUser);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify site consumer is able to retrieve site membership information of another user")
public void siteConsumerCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify site consumer is able to retrieve sites membership information of another user")
public void siteConsumerCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
siteAPI.getSiteMembershipInformation(adminUser);
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(adminUser);
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify admin is able to retrieve site membership information of another user")
public void siteAdminCanRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify admin is able to retrieve sites membership information of another user")
public void siteAdminCanRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUser);
siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" },
@TestRail(section = { "rest-api", "people" },
executionType = ExecutionType.SANITY,
description = "Verify that unauthenticated user is not able to retrieve site membership information")
public void unauthenticatedUserCannotRetrieveSiteMembershipInformation() throws JsonToModelConversionException, Exception
description = "Verify that unauthenticated user is not able to retrieve sites membership information")
public void unauthenticatedUserCannotRetrieveSitesMembershipInformation() throws JsonToModelConversionException, Exception
{
UserModel inexistentUser = new UserModel("inexistent user", "wrong password");
restClient.authenticateUser(inexistentUser);
siteAPI.getSiteMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
siteAPI.usingRestWrapper()
peopleApi.getSitesMembershipInformation(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
peopleApi.usingRestWrapper()
.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@@ -1,104 +0,0 @@
package org.alfresco.rest.sites;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.requests.RestSitesApi;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
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", "comments", "sanity" })
public class GetSitesTests extends RestTest
{
@Autowired
RestSitesApi siteAPI;
@Autowired
DataUser dataUser;
@Autowired
DataSite dataSite;
private UserModel adminUserModel;
private UserModel userModel;
private ListUserWithRoles usersWithRoles;
private SiteModel siteModel;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUserModel = dataUser.getAdminUser();
restClient.authenticateUser(adminUserModel);
siteAPI.useRestClient(restClient);
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)")
public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)")
public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)")
public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)")
public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)")
public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role")
public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
userModel = dataUser.createRandomTestUser();
userModel.setPassword("user wrong password");
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
restClient.authenticateUser(userModel);
siteAPI.getAllSites();
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
}