mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch '5.2.N' into TAS-2024
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
package org.alfresco.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.ErrorModel;
|
||||
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;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE })
|
||||
public class DeleteFavoriteSiteCoreTests extends RestTest
|
||||
{
|
||||
UserModel userModel;
|
||||
SiteModel siteModel;
|
||||
UserModel adminUserModel;
|
||||
RestSiteModel restSiteModel;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user removes a site from favorites using '-me-' in place of personId with Rest API and response is successful (204)")
|
||||
public void removeFavoriteSiteWithSuccessUsingMeAsPersonId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
restClient.withCoreAPI().usingMe().removeFavoriteSite(siteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify inexistent user is not able to remove a site from favorites and response is 404")
|
||||
public void inexistentUserIsNotAbleToRemoveFavoriteSite() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
UserModel inexistentUser = new UserModel("inexistenUser", "password");
|
||||
restClient.withCoreAPI().usingUser(inexistentUser).removeFavoriteSite(siteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "inexistenUser"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify user is not able to remove from favorites a site with inexistent id and response is 404")
|
||||
public void userIsNotAbleToRemoveFavoriteSiteWithInexistentId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
dataSite.usingUser(adminUserModel).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
SiteModel inexistentSite = new SiteModel("inexistentSite");
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).removeFavoriteSite(inexistentSite);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(ErrorModel.RELATIONSHIP_NOT_FOUND, adminUserModel.getUsername(), inexistentSite.getTitle()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorites abd add it again and response is successful (204)")
|
||||
public void managerUserRemovesFavoriteSiteAndAddItAgain() throws Exception
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingUser(managerUser).addFavoriteSite(siteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify manager user removes a site from its favorite sites list with Rest API and response is successful (204)")
|
||||
public void managerUserRemovesFavoriteSiteWithSuccess() throws Exception
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
dataSite.usingUser(managerUser).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().removeFavoriteSite(siteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingAuthUser().getFavorites().assertThat().entriesListDoesNotContain("id", siteModel.getId());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify uninvited user can delete favorite public site and response is 204")
|
||||
public void uninvitedUserCanDeleteFavoritePublicSite() throws Exception
|
||||
{
|
||||
SiteModel publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(publicSiteModel);
|
||||
|
||||
restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(publicSiteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", publicSiteModel.getId());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify uninvited user can delete favorite moderated site and response is 204")
|
||||
public void uninvitedUserCanDeleteFavoriteModeratedSite() throws Exception
|
||||
{
|
||||
SiteModel moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite();
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(moderatedSiteModel);
|
||||
|
||||
restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(moderatedSiteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", moderatedSiteModel.getId());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify user can delete favorite private site and response is 204")
|
||||
public void userCanDeleteFavoritePrivateSite() throws Exception
|
||||
{
|
||||
SiteModel privateSiteModel = dataSite.usingUser(userModel).createPrivateRandomSite();
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).addFavoriteSite(privateSiteModel);
|
||||
|
||||
restClient.withCoreAPI().usingAuthUser().removeFavoriteSite(privateSiteModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingAuthUser().getFavoriteSites().assertThat().entriesListDoesNotContain("id", privateSiteModel.getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.ErrorModel;
|
||||
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.springframework.social.alfresco.api.entities.Site.Visibility;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 11/22/2016.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE })
|
||||
public class GetSitesCoreTests extends RestTest
|
||||
{
|
||||
private UserModel userModel, privateSiteManager, privateSiteConsumer;
|
||||
private SiteModel publicSite, privateSite, moderatedSite, deletedSite;
|
||||
private RestSiteModelsCollection sites;
|
||||
private SiteModel siteModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
privateSiteManager = dataUser.createRandomTestUser();
|
||||
privateSiteConsumer = dataUser.createRandomTestUser();
|
||||
siteModel = new SiteModel(RandomData.getRandomName("0-PublicSite"));
|
||||
publicSite = dataSite.usingAdmin().createSite(siteModel);
|
||||
siteModel = new SiteModel(RandomData.getRandomName("0-PrivateSite"), Visibility.PRIVATE);
|
||||
privateSite = dataSite.usingAdmin().createSite(siteModel);
|
||||
siteModel = new SiteModel(RandomData.getRandomName("0-ModeratedSite"), Visibility.MODERATED);
|
||||
moderatedSite = dataSite.usingAdmin().createSite(siteModel);
|
||||
dataUser.addUserToSite(privateSiteManager, privateSite, UserRole.SiteManager);
|
||||
dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer);
|
||||
deletedSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify invalid request returns status code 400 for invalid maxItems")
|
||||
public void checkStatusCodeForInvalidMaxItems() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withParams("maxItems=0")
|
||||
.withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify invalid request returns status code 400 for invalid skipCount")
|
||||
public void checkStatusCodeForInvalidSkipCount() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withParams("skipCount=A")
|
||||
.withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User gets sites ordered by name ascendant and status code is 200")
|
||||
public void getSitesOrderedByNameASC() throws Exception
|
||||
{
|
||||
sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=name ASC")
|
||||
.withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sites.assertThat().entriesListIsNotEmpty();
|
||||
List<RestSiteModel> sitesList = sites.getEntries();
|
||||
sitesList.get(0).onModel().assertThat().field("title").is(moderatedSite.getTitle());
|
||||
sitesList.get(1).onModel().assertThat().field("title").is(privateSite.getTitle());
|
||||
sitesList.get(2).onModel().assertThat().field("title").is(publicSite.getTitle());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify if any user gets all public and moderated sites and status code is 200")
|
||||
public void userGetsOnlyPublicAndModeratedSites() throws Exception
|
||||
{
|
||||
sites = restClient.authenticateUser(userModel).withParams("maxItems=5000")
|
||||
.withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sites.assertThat().entriesListContains("title", publicSite.getTitle())
|
||||
.and().entriesListContains("title", moderatedSite.getTitle())
|
||||
.and().entriesListDoesNotContain("title", privateSite.getTitle());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify if a member of a private site gets the private site, all public sites and all moderated sites. Verify if status code is 200")
|
||||
public void userGetsSitesVisibleForHim() throws Exception
|
||||
{
|
||||
sites = restClient.authenticateUser(privateSiteConsumer).withParams("maxItems=5000")
|
||||
.withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sites.assertThat().entriesListContains("title", publicSite.getTitle())
|
||||
.and().entriesListContains("title", moderatedSite.getTitle())
|
||||
.and().entriesListContains("title", privateSite.getTitle());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify if a site is not retrieved anymore after deletion and status code is 200")
|
||||
public void checkDeletedSiteIsNotRetrieved() throws Exception
|
||||
{
|
||||
sites = restClient.authenticateUser(userModel).withParams("maxItems=5000").withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sites.assertThat().entriesListContains("title", deletedSite.getTitle());
|
||||
|
||||
dataSite.usingAdmin().deleteSite(deletedSite);
|
||||
|
||||
sites = restClient.withParams("maxItems=5000").withCoreAPI().getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sites.assertThat().entriesListDoesNotContain("title", deletedSite.getTitle());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun=true)
|
||||
public void cleanup() throws Exception
|
||||
{
|
||||
dataSite.usingAdmin().deleteSite(moderatedSite);
|
||||
dataSite.usingAdmin().deleteSite(privateSite);
|
||||
dataSite.usingAdmin().deleteSite(publicSite);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user