Files
SearchServices/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersSanityTests.java
T

116 lines
6.1 KiB
Java

package org.alfresco.rest.sites;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
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 iulia.cojocea
*/
public class GetSiteContainersSanityTests extends RestTest
{
private UserModel adminUserModel;
private SiteModel siteModel;
private ListUserWithRoles usersWithRoles;
private UserModel userModel;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUserModel = dataUser.getAdminUser();
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify user with Manager role gets site containers and gets status code OK (200)")
public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
restClient.withCoreAPI().usingSite(siteModel).getSiteContainers()
.assertThat().entriesListIsNotEmpty()
.assertThat().paginationExist()
.and().paginationField("count").isNot("0");
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify user with Collaborator role gets site containers and gets status code OK (200)")
public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
restClient.withCoreAPI().usingSite(siteModel).getSiteContainers()
.assertThat().entriesListIsNotEmpty()
.assertThat().paginationExist()
.and().paginationField("count").isNot("0");
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify user with Contributor role gets site containers and gets status code OK (200)")
public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
restClient.withCoreAPI().usingSite(siteModel).getSiteContainers()
.assertThat().entriesListIsNotEmpty()
.assertThat().paginationExist()
.and().paginationField("count").isNot("0");
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify user with Consumer role gets site containers and gets status code OK (200)")
public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
restClient.withCoreAPI().usingSite(siteModel).getSiteContainers()
.assertThat().entriesListIsNotEmpty()
.assertThat().paginationExist()
.and().paginationField("count").isNot("0");
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Verify user with Admin user gets site containers information and gets status code OK (200)")
public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
restClient.withCoreAPI().usingSite(siteModel).getSiteContainers()
.assertThat().entriesListIsNotEmpty()
.assertThat().paginationExist()
.and().paginationField("count").isNot("0");
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
description = "Failed authentication get site containers call returns status code 401 with Manager role")
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainers() throws JsonToModelConversionException, Exception
{
userModel = dataUser.createRandomTestUser();
userModel.setPassword("user wrong password");
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
restClient.authenticateUser(userModel)
.withCoreAPI().usingSite(siteModel).getSiteContainers();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
}
}