mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPersonFavoritesModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
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 GetFavoriteCoreTests extends RestTest {
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private FolderModel folderModel;
|
||||
private FileModel fileModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception {
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
siteModel.setGuid(
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when person id does't exist")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE })
|
||||
public void getFavoriteSiteWhenPersonIdNotExist() throws JsonToModelConversionException, Exception {
|
||||
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel);
|
||||
UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername()))
|
||||
.statusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when favorite id does't exist")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE })
|
||||
public void getFavoriteSiteWhenFavoriteIdNotExist() throws JsonToModelConversionException, Exception {
|
||||
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).getFavorite("invalidId");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidId"))
|
||||
.statusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite user doesn't have any favorite site, file or folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE })
|
||||
public void getFavoriteSiteForUserWithoutAnyFavorites() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername(), siteModel.getGuid()))
|
||||
.statusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site for -me-")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.CORE })
|
||||
public void getFavoriteSiteUsingMe() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingMe().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.alfresco.rest.favorites;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPersonFavoritesModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
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 GetFavoriteFullTests extends RestTest {
|
||||
private UserModel adminUserModel, networkUserModel;
|
||||
private SiteModel siteModel;
|
||||
private FolderModel folderModel;
|
||||
private FileModel fileModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception {
|
||||
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
siteModel.setGuid(
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify get favorite site when using invalid network id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.FULL })
|
||||
public void getFavoriteSiteWhenNetworkIdIsInvalid() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel);
|
||||
UserModel someUser = new UserModel("invalidUser", DataUser.PASSWORD);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(someUser).getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, someUser.getUsername()))
|
||||
.statusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPersonFavoritesModel;
|
||||
import org.alfresco.rest.model.RestPersonFavoritesModelsCollection;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -27,8 +28,6 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
private FolderModel folderModel;
|
||||
private FileModel fileModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestSiteModelsCollection restSiteModelsCollection;
|
||||
private RestPersonFavoritesModelsCollection restPersonFavoritesModelsCollection;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -53,9 +52,9 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
{
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addSiteToFavorites(siteModel);
|
||||
|
||||
restSiteModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavoriteSites();
|
||||
RestPersonFavoritesModel favoriteSite = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid());
|
||||
favoriteSite.assertThat().field("targetGuid").equals(siteModel.getGuid());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -65,10 +64,9 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
{
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addFolderToFavorites(folderModel);
|
||||
|
||||
restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites();
|
||||
RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(folderModel.getNodeRef());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", folderModel.getNodeRef());
|
||||
|
||||
favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -78,50 +76,135 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
{
|
||||
restClient.withCoreAPI().usingUser(adminUserModel).addFileToFavorites(fileModel);
|
||||
|
||||
restPersonFavoritesModelsCollection = restClient.withCoreAPI().usingUser(adminUserModel).getFavorites();
|
||||
RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingUser(adminUserModel).getFavorite(fileModel.getNodeRefWithoutVersion());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPersonFavoritesModelsCollection.and().entriesListContains("targetGuid", fileModel.getNodeRefWithoutVersion());
|
||||
favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user gets favorite site with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void managerIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception
|
||||
public void managerIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel);
|
||||
|
||||
restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites();
|
||||
RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid());
|
||||
favSite.assertThat().field("targetGuid").equals(siteModel.getGuid());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user gets favorite folder with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void managerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user gets favorite file with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void managerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef());
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Collaborator user gets favorite site with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveFavorites() throws JsonToModelConversionException, Exception
|
||||
public void collaboratorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel);
|
||||
|
||||
restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites();
|
||||
RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid());
|
||||
favSite.assertThat().field("targetGuid").equals(siteModel.getGuid());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify collaborator user gets favorite folder with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify collaborator user gets favorite file with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef());
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Contributor user gets favorite site with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void contributorIsAbleToRetrieveFavorite() throws JsonToModelConversionException, Exception
|
||||
public void contributorIsAbleToRetrieveFavoriteSite() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel);
|
||||
|
||||
restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites();
|
||||
RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid());
|
||||
favSite.assertThat().field("targetGuid").equals(siteModel.getGuid()); ;
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify contributor user gets favorite folder with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void contributorIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify contributor user gets favorite file with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void contributorIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef());
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Consumer user gets favorite site with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
@@ -130,11 +213,38 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingAuthUser().addSiteToFavorites(siteModel);
|
||||
|
||||
restSiteModelsCollection = restClient.withCoreAPI().usingAuthUser().getFavoriteSites();
|
||||
RestPersonFavoritesModel favSite = restClient.withCoreAPI().usingAuthUser().getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restSiteModelsCollection.and().entriesListContains("guid",siteModel.getGuid());
|
||||
favSite.assertThat().field("targetGuid").equals(siteModel.getGuid());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify consumer user gets favorite folder with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void consumerIsAbleToRetrieveFavoriteFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingAuthUser().addFolderToFavorites(folderModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFolder = restClient.withCoreAPI().usingAuthUser().getFavorite(folderModel.getNodeRef());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFolder.assertThat().field("targetGuid").equals(folderModel.getNodeRef());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify consumer user gets favorite file with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
public void consumerIsAbleToRetrieveFavoriteFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingAuthUser().addFileToFavorites(fileModel);
|
||||
|
||||
RestPersonFavoritesModel favoriteFile = restClient.withCoreAPI().usingAuthUser().getFavorite(fileModel.getNodeRefWithoutVersion());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
favoriteFile.assertThat().field("targetGuid").equals(fileModel.getNodeRef());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user doesn't get favorite site of another user with Rest API and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.FAVORITES, TestGroup.SANITY })
|
||||
@@ -181,7 +291,8 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager).withCoreAPI()
|
||||
.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).getFavorite(siteModel.getGuid());
|
||||
.usingUser(siteManager).getFavorite(siteModel.getGuid());
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastExceptionContains(HttpStatus.UNAUTHORIZED.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.alfresco.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPersonModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
*/
|
||||
public class GetPeopleCoreTests extends RestTest
|
||||
{
|
||||
UserModel userModel;
|
||||
SiteModel siteModel;
|
||||
UserModel searchedUser;
|
||||
UserModel adminUser, managerUser;
|
||||
UserModel inexistentUser;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
searchedUser = dataUser.createRandomTestUser();
|
||||
managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
inexistentUser = new UserModel("inexistentUser", "password");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify inexistent user cannot get a person with Rest API and response is 401")
|
||||
public void inexistentUserIsUnauthorizedToGetPerson() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(inexistentUser).withCoreAPI().usingUser(searchedUser).getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user cannot get a person that doesn't exists with Rest API and response is 404")
|
||||
public void userCannotGetInexistentPerson() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(managerUser).withCoreAPI().usingUser(inexistentUser).getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
restClient.assertLastError().containsSummary(String.format(inexistentUser.getUsername(), RestErrorModel.ENTITY_NOT_FOUND));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package org.alfresco.rest.people;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPersonModel;
|
||||
import org.alfresco.rest.model.RestPersonModelsCollection;
|
||||
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.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetPeopleFullTests extends RestTest
|
||||
{
|
||||
UserModel userModel;
|
||||
SiteModel siteModel;
|
||||
UserModel searchedUser, managerUser;
|
||||
UserModel adminUser;
|
||||
private RestPersonModel personModel;
|
||||
private String domain = "@tas-automation.org";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
searchedUser = dataUser.createRandomTestUser();
|
||||
managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets person using '-me-' instead of personId with Rest API and response is successful")
|
||||
public void checkGetPersonIsSuccessfulForMe() throws Exception
|
||||
{
|
||||
personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingMe().getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
personModel.assertThat().field("id").is(managerUser.getUsername())
|
||||
.and().field("firstName").is(managerUser.getUsername() + " FirstName")
|
||||
.and().field("email").is(managerUser.getUsername() + domain)
|
||||
.and().field("emailNotificationsEnabled").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get person response with Rest API")
|
||||
public void checkResponseSchemaForGetPerson() throws Exception
|
||||
{
|
||||
RestPersonModel newUser = RestPersonModel.getRandomPersonModel("aspectNames", "avatarId", "statusUpdatedAt");
|
||||
newUser = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().createPerson(newUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
personModel = restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel(newUser.getId(), newUser.getPassword())).getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
personModel.assertThat().field("id").is(newUser.getId())
|
||||
.and().field("firstName").is(newUser.getFirstName())
|
||||
.and().field("lastName").is(newUser.getLastName())
|
||||
.and().field("description").is(newUser.getDescription())
|
||||
.and().field("email").is(newUser.getEmail())
|
||||
.and().field("skypeId").is(newUser.getSkypeId())
|
||||
.and().field("googleId").is(newUser.getGoogleId())
|
||||
.and().field("instantMessageId").is(newUser.getInstantMessageId())
|
||||
.and().field("jobTitle").is(newUser.getJobTitle())
|
||||
.and().field("location").is(newUser.getLocation())
|
||||
.and().field("mobile").is(newUser.getMobile())
|
||||
.and().field("telephone").is(newUser.getTelephone())
|
||||
.and().field("userStatus").is(newUser.getUserStatus())
|
||||
.and().field("enabled").is(newUser.getEnabled())
|
||||
.and().field("emailNotificationsEnabled").is(newUser.getEmailNotificationsEnabled());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets a person with special chars in username with Rest API and response is not found")
|
||||
public void userChecksIfPersonWithSpecilCharsInUsernameIsNotFound() throws Exception
|
||||
{
|
||||
UserModel userSpecialChars = dataUser.usingAdmin().createUser(RandomStringUtils.randomAlphabetic(2) + "~!@#$%^&*()_+[]{}|\\;':\",./<>", "password");
|
||||
//setting the encoded text for username
|
||||
userSpecialChars.setUsername(RandomStringUtils.randomAlphabetic(2) + "~!%40%23%24%25%5E%26*()_%2B%5B%5D%7B%7D%7C%5C%3B%27%3A%22%2C.%2F%3C%3E");
|
||||
|
||||
personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(userSpecialChars).getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, userSpecialChars.getUsername()))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets a person with empty personId with Rest API and response is successful")
|
||||
public void userGetPersonWithEmptyPersonId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(managerUser).withCoreAPI();
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}?{parameters}", "", restClient.getParameters());
|
||||
RestPersonModelsCollection persons = restClient.processModels(RestPersonModelsCollection.class, request);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
persons.assertThat().entriesListIsNotEmpty();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin user with Rest API and response is successful")
|
||||
public void managerUserGetAdminPerson() throws Exception
|
||||
{
|
||||
personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(adminUser).getPerson();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
personModel.assertThat().field("id").is(adminUser.getUsername())
|
||||
.and().field("firstName").is("Administrator")
|
||||
.and().field("email").is("admin@alfresco.com")
|
||||
.and().field("emailNotificationsEnabled").is("true")
|
||||
.and().field("enabled").is("true");
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,6 @@ public class GetPeopleSanityTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
personModel.assertThat().field("id").is(searchedUser.getUsername()).assertThat().field("firstName").is(searchedUser.getUsername() + " FirstName").and()
|
||||
.field("email").is(searchedUser.getUsername() + domain).and().field("emailNotificationsEnabled").is("true");
|
||||
;
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY })
|
||||
|
||||
@@ -57,9 +57,12 @@ public class GetTasksCoreTests extends RestTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE })
|
||||
public void orderByParameterApplied() throws Exception
|
||||
{
|
||||
taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id").withWorkflowAPI().getTasks();
|
||||
|
||||
|
||||
taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("orderBy=id DESC").withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
taskModels.assertThat().entriesListIsNotEmpty();
|
||||
taskModels.assertThat().entriesListIsNotEmpty().
|
||||
and().entriesListIsSortedAscBy("id");
|
||||
List<RestTaskModel> tasksList = taskModels.getEntries();
|
||||
List<String> taskIds = new ArrayList<String>();
|
||||
for(RestTaskModel task: tasksList)
|
||||
|
||||
Reference in New Issue
Block a user