mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
up comments
This commit is contained in:
@@ -3,7 +3,6 @@ package org.alfresco.rest.comments;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
@@ -22,10 +21,7 @@ import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
|
||||
{
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -39,8 +35,7 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
commentsAPI.useRestClient(restClient);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
@@ -51,10 +46,10 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
String newContent = "This is a new comment added by " + adminUserModel.getUsername();
|
||||
commentsAPI.addComment(document, newContent)
|
||||
restClient.usingNode(document).addComment(newContent)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(newContent);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201")
|
||||
@@ -62,10 +57,10 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager;
|
||||
commentsAPI.addComment(document, contentSiteManger)
|
||||
restClient.usingNode(document).addComment(contentSiteManger)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteManger);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201")
|
||||
@@ -73,10 +68,10 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor;
|
||||
commentsAPI.addComment(document, contentSiteContributor)
|
||||
restClient.usingNode(document).addComment(contentSiteContributor)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteContributor);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201")
|
||||
@@ -84,10 +79,10 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator;
|
||||
commentsAPI.addComment(document, contentSiteCollaborator)
|
||||
restClient.usingNode(document).addComment(contentSiteCollaborator)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteCollaborator);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't add comments with Rest API and status code is 403")
|
||||
@@ -95,8 +90,8 @@ public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer;
|
||||
commentsAPI.addComment(document, contentSiteConsumer);
|
||||
commentsAPI.usingRestWrapper()
|
||||
restClient.usingNode(document).addComment(contentSiteConsumer);
|
||||
restClient
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
@@ -106,8 +101,8 @@ public class AddCommentSanityTests extends RestTest
|
||||
public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
commentsAPI.addComment(document, "This is a new comment");
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.usingNode(document).addComment("This is a new comment");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.alfresco.rest.comments;
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
@@ -27,8 +26,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public class AddCommentsSanityTests extends RestTest
|
||||
{
|
||||
@Autowired RestCommentsApi commentsAPI;
|
||||
|
||||
@Autowired DataUser dataUser;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
@@ -43,7 +40,7 @@ public class AddCommentsSanityTests extends RestTest
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
commentsAPI.useRestClient(restClient);
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -59,60 +56,59 @@ public class AddCommentsSanityTests extends RestTest
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201")
|
||||
public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentsAPI.addComments(document, comment1, comment2)
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.usingNode(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple comments with Rest API and status code is 201")
|
||||
public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentsAPI.addComments(document, comment1, comment2)
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.usingNode(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201")
|
||||
public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
commentsAPI.addComments(document, comment1, comment2)
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.usingNode(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201")
|
||||
public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentsAPI.addComments(document, comment1, comment2)
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.usingNode(document).addComments(comment1, comment2)
|
||||
.assertThat().paginationExist().and().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201")
|
||||
public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
commentsAPI.addComments(document, comment1, comment2);
|
||||
commentsAPI.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.usingNode(document).addComments(comment1, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -120,8 +116,8 @@ public class AddCommentsSanityTests extends RestTest
|
||||
@Bug(id="MNT-16904")
|
||||
public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
commentsAPI.addComments(document, comment1, comment2);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"))
|
||||
.usingNode(document).addComments(comment1, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
@@ -26,7 +26,7 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
{
|
||||
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
Node commentsAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
@@ -43,19 +43,16 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
commentsAPI.useRestClient(restClient);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addCommentToDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentsAPI.useRestClient(restClient);
|
||||
comment = commentsAPI.addComment(document, "This is a new comment");
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = restClient.usingNode(document).addComment("This is a new comment");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -63,8 +60,8 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -72,8 +69,8 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -81,8 +78,8 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
public void collaboratorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -91,10 +88,9 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
public void contributorIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -102,10 +98,9 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -114,9 +109,7 @@ public class DeleteCommentsSanityTests extends RestTest
|
||||
{
|
||||
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
|
||||
restClient.authenticateUser(nonexistentModel);
|
||||
commentsAPI.deleteComment(document, comment);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
|
||||
restClient.usingNode(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.alfresco.rest.comments;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
@@ -23,7 +23,7 @@ import org.testng.annotations.Test;
|
||||
public class GetCommentsSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
Node commentsAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
@@ -41,11 +41,10 @@ public class GetCommentsSanityTests extends RestTest
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
commentsAPI.useRestClient(restClient);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
content = "This is a new comment";
|
||||
commentsAPI.addComment(document, content);
|
||||
restClient.usingNode(document).addComment(content);
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -55,8 +54,8 @@ public class GetCommentsSanityTests extends RestTest
|
||||
public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentsAPI.getNodeComments(document);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.usingNode(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -64,10 +63,10 @@ public class GetCommentsSanityTests extends RestTest
|
||||
public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", content);
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -75,10 +74,10 @@ public class GetCommentsSanityTests extends RestTest
|
||||
public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", content);
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -86,9 +85,9 @@ public class GetCommentsSanityTests extends RestTest
|
||||
public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", content);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -96,9 +95,9 @@ public class GetCommentsSanityTests extends RestTest
|
||||
public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", content);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -108,8 +107,8 @@ public class GetCommentsSanityTests extends RestTest
|
||||
{
|
||||
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
|
||||
restClient.authenticateUser(nonexistentModel);
|
||||
commentsAPI.getNodeComments(document);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.usingNode(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -119,13 +118,13 @@ public class GetCommentsSanityTests extends RestTest
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(userModel);
|
||||
String contentManager = "This is a new comment added by " + userModel.getUsername();
|
||||
commentsAPI.addComment(document,contentManager);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.usingNode(document).addComment(contentManager);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", contentManager);
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY,
|
||||
@@ -135,12 +134,12 @@ public class GetCommentsSanityTests extends RestTest
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(userModel);
|
||||
String contentCollaborator = "This is a new comment added by " + userModel.getUsername();
|
||||
commentsAPI.addComment(document, contentCollaborator);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.usingNode(document).addComment(contentCollaborator);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentsAPI.getNodeComments(document)
|
||||
restClient.usingNode(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", contentCollaborator);
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
@@ -26,7 +26,7 @@ import org.testng.annotations.Test;
|
||||
public class UpdateCommentsSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
Node commentsAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
@@ -43,9 +43,9 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
commentsAPI.useRestClient(restClient);
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
commentModel = commentsAPI.addComment(document, "This is a new comment");
|
||||
commentModel = restClient.usingNode(document).addComment("This is a new comment");
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -56,10 +56,10 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
String updatedContent = "This is the updated comment with admin user";
|
||||
commentsAPI.updateComment(document, commentModel, updatedContent)
|
||||
restClient.usingNode(document).updateComment(commentModel, updatedContent)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(updatedContent);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -67,11 +67,11 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentsAPI.updateComment(document, commentModel, "This is the updated comment with Manager user")
|
||||
restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Manager user")
|
||||
.and().field("content").is("This is the updated comment with Manager user")
|
||||
.and().field("canEdit").is(true)
|
||||
.and().field("canDelete").is(true);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
@@ -80,8 +80,8 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
String updatedContent = "This is the updated comment with Contributor user";
|
||||
commentsAPI.updateComment(document, commentModel, updatedContent);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.usingNode(document).updateComment(commentModel, updatedContent);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
commentsAPI.updateComment(document, commentModel, "This is the updated comment with Consumer user");
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Consumer user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -101,9 +101,8 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
public void collaboratorIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user");
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -113,9 +112,9 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
UserModel incorrectUserModel = new UserModel("userName", "password");
|
||||
restClient.authenticateUser(incorrectUserModel);
|
||||
commentsAPI.getNodeComments(document);
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.authenticateUser(incorrectUserModel)
|
||||
.usingNode(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify update comment with inexistent nodeId returns status code 404")
|
||||
@@ -125,8 +124,8 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
|
||||
FolderModel content = FolderModel.getRandomFolderModel();
|
||||
content.setNodeRef("node ref that does not exist");
|
||||
commentsAPI.updateComment(content, commentModel, "This is the updated comment.");
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
restClient.usingNode(content).updateComment(commentModel, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary("node ref that does not exist was not found");
|
||||
}
|
||||
|
||||
@@ -138,9 +137,8 @@ public class UpdateCommentsSanityTests extends RestTest
|
||||
RestCommentModel comment = new RestCommentModel();
|
||||
String id = "comment id that does not exist";
|
||||
comment.setId(id);
|
||||
commentsAPI.updateComment(document, comment, "This is the updated comment.");
|
||||
|
||||
commentsAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
restClient.usingNode(document).updateComment(comment, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, id));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,12 @@ package org.alfresco.rest.demo;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.social.alfresco.api.entities.Role;
|
||||
import org.springframework.social.alfresco.api.entities.Site.Visibility;
|
||||
@@ -20,13 +17,7 @@ import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public class RestDemoTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
|
||||
{
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
|
||||
@@ -35,10 +26,7 @@ public class RestDemoTests extends RestTest
|
||||
{
|
||||
userModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
restClient.authenticateUser(userModel);
|
||||
|
||||
sitesApi.useRestClient(restClient);
|
||||
commentsAPI.useRestClient(restClient);
|
||||
restClient.authenticateUser(userModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,11 +65,10 @@ public class RestDemoTests extends RestTest
|
||||
.usingResource(FolderModel.getSharedFolderModel())
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
// add new comment
|
||||
commentsAPI.addComment(fileModel, "This is a new comment");
|
||||
commentsAPI.getNodeComments(fileModel)
|
||||
restClient.usingNode(fileModel).addComment("This is a new comment");
|
||||
restClient.usingNode(fileModel).getNodeComments()
|
||||
.assertThat().entriesListIsNotEmpty().and()
|
||||
.entriesListContains("content", "This is a new comment");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,21 +87,20 @@ public class RestDemoTests extends RestTest
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
|
||||
// add user as Consumer to site
|
||||
sitesApi.addPerson(siteModel, testUser);
|
||||
sitesApi.getSiteMembers(siteModel).assertThat().entriesListContains("id", testUser.getUsername())
|
||||
restClient.usingSite(siteModel).addPerson(testUser);
|
||||
restClient.usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername())
|
||||
.when().getSiteMember(testUser.getUsername())
|
||||
.assertSiteMemberHasRole(Role.SiteConsumer);
|
||||
|
||||
// update site member to Manager
|
||||
testUser.setUserRole(UserRole.SiteCollaborator);
|
||||
sitesApi.updateSiteMember(siteModel, testUser);
|
||||
sitesApi.getSiteMembers(siteModel).and()
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUser);
|
||||
restClient.usingSite(siteModel).getSiteMembers().and()
|
||||
.entriesListContains("id", testUser.getUsername())
|
||||
.when().getSiteMember(testUser.getUsername())
|
||||
.assertSiteMemberHasRole(Role.SiteCollaborator);
|
||||
|
||||
sitesApi.deleteSiteMember(siteModel, testUser);
|
||||
sitesApi.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.usingSite(siteModel).deleteSiteMember(testUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -4,24 +4,19 @@ import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public class SampleCommentsTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestCommentsApi commentsAPI;
|
||||
|
||||
{
|
||||
private UserModel userModel;
|
||||
private FolderModel folderModel;
|
||||
private SiteModel siteModel;
|
||||
@@ -33,9 +28,7 @@ public class SampleCommentsTests extends RestTest
|
||||
userModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
|
||||
restClient.authenticateUser(userModel);
|
||||
commentsAPI.useRestClient(restClient);
|
||||
|
||||
restClient.authenticateUser(userModel);
|
||||
document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@@ -43,27 +36,25 @@ public class SampleCommentsTests extends RestTest
|
||||
description= "Verify admin user adds comments with Rest API and status code is 200")
|
||||
public void admiShouldAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
commentsAPI.addComment(document, "This is a new comment");
|
||||
commentsAPI.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.usingNode(document).addComment("This is a new comment");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify admin user gets comments with Rest API and status code is 200")
|
||||
public void admiShouldRetrieveComments() throws Exception
|
||||
{
|
||||
commentsAPI.getNodeComments(document);
|
||||
commentsAPI.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.usingNode(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section={"demo", "sample-section"}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify admin user updates comments with Rest API")
|
||||
public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestCommentModel commentModel = commentsAPI.addComment(document, "This is a new comment");
|
||||
RestCommentModel commentModel = restClient.usingNode(document).addComment("This is a new comment");
|
||||
|
||||
commentsAPI.updateComment(document, commentModel, "This is the updated comment with Collaborator user")
|
||||
restClient.usingNode(document).updateComment(commentModel, "This is the updated comment with Collaborator user")
|
||||
.assertThat().field("content").is("This is the updated comment with Collaborator user");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SampleSitesTests extends RestTest
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
restClient.usingSite(siteModel).addPerson(testUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class RestApiDemoTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi sitesAPI;
|
||||
|
||||
{
|
||||
/*
|
||||
* Test steps:
|
||||
* 1. create a user
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -11,10 +9,7 @@ import org.testng.annotations.Test;
|
||||
*
|
||||
*/
|
||||
public class RestApiWorkshopTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi sitesAPI;
|
||||
|
||||
{
|
||||
@Test
|
||||
public void verifyGetSitesRestApiCall() throws Exception
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.alfresco.rest.people;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestPeopleApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
@@ -27,9 +26,6 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
@Autowired
|
||||
RestPeopleApi peopleApi;
|
||||
|
||||
@Autowired
|
||||
RestSitesApi sitesApi;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -49,8 +45,7 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
peopleApi.useRestClient(restClient);
|
||||
sitesApi.useRestClient(restClient);
|
||||
peopleApi.useRestClient(restClient);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
|
||||
@@ -60,12 +55,11 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser("testUser");
|
||||
newUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
sitesApi.addPerson(siteModel, newUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.usingSite(siteModel).addPerson(newUser);
|
||||
|
||||
peopleApi.deleteSiteMember(newUser, siteModel);
|
||||
sitesApi.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
|
||||
@@ -75,12 +69,11 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser("testUser");
|
||||
newUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(adminUser);
|
||||
sitesApi.addPerson(siteModel, newUser);
|
||||
restClient.authenticateUser(adminUser)
|
||||
.usingSite(siteModel).addPerson(newUser);
|
||||
|
||||
peopleApi.deleteSiteMember(newUser, siteModel);
|
||||
sitesApi.usingRestWrapper()
|
||||
.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
|
||||
@@ -91,12 +84,12 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser("testUser");
|
||||
newUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(adminUser);
|
||||
sitesApi.addPerson(siteModel, newUser);
|
||||
restClient.authenticateUser(adminUser)
|
||||
.usingSite(siteModel).addPerson(newUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
peopleApi.deleteSiteMember(newUser, siteModel);
|
||||
sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -108,12 +101,12 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser("testUser");
|
||||
newUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(adminUser);
|
||||
sitesApi.addPerson(siteModel, newUser);
|
||||
restClient.authenticateUser(adminUser)
|
||||
.usingSite(siteModel).addPerson(newUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
peopleApi.deleteSiteMember(newUser, siteModel);
|
||||
sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -125,12 +118,12 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser("testUser");
|
||||
newUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.authenticateUser(adminUser);
|
||||
sitesApi.addPerson(siteModel, newUser);
|
||||
restClient.authenticateUser(adminUser)
|
||||
.usingSite(siteModel).addPerson(newUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
peopleApi.deleteSiteMember(newUser, siteModel);
|
||||
sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@@ -142,6 +135,6 @@ public class DeleteSiteMemberSanityTests extends RestTest
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
|
||||
peopleApi.deleteSiteMember(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer), siteModel);
|
||||
sitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -10,7 +9,6 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -18,9 +16,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class AddSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
@@ -28,8 +23,7 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteAPI.useRestClient(restClient);
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
@@ -43,7 +37,7 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteAPI.addPerson(siteModel, testUser)
|
||||
restClient.usingSite(siteModel).addPerson(testUser)
|
||||
.assertThat().field("id").is(testUser.getUsername())
|
||||
.and().field("role").is(testUser.getUserRole());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
@@ -55,8 +49,9 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.usingSite(siteModel).addPerson(testUser);
|
||||
|
||||
restClient.assertLastError().containsSummary("Permission was denied");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
@@ -67,8 +62,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.usingSite(siteModel).addPerson(testUser);
|
||||
restClient.assertLastError().containsSummary("Permission was denied");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
@@ -79,8 +74,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.usingSite(siteModel).addPerson(testUser);
|
||||
restClient.assertLastError().containsSummary("Permission was denied");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
@@ -91,10 +86,10 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.addPerson(siteModel, testUser)
|
||||
.and().field("id").is(testUser.getUsername())
|
||||
.and().field("role").is(testUser.getUserRole());
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.usingSite(siteModel).addPerson(testUser)
|
||||
.and().field("id").is(testUser.getUsername())
|
||||
.and().field("role").is(testUser.getUserRole());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -105,8 +100,8 @@ public class AddSiteMemberSanityTests extends RestTest
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
UserModel inexistentUser = new UserModel("inexistent user", "inexistent password");
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
siteAPI.addPerson(siteModel, testUser);
|
||||
restClient.authenticateUser(inexistentUser)
|
||||
.usingSite(siteModel).addPerson(testUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.alfresco.rest.sites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestSiteContainerModel;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -11,7 +10,6 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -21,10 +19,7 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class GetSiteContainerSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
@@ -34,8 +29,7 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteAPI.useRestClient(restClient);
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
@@ -46,8 +40,8 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void getSiteContainerWithManagerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
restClient.usingSite(siteModel).getSiteContainer(siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -58,8 +52,8 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void getSiteContainerWithCollaboratorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
restClient.usingSite(siteModel).getSiteContainer(siteContainerModel)
|
||||
.and().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -70,8 +64,8 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void getSiteContainerWithContributorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
restClient.usingSite(siteModel).getSiteContainer(siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -82,8 +76,8 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void getSiteContainerWithConsumerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
restClient.usingSite(siteModel).getSiteContainer(siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -94,8 +88,8 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void getSiteContainerWithAdminUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel)
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
restClient.usingSite(siteModel).getSiteContainer(siteContainerModel)
|
||||
.assertThat().field("id").is(siteContainerModel.onModel().getId())
|
||||
.and().field("folderId").is(siteContainerModel.onModel().getFolderId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -108,12 +102,12 @@ public class GetSiteContainerSanityTests extends RestTest
|
||||
public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteContainer() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteContainerModel = siteAPI.getSiteContainers(siteModel).getOneRandomEntry();
|
||||
siteContainerModel = restClient.usingSite(siteModel).getSiteContainers().getOneRandomEntry();
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getSiteContainer(siteModel, siteContainerModel);
|
||||
restClient.authenticateUser(userModel)
|
||||
.usingSite(siteModel).getSiteContainer(siteContainerModel);
|
||||
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;
|
||||
@@ -23,10 +22,7 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class GetSiteContainersSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
{
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -41,8 +37,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteAPI.useRestClient(restClient);
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -52,7 +47,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
public void getSiteContainersWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteAPI.getSiteContainers(siteModel)
|
||||
restClient.usingSite(siteModel).getSiteContainers()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
@@ -64,7 +59,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
public void getSiteContainersWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.getSiteContainers(siteModel)
|
||||
restClient.usingSite(siteModel).getSiteContainers()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
@@ -76,7 +71,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
public void getSiteContainersWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.getSiteContainers(siteModel)
|
||||
restClient.usingSite(siteModel).getSiteContainers()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
@@ -88,7 +83,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
public void getSiteContainersWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.getSiteContainers(siteModel)
|
||||
restClient.usingSite(siteModel).getSiteContainers()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
@@ -100,7 +95,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
public void getSiteContainersWithAdminUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.getSiteContainers(siteModel)
|
||||
restClient.usingSite(siteModel).getSiteContainers()
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().paginationExist()
|
||||
.and().paginationField("count").isNot("0");
|
||||
@@ -116,7 +111,7 @@ public class GetSiteContainersSanityTests extends RestTest
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getSiteContainers(siteModel);
|
||||
restClient.usingSite(siteModel).getSiteContainers();
|
||||
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.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
@@ -12,7 +11,6 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -23,10 +21,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class GetSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
|
||||
@Autowired
|
||||
RestSitesApi restSitesApi;
|
||||
|
||||
private UserModel adminUser;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
@@ -35,8 +29,7 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
restSitesApi.useRestClient(restClient);
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
@@ -49,10 +42,10 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
public void getSiteMemberWithManagerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restSitesApi.getSiteMember(siteModel, userModel)
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel)
|
||||
.assertThat().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -60,10 +53,10 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
public void getSiteMemberWithCollaboratorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restSitesApi.getSiteMember(siteModel, userModel)
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel)
|
||||
.and().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -71,9 +64,10 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
public void getSiteMemberWithContributorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restSitesApi.getSiteMember(siteModel, userModel).and().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel)
|
||||
.and().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -81,10 +75,10 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
public void getSiteMemberWithConsumerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restSitesApi.getSiteMember(siteModel, userModel)
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel)
|
||||
.and().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -92,10 +86,10 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
public void getSiteMemberWithAdminUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
restSitesApi.getSiteMember(siteModel, userModel)
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel)
|
||||
.and().field("id").is(userModel.getUsername())
|
||||
.and().field("role").is(userModel.getUserRole());
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
@@ -105,7 +99,7 @@ public class GetSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
UserModel inexistentUser = new UserModel("inexistent user", "inexistent password");
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
restSitesApi.getSiteMember(siteModel, userModel);
|
||||
restSitesApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.usingSite(siteModel).getSiteMember(userModel);
|
||||
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;
|
||||
@@ -25,9 +24,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class GetSiteMembersSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -42,8 +38,7 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteAPI.useRestClient(restClient);
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
@@ -52,10 +47,10 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
description = "Verify user with Manager role gets site members and gets status code OK (200)")
|
||||
public void getSiteMembersWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString());
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -63,10 +58,10 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
description = "Verify user with Collaborator role gets site members and gets status code OK (200)")
|
||||
public void getSiteMembersWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty().assertThat()
|
||||
.entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and()
|
||||
.entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString());
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat()
|
||||
.entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and()
|
||||
.entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -74,8 +69,8 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
description = "Verify user with Contributor role gets site members and gets status code OK (200)")
|
||||
public void getSiteMembersWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -85,8 +80,8 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
description = "Verify user with Consumer role gets site members and gets status code OK (200)")
|
||||
public void getSiteMembersWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername())
|
||||
.and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -96,10 +91,10 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
description = "Verify user with admin usere gets site members and gets status code OK (200)")
|
||||
public void getSiteMembersWithAdminUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUser);
|
||||
siteAPI.getSiteMembers(siteModel).assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", adminUser.getUsername())
|
||||
.when().assertThat().entriesListContains("role", "SiteManager");
|
||||
restClient.authenticateUser(adminUser)
|
||||
.usingSite(siteModel).getSiteMembers().assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("id", adminUser.getUsername())
|
||||
.when().assertThat().entriesListContains("role", "SiteManager");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -111,8 +106,8 @@ public class GetSiteMembersSanityTests extends RestTest
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getSiteMembers(siteModel);
|
||||
restClient.authenticateUser(userModel)
|
||||
.usingSite(siteModel).getSiteMembers();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
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;
|
||||
@@ -23,11 +22,7 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY})
|
||||
public class RemoveSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
|
||||
@Autowired
|
||||
RestSitesApi restSitesAPI;
|
||||
|
||||
{
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@@ -41,8 +36,7 @@ public class RemoveSiteMemberSanityTests extends RestTest
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
restSitesAPI.useRestClient(restClient);
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
@@ -55,10 +49,10 @@ public class RemoveSiteMemberSanityTests extends RestTest
|
||||
description = "Verify that site manager can delete site member and gets status code 204, 'No Content'")
|
||||
public void siteManagerIsAbleToDeleteSiteMember() throws Exception{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername());
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@@ -66,50 +60,55 @@ public class RemoveSiteMemberSanityTests extends RestTest
|
||||
description = "Verify that site collaborator cannot delete site member and gets status code 403, 'Forbidden'")
|
||||
public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws Exception{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername());
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that site contributor cannot delete site member and gets status code 403, 'Forbidden'")
|
||||
public void siteContributorIsNotAbleToDeleteSiteMember() throws Exception{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername());
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5444")
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that site consumer cannot delete site member and gets status code 403, 'Forbidden'")
|
||||
public void siteConsumerIsNotAbleToDeleteSiteMember() throws Exception{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
restClient.getSites().assertThat().entriesListContains("id", testUserModel.getUsername());
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that admin user can delete site member and gets status code 204, 'No Content'")
|
||||
public void adminUserIsAbleToDeleteSiteMember() throws Exception{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.getSites().assertThat().entriesListDoesNotContain("id", testUserModel.getUsername());
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that unauthenticated user is not able to delete site member")
|
||||
public void unauthenticatedUserIsNotAuthorizedToDeleteSiteMember() throws Exception{
|
||||
UserModel inexistentUser = new UserModel("inexistent user", "inexistent password");
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
restSitesAPI.deleteSiteMember(siteModel, testUserModel);
|
||||
restSitesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
restClient.authenticateUser(inexistentUser)
|
||||
.usingSite(siteModel).deleteSiteMember(testUserModel);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -10,7 +9,6 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -18,9 +16,6 @@ import org.testng.annotations.Test;
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
|
||||
public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
@@ -29,8 +24,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteAPI.useRestClient(restClient);
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
@@ -44,7 +38,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
testUserModel.setUserRole(UserRole.SiteConsumer);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel)
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel)
|
||||
.assertThat().field("id").is(testUserModel.getUsername())
|
||||
.and().field("role").is(testUserModel.getUserRole());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -57,7 +51,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel);
|
||||
restClient.assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
@@ -70,7 +64,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel);
|
||||
restClient.assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
@@ -83,7 +77,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel);
|
||||
restClient.assertLastError()
|
||||
.containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", siteModel.getTitle()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
@@ -95,7 +89,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel)
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel)
|
||||
.assertThat().field("id").is(testUserModel.getUsername())
|
||||
.and().field("role").is(testUserModel.getUserRole());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -108,7 +102,7 @@ public class UpdateSiteMemberSanityTests extends RestTest
|
||||
UserModel inexistentUser = new UserModel("inexistent user", "inexistent password");
|
||||
restClient.authenticateUser(inexistentUser);
|
||||
testUserModel.setUserRole(UserRole.SiteCollaborator);
|
||||
siteAPI.updateSiteMember(siteModel, testUserModel);
|
||||
restClient.usingSite(siteModel).updateSiteMember(testUserModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user