mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
up v2
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package org.alfresco.rest;
|
||||
|
||||
import org.alfresco.rest.core.RestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
|
||||
@ContextConfiguration("classpath:alfresco-restapi-context.xml")
|
||||
public class MySampleDSL extends AbstractTestNGSpringContextTests {
|
||||
@Autowired
|
||||
RestWrapper restAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
protected RestProperties restProperties;
|
||||
|
||||
@BeforeClass
|
||||
public void asd() {
|
||||
RestAssured.baseURI = restProperties.envProperty().getTestServerUrl();
|
||||
RestAssured.port = restProperties.envProperty().getPort();
|
||||
RestAssured.basePath = restProperties.getRestBasePath();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void something() throws Exception {
|
||||
// GET /Sites/<hahaha>/containers
|
||||
|
||||
|
||||
restAPI.authenticateUser(dataUser.getAdminUser()).usingSite("workshop").getContainers().assertThat().entriesListIsNotEmpty();
|
||||
|
||||
|
||||
// restAPI.usingSite("hahaha").getContainers().assertThat().field("level1").field("level2").field("level3").is("b")
|
||||
// restAPI.usingSite("hahaha").getContainers().assertThat().field("level3").is("a");
|
||||
// restAPI.usingSite("hahaha").getContainers().assertThat().listIsNotEmpty()
|
||||
// .listContains(level)
|
||||
// .statusCode().is(HttpStatus.OK);
|
||||
//
|
||||
//
|
||||
//
|
||||
// //GET /sites/{siteId}/containers/{containerId}
|
||||
//
|
||||
// restAPI.usingSite("haha").getContainer("c1").assertThat().file("folderId").is("jjsjsj");
|
||||
// .statusCode().
|
||||
//
|
||||
//
|
||||
// SiteModel site;
|
||||
// String body = JsonBodyGenerator.siteMemberhipRequest("Please accept me", site, "New request");
|
||||
// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest();
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// restAPI.usingPeople(people).withBody(body).addSiteMembershipRequest().assertthat().statusCode().is().and().fiels
|
||||
// restApi.getBodyResponse.
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class SampleSitesTests extends RestTest
|
||||
public void adminShouldGetSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
siteAPI.getSite(siteModel);
|
||||
siteAPI.usingRestWrapper()
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SampleSitesTests extends RestTest
|
||||
public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
siteAPI.getSites();
|
||||
siteAPI.usingRestWrapper()
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SampleSitesTests extends RestTest
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
siteAPI.usingRestWrapper()
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.alfresco.rest.favorites;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestFavoritesApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
@@ -24,9 +23,6 @@ public class AddFavoritesSanityTests extends RestTest
|
||||
@Autowired
|
||||
RestFavoritesApi favoritesAPI;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -37,12 +33,12 @@ public class AddFavoritesSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
favoritesAPI.useRestClient(restClient);
|
||||
sitesApi.useRestClient(restClient);
|
||||
siteModel.setGuid(sitesApi.getSite(siteModel).getGuid());
|
||||
|
||||
siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.alfresco.rest.favorites;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestFavoritesApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.ErrorModel;
|
||||
@@ -24,9 +23,6 @@ public class DeleteFavoritesSanityTests extends RestTest
|
||||
@Autowired
|
||||
RestFavoritesApi favoritesAPI;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
@@ -35,12 +31,12 @@ public class DeleteFavoritesSanityTests extends RestTest
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
favoritesAPI.useRestClient(restClient);
|
||||
sitesApi.useRestClient(restClient);
|
||||
siteModel.setGuid(sitesApi.getSite(siteModel).getGuid());
|
||||
|
||||
siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestFavoritesApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.ErrorModel;
|
||||
@@ -27,8 +26,6 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
@Autowired
|
||||
RestFavoritesApi favoritesAPI;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
@@ -46,8 +43,8 @@ public class GetFavoriteSanityTests extends RestTest
|
||||
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
favoritesAPI.useRestClient(restClient);
|
||||
sitesApi.useRestClient(restClient);
|
||||
siteModel.setGuid(sitesApi.getSite(siteModel).getGuid());
|
||||
|
||||
siteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(siteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestFavoritesApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.ErrorModel;
|
||||
@@ -28,9 +27,6 @@ public class GetFavoritesSanityTests extends RestTest
|
||||
@Autowired
|
||||
RestFavoritesApi favoritesAPI;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel firstSiteModel;
|
||||
private SiteModel secondSiteModel;
|
||||
@@ -53,9 +49,9 @@ public class GetFavoritesSanityTests extends RestTest
|
||||
secondFileModel = dataContent.usingUser(adminUserModel).usingResource(firstFolderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
favoritesAPI.useRestClient(restClient);
|
||||
sitesApi.useRestClient(restClient);
|
||||
firstSiteModel.setGuid(sitesApi.getSite(firstSiteModel).getGuid());
|
||||
secondSiteModel.setGuid(sitesApi.getSite(secondSiteModel).getGuid());
|
||||
|
||||
firstSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(firstSiteModel).getSite().getGuid());
|
||||
secondSiteModel.setGuid(restClient.authenticateUser(adminUserModel).usingSite(secondSiteModel).getSite().getGuid());
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(firstSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
siteAPI.addPerson(siteModel, testUser)
|
||||
.assertThat().field("id").is(testUser.getUsername())
|
||||
.and().field("role").is(testUser.getUserRole());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -57,8 +57,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertLastError().containsSummary("Permission was denied");
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -69,8 +69,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertLastError().containsSummary("Permission was denied");
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -81,8 +81,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
siteAPI.usingRestWrapper().assertLastError().containsSummary("Permission was denied");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertLastError().containsSummary("Permission was denied");
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -95,7 +95,7 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
siteAPI.addPerson(siteModel, testUser)
|
||||
.and().field("id").is(testUser.getUsername())
|
||||
.and().field("role").is(testUser.getUserRole());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -107,6 +107,6 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
UserModel inexistentUser = new UserModel("inexistent user", "inexistent password");
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -62,7 +62,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
.and().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -74,7 +74,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -86,7 +86,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -98,7 +98,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,6 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
restClient.authenticateUser(userModel);
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel);
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -68,7 +68,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -80,7 +80,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -92,7 +92,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -104,7 +104,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -117,6 +117,6 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getSiteContainers(siteModel);
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -67,7 +67,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty().assertThat()
|
||||
.entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and()
|
||||
.entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -78,7 +78,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -89,7 +89,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -100,7 +100,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", adminUser.getUsername())
|
||||
.when().assertThat().entriesListContains("role", "SiteManager");
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -113,6 +113,6 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getSiteMembers(siteModel);
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -29,9 +28,6 @@ public class GetSiteSanityTests extends RestTest
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
@Autowired
|
||||
DataSite dataSite;
|
||||
|
||||
@@ -44,8 +40,7 @@ public class GetSiteSanityTests extends RestTest
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.useRestClient(restClient);
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -54,55 +49,61 @@ public class GetSiteSanityTests extends RestTest
|
||||
description = "Verify user with Manager role gets site information and gets status code OK (200)")
|
||||
public void getSiteWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteAPI.getSite(siteModel)
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.usingSite(siteModel)
|
||||
.getSite()
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Collaborator role gets site information and gets status code OK (200)")
|
||||
public void getSiteWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.getSite(siteModel)
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.usingSite(siteModel)
|
||||
.getSite()
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Contributor role gets site information and gets status code OK (200)")
|
||||
public void getSiteWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.getSite(siteModel)
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.usingSite(siteModel)
|
||||
.getSite()
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Consumer role gets site information and gets status code OK (200)")
|
||||
public void getSiteWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.getSite(siteModel)
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.usingSite(siteModel)
|
||||
.getSite()
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with admin role gets site information and gets status code OK (200)")
|
||||
public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.getSite(siteModel)
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.usingSite(siteModel)
|
||||
.getSite()
|
||||
.and().field("id").is(siteModel.getId())
|
||||
.and().field("title").is(siteModel.getTitle());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -113,8 +114,8 @@ public class GetSiteSanityTests extends RestTest
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.authenticateUser(userModel).withParams("maxItems=10000")
|
||||
.getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -24,9 +23,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class GetSitesSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -42,8 +38,7 @@ public class GetSitesSanityTests extends RestTest
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.useRestClient(restClient);
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -52,24 +47,24 @@ public class GetSitesSanityTests extends RestTest
|
||||
public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteAPI.getAllSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.getSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Collaborator role gets sites information and gets status code OK (200)")
|
||||
public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.getAllSites().assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.getSites().assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -77,12 +72,12 @@ public class GetSitesSanityTests extends RestTest
|
||||
public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.getAllSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.getSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -90,24 +85,24 @@ public class GetSitesSanityTests extends RestTest
|
||||
public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.getAllSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.getSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Admin user gets sites information and gets status code OK (200)")
|
||||
public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.getAllSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.getSites()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", siteModel.getId())
|
||||
.and().paginationExist();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -119,8 +114,8 @@ public class GetSitesSanityTests extends RestTest
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.authenticateUser(userModel)
|
||||
.getSites();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel)
|
||||
.assertThat().field("id").is(testUserModel.getUsername())
|
||||
.and().field("role").is(testUserModel.getUserRole());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@@ -58,9 +58,9 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
siteAPI.usingRestWrapper().assertLastError()
|
||||
restClient().assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@@ -71,9 +71,9 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
siteAPI.usingRestWrapper().assertLastError()
|
||||
restClient().assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@@ -84,9 +84,9 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
siteAPI.usingRestWrapper().assertLastError()
|
||||
restClient().assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -98,7 +98,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel)
|
||||
.assertThat().field("id").is(testUserModel.getUsername())
|
||||
.and().field("role").is(testUserModel.getUserRole());
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient().assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="MNT-16904")
|
||||
@@ -109,6 +109,6 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ reports.path=./target/reports
|
||||
|
||||
# in containers we cannot access directly JMX, so we will use http://jolokia.org agent
|
||||
# disabling this we will use direct JMX calls to server
|
||||
jmx.useJolokiaAgent=true
|
||||
jmx.useJolokiaAgent=false
|
||||
|
||||
#
|
||||
# Database Section
|
||||
|
||||
Reference in New Issue
Block a user