mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
REPO-2755: REST API & CMIS TAS sanity builds:
- refactored RestAPI "Comments" API tests to be included in a single class per endpoint (not separate Sanity/Core/Full tests)
This commit is contained in:
@@ -1,114 +0,0 @@
|
||||
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.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class AddCommentSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
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);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
String newContent = "This is a new comment added by " + adminUserModel.getUsername();
|
||||
restClient.withCoreAPI().usingResource(document).addComment(newContent)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(newContent);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager;
|
||||
RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
createdComment.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteManger);
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
@Bug(id="ACE-4614")
|
||||
public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor;
|
||||
RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
createdComment.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteContributor);
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator;
|
||||
restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteCollaborator);
|
||||
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")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer;
|
||||
restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer);
|
||||
restClient
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
+113
-37
@@ -1,6 +1,7 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
@@ -8,8 +9,8 @@ import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
@@ -22,15 +23,14 @@ import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class AddCommentCoreTests extends RestTest
|
||||
{
|
||||
public class AddCommentTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String comment;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@@ -38,17 +38,102 @@ public class AddCommentCoreTests extends RestTest
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
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 setUp()
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
String newContent = "This is a new comment added by " + adminUserModel.getUsername();
|
||||
restClient.withCoreAPI().usingResource(document).addComment(newContent)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(newContent);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.onResponse().assertThat().body("entry.edited", org.hamcrest.Matchers.is(false));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that comment can be retrieved after it is added")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
String contentSiteManger = "This is a new comment added by user with role: " + UserRole.SiteManager;
|
||||
RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteManger);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
createdComment.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteManger);
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Bug(id="ACE-4614")
|
||||
public void contributorIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
String contentSiteContributor = "This is a new comment added by user with role" + UserRole.SiteContributor;
|
||||
RestCommentModel createdComment = restClient.withCoreAPI().usingResource(document).addComment(contentSiteContributor);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
createdComment.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteContributor);
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
String contentSiteCollaborator = "This is a new comment added by user with role: " + UserRole.SiteCollaborator;
|
||||
restClient.withCoreAPI().usingResource(document).addComment(contentSiteCollaborator)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(contentSiteCollaborator);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't add comments with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
String contentSiteConsumer = "This is a new comment added by user with role: " + UserRole.SiteConsumer;
|
||||
restClient.withCoreAPI().usingResource(document).addComment(contentSiteConsumer);
|
||||
restClient
|
||||
.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
@@ -56,6 +141,7 @@ public class AddCommentCoreTests extends RestTest
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentUsingInvalidNodeId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
file.setNodeRef(RandomStringUtils.randomAlphanumeric(20));
|
||||
|
||||
@@ -67,9 +153,10 @@ public class AddCommentCoreTests extends RestTest
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that request using nodeId that is neither document or folder returns 405")
|
||||
@Bug(id = "MNT-16904")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentUsingResourceThatIsNotFileOrFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
@@ -82,7 +169,7 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding comment using empty content returns 400 status code")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentUsingEmptyContent() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
@@ -92,9 +179,10 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify adding comment with the same content as one existing comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentTwice() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
@@ -105,28 +193,13 @@ public class AddCommentCoreTests extends RestTest
|
||||
restClient.withCoreAPI().usingResource(document).getNodeComments()
|
||||
.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comment can be retrieved after it is added")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentThenRetrieveComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
RestCommentModelsCollection comments = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify comment cannot be added if user is not member of private site")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithNonMemberOfPrivateSite() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
UserModel member = dataUser.createRandomTestUser();
|
||||
SiteModel privateSite = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
FileModel file = dataContent.usingSite(privateSite).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
@@ -138,10 +211,11 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify comment cannot be added if empty network ID is provided")
|
||||
@Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
// @Bug(id = "MNT-16904", description = "It fails only on environment with tenants")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentUsingEmptyNetworkId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
UserModel member = dataUser.createRandomTestUser();
|
||||
member.setDomain("");
|
||||
|
||||
@@ -153,9 +227,10 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comment cannot be added to another comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentToAComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
@@ -169,9 +244,10 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comment cannot be added to a tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentToATag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comment = RandomData.getRandomName("comment1");
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag("randomTag");
|
||||
|
||||
@@ -182,4 +258,4 @@ public class AddCommentCoreTests extends RestTest
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class AddCommentsCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, networkUserModel;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestCommentModelsCollection comments;
|
||||
private String comment = "This is a new comment";
|
||||
private String comment2 = "This is the second comment";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't add comments to a node with ID that does not exist and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanNotAddCommentsOnNonexistentFile() throws Exception
|
||||
{
|
||||
FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
|
||||
nonexistentFile.setNodeRef("ABC");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void userCanNotAddCommentsOnLink() throws Exception
|
||||
{
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
fileWithNodeRefFromLink.setNodeRef(link.getNodeRef());
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(fileWithNodeRefFromLink).addComments(comment,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can add comments with the same content as one existing comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String sameComment = comment;
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment, sameComment)
|
||||
.assertThat().paginationExist().and().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment)
|
||||
.and().entriesListContains("content", sameComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListIsNotEmpty();
|
||||
List<RestCommentModel> commentsList = comments.getEntries();
|
||||
commentsList.get(0).onModel().assertThat().field("content").is(comment);
|
||||
commentsList.get(1).onModel().assertThat().field("content").is(sameComment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can not add comments to a not joined private site. Status code returned is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception
|
||||
{
|
||||
SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite();
|
||||
FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify add comments from node with invalid network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentsWithInvalidNetworkId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify add comments from node with empty network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentsWithEmptyNetworkId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
networkUserModel.setDomain("");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comments cannot be added to another comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentsToAComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
file.setNodeRef(commentEntry.getId());
|
||||
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComments(comment, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comments cannot be added to a tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void addCommentsToATag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag");
|
||||
|
||||
file.setNodeRef(tag.getId());
|
||||
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComments(comment, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Andrei Rusu
|
||||
*/
|
||||
public class AddCommentsFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String comment = "This is a new comment";
|
||||
private String comment2 = "This is the second comment";
|
||||
private RestCommentModelsCollection comments;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can provide a large string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String longString = RandomStringUtils.randomAlphanumeric(10000);
|
||||
String longString1 = RandomStringUtils.randomAlphanumeric(90000);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(longString, longString1);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", longString);
|
||||
comments.assertThat().entriesListContains("content", longString1);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can provide a short string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String shortString = RandomStringUtils.randomAlphanumeric(2);
|
||||
String shortString1 = RandomStringUtils.randomAlphanumeric(1);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(shortString, shortString1);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", shortString);
|
||||
comments.assertThat().entriesListContains("content", shortString1);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Collaborator user verify that you can provide a string with special characters for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
String shortString = RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(specialCharsString, shortString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", specialCharsString);
|
||||
comments.assertThat().entriesListContains("content", shortString);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can not provide an empty string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String emptyString = "";
|
||||
String spaceString = " ";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(emptyString, spaceString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Collaborator user verify that you can provide several comments in one request")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String charString = RandomStringUtils.randomAlphanumeric(10);
|
||||
String charString1 = RandomStringUtils.randomAlphanumeric(10);
|
||||
String charString2 = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(comment, comment2, charString, charString1, charString2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
comments.assertThat().paginationField("totalItems").is("5");
|
||||
comments.assertThat().paginationField("count").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Provide invalid request body parameter and check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI();
|
||||
String postBody = JsonBodyGenerator.keyValueJson("content2", comment);
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef());
|
||||
restClient.processModel(RestCommentModel.class, request);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
|
||||
restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
|
||||
restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
|
||||
restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
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.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/10/2016.
|
||||
*/
|
||||
public class AddCommentsSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String comment1, comment2;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomComments()
|
||||
{
|
||||
comment1 = RandomData.getRandomName("comment1");
|
||||
comment2 = RandomData.getRandomName("comment2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
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")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
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")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
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")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().paginationExist().and().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
|
||||
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")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.noAuthentication()
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/10/2016.
|
||||
*/
|
||||
public class AddCommentsTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, networkUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestCommentModelsCollection comments;
|
||||
private String comment1, comment2;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomComments()
|
||||
{
|
||||
comment1 = RandomData.getRandomName("comment1");
|
||||
comment2 = RandomData.getRandomName("comment2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post multiple comments call")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void unauthenticatedUserIsNotAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.noAuthentication()
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void contributorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2)
|
||||
.assertThat().paginationExist().and().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user adds multiple comments with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsAbleToAddComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can not add comments to a not joined private site. Status code returned is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanNotAddCommentsToANotJoinedPrivateSite() throws Exception
|
||||
{
|
||||
SiteModel sitePrivateNotJoined = dataSite.createPrivateRandomSite();
|
||||
FileModel file = dataContent.usingSite(sitePrivateNotJoined).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment1, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't add comments to a node with ID that does not exist and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanNotAddCommentsOnNonexistentFile() throws Exception
|
||||
{
|
||||
FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
|
||||
nonexistentFile.setNodeRef("ABC");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(nonexistentFile).addComments(comment1,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't add comments to a node that exists but is not a document or a folder and status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@Bug(id = "MNT-16904")
|
||||
public void userCanNotAddCommentsOnLink() throws Exception
|
||||
{
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
fileWithNodeRefFromLink.setNodeRef(link.getNodeRef());
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(fileWithNodeRefFromLink).addComments(comment1,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.UNABLE_TO_LOCATE);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can add comments with the same content as one existing comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanAddCommentWithTheSameContentAsExistingOne() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String sameComment = comment1;
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment1, sameComment)
|
||||
.assertThat().paginationExist().and().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("content", comment1)
|
||||
.and().entriesListContains("content", sameComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListIsNotEmpty();
|
||||
List<RestCommentModel> commentsList = comments.getEntries();
|
||||
commentsList.get(0).onModel().assertThat().field("content").is(comment1);
|
||||
commentsList.get(1).onModel().assertThat().field("content").is(sameComment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify add comments from node with invalid network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsWithInvalidNetworkId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify add comments from node with empty network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsWithEmptyNetworkId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
networkUserModel.setDomain("");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).addComments(comment1,comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comments cannot be added to another comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsToAComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComment(comment1);
|
||||
file.setNodeRef(commentEntry.getId());
|
||||
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComments(comment1, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that comments cannot be added to a tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsToATag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(file).addTag("randomTag");
|
||||
|
||||
file.setNodeRef(tag.getId());
|
||||
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComments(comment1, comment2);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can provide a large string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addLongCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String longString = RandomStringUtils.randomAlphanumeric(10000);
|
||||
String longString1 = RandomStringUtils.randomAlphanumeric(90000);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(longString, longString1);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", longString);
|
||||
comments.assertThat().entriesListContains("content", longString1);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can provide a short string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addShortCommentsWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String shortString = RandomStringUtils.randomAlphanumeric(2);
|
||||
String shortString1 = RandomStringUtils.randomAlphanumeric(1);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(shortString, shortString1);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", shortString);
|
||||
comments.assertThat().entriesListContains("content", shortString1);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Collaborator user verify that you can provide a string with special characters for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentsWithSpecialCharsWithCollaboratorCheckCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
String shortString = RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(specialCharsString, shortString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", specialCharsString);
|
||||
comments.assertThat().entriesListContains("content", shortString);
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
comments.assertThat().paginationField("count").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Manager user verify that you can not provide an empty string for one comment")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addEmptyStringCommentsWithManagerCheckCommentIsReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String emptyString = "";
|
||||
String spaceString = " ";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addComments(emptyString, spaceString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NON_NULL_COMMENT);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Using Collaborator user verify that you can provide several comments in one request")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addSeveralCommentsWithCollaboratorCheckCommentsAreReturned() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String charString = RandomStringUtils.randomAlphanumeric(10);
|
||||
String charString1 = RandomStringUtils.randomAlphanumeric(10);
|
||||
String charString2 = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComments(comment1, comment2, charString, charString1, charString2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment1);
|
||||
comments.assertThat().paginationField("totalItems").is("5");
|
||||
comments.assertThat().paginationField("count").is("5");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Provide invalid request body parameter and check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void invalidRequestBodyParameterCheckErrorModelSchema() throws Exception
|
||||
{
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI();
|
||||
String postBody = JsonBodyGenerator.keyValueJson("content2", comment1);
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", document.getNodeRef());
|
||||
restClient.processModel(RestCommentModel.class, request);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
|
||||
restClient.assertLastError().containsErrorKey(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
|
||||
restClient.assertLastError().containsSummary(String.format(RestErrorModel.UNRECOGNIZED_FIELD, "content2"));
|
||||
restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
|
||||
restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
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.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DeleteCommentCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestCommentModel comment;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comments created by admin and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = new RestCommentModel();
|
||||
comment.setId("inexistent");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
FileModel inexistentDocument = new FileModel();
|
||||
inexistentDocument.setNodeRef("inexistent");
|
||||
restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
+136
-26
@@ -19,26 +19,137 @@ import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DeleteCommentFullTests extends RestTest
|
||||
public class DeleteCommentTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, networkUserModel;
|
||||
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestCommentModel commentModel;
|
||||
private RestCommentModelsCollection comments;
|
||||
private RestCommentModel commentModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String comment = "This is a new comment";
|
||||
|
||||
private String commentText = "This is a new comment";
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteConsumer,
|
||||
UserRole.SiteCollaborator, UserRole.SiteContributor);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes comments with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin");
|
||||
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
|
||||
restClient.authenticateUser(nonexistentModel);
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can't delete comments created by admin user and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistent ID and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteInexistentComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = new RestCommentModel();
|
||||
commentModel.setId("inexistent");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete comments with inexistend NodeId and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteCommentWithInexistentNodeId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
FileModel inexistentDocument = new FileModel();
|
||||
inexistentDocument.setNodeRef("inexistent");
|
||||
restClient.withCoreAPI().usingResource(inexistentDocument).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can't delete deleted comments and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userIsNotAbleToDeleteDeletedComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user deletes comment created by admin"
|
||||
+ " and status code is 204. Check with getComments for validation")
|
||||
@@ -48,7 +159,7 @@ public class DeleteCommentFullTests extends RestTest
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
.withCoreAPI().usingResource(file).addComment(commentText);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
@@ -56,10 +167,10 @@ public class DeleteCommentFullTests extends RestTest
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListDoesNotContain("content", comment);
|
||||
comments.assertThat().entriesListDoesNotContain("content", commentText);
|
||||
comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0");
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete comment created by self"
|
||||
+ " and status code is 204. Check with getComments for validation")
|
||||
@@ -69,17 +180,17 @@ public class DeleteCommentFullTests extends RestTest
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
.withCoreAPI().usingResource(file).addComment(commentText);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListDoesNotContain("content", comment);
|
||||
comments.assertThat().entriesListDoesNotContain("content", commentText);
|
||||
comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0");
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Contributor user deletes comment created by self"
|
||||
+ " and status code is 204. Check with getComments for validation")
|
||||
@@ -90,17 +201,17 @@ public class DeleteCommentFullTests extends RestTest
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
.withCoreAPI().usingResource(file).addComment(commentText);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListDoesNotContain("content", comment);
|
||||
comments.assertThat().entriesListDoesNotContain("content", commentText);
|
||||
comments.getPagination().assertThat().field("totalItems").is("0").and().field("count").is("0");
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Consumer user cannot delete comment created by admin"
|
||||
+ " and status code is 403. Check with getComments for validation and check default error model schema.")
|
||||
@@ -109,7 +220,7 @@ public class DeleteCommentFullTests extends RestTest
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
@@ -121,7 +232,7 @@ public class DeleteCommentFullTests extends RestTest
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
comments.assertThat().entriesListContains("content", commentText);
|
||||
comments.getPagination().assertThat().field("totalItems").is("1").and().field("count").is("1");
|
||||
}
|
||||
|
||||
@@ -133,12 +244,12 @@ public class DeleteCommentFullTests extends RestTest
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
dataContent.usingAdmin().usingResource(file).updateContent("updated content to increase version number");
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user cannot delete comment with invalid node "
|
||||
+ "and status code is 404. Check with getComments for validation")
|
||||
@@ -147,7 +258,7 @@ public class DeleteCommentFullTests extends RestTest
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText);
|
||||
file.setNodeRef("invalid");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
@@ -164,12 +275,12 @@ public class DeleteCommentFullTests extends RestTest
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText);
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.COMMENTS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify deleteComment from node with empty network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -177,10 +288,9 @@ public class DeleteCommentFullTests extends RestTest
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
commentModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(commentText);
|
||||
networkUserModel.setDomain("");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).deleteComment(commentModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 11/18/2016.
|
||||
*/
|
||||
public class GetCommentsCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel, networkUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private String comment = "This is a new comment";
|
||||
private String comment2 = "This is a 2nd comment";
|
||||
private String comment3 = "This is a 3rd comment";
|
||||
private RestCommentModelsCollection comments;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(document).addComment(comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(document).addComment(comment3);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void checkStatusCodeForInvalidMaxItems() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=0")
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary("Only positive values supported for maxItems");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't get comments for node with ID that does not exist and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanNotGetCommentsOnNonexistentFile() throws Exception
|
||||
{
|
||||
FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
nonexistentFile.setNodeRef("ABC");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(nonexistentFile).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void userCanNotGetCommentsOnLink() throws Exception
|
||||
{
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F"));
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(fileWithNodeRefFromLink).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef()))
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify request returns status 403 if the user does not have permission read comments on the node")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify user gets comments without the first 2 and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void skipFirst2Comments() throws Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2")
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("skipCount").is("2");
|
||||
comments.assertThat().paginationField("totalItems").is("3");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify get comments from node with invalid network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void getCommentsWithInvalidNetwork() throws Exception
|
||||
{
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify get comments from node with empty network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void getCommentsWithEmptyNetwork() throws Exception
|
||||
{
|
||||
networkUserModel.setDomain("");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetCommentsFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private String comment = "This is a new comment";
|
||||
private String comment2 = "This is the second comment";
|
||||
private RestCommentModelsCollection comments;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private FileModel file;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteContributor, UserRole.SiteConsumer);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void setUp() throws DataPreparationException, Exception {
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if manager adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if collaborator adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if contributor adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@Bug(id = "ACE-4614")
|
||||
public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().paginationField("totalItems").is("0");
|
||||
comments.assertThat().paginationField("count").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add one comment with Manager and check that returned person is the right one")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception
|
||||
{
|
||||
UserModel user1 = dataUser.createRandomTestUser();
|
||||
dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager);
|
||||
|
||||
restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment);
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName")
|
||||
.assertThat().field("lastName").is("LN-" + user1.getUsername());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add one comment with Collaborator and check that returned company details are correct")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.getOneRandomEntry().onModel().getCreatedBy().getCompany()
|
||||
.assertThat().field("organization").isNull()
|
||||
.assertThat().field("address1").isNull()
|
||||
.assertThat().field("address2").isNull()
|
||||
.assertThat().field("address3").isNull()
|
||||
.assertThat().field("postcode").isNull()
|
||||
.assertThat().field("telephone").isNull()
|
||||
.assertThat().field("fax").isNull()
|
||||
.assertThat().field("email").isNull();
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("skipCount").is("1");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment2)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.assertThat().entriesListIsNotEmpty()
|
||||
.and().paginationField("count").is("2");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
|
||||
comments.getEntries().get(0).onModel().getCreatedBy()
|
||||
.assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName")
|
||||
.assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername());
|
||||
|
||||
comments.getEntries().get(1).onModel().getCreatedBy()
|
||||
.assertThat().field("firstName").is("Administrator")
|
||||
.assertThat().field("id").is("admin");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
|
||||
restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
package org.alfresco.rest.comments;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetCommentsTests extends RestTest
|
||||
{
|
||||
private FileModel file, document, document1;
|
||||
private SiteModel siteModel, privateSiteModel;
|
||||
private UserModel adminUserModel, userModel, networkUserModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String comment = "This is a new comment";
|
||||
private String comment2 = "This is a 2nd comment";
|
||||
private String comment3 = "This is a 3rd comment";
|
||||
private RestCommentModelsCollection comments;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
document = dataContent.usingSite(privateSiteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
document1 = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document1).addComment(comment);
|
||||
restClient.withCoreAPI().usingResource(document).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(document).addComment(comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
restClient.withCoreAPI().usingResource(document).addComment(comment3);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify Admin user gets comments with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify Manager user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
|
||||
restClient.authenticateUser(nonexistentModel).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Manager user gets comments created by admin user with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Contributor user gets comments created by admin user with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Collaborator user gets comments created by admin user with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Consumer user gets comments created by admin user with Rest API and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Manager user gets comments created by another user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator);
|
||||
String contentManager = "This is a new comment added by " + userModel.getUsername();
|
||||
restClient.authenticateUser(userModel).withCoreAPI()
|
||||
.usingResource(document1).addComment(contentManager);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", contentManager)
|
||||
.and().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify admin user gets comments created by another user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void adminIsAbleToRetrieveCommentsCreatedByAnotherUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator);
|
||||
String contentCollaborator = "This is a new comment added by " + userModel.getUsername();
|
||||
restClient.authenticateUser(userModel).withCoreAPI()
|
||||
.usingResource(document1).addComment(contentCollaborator);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document1).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", contentCollaborator)
|
||||
.and().entriesListContains("content", comment);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify request returns status 403 if the user does not have permission read comments on the node")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void uninvitedUserCanNotGetCommentsFromPrivateSite() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(userModel).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify user gets comments without the first 2 and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void skipFirst2Comments() throws Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=2")
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("skipCount").is("2");
|
||||
comments.assertThat().paginationField("totalItems").is("3");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify invalid request returns status code 400 for invalid maxItems or skipCount")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void checkStatusCodeForInvalidMaxItems() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=0")
|
||||
.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary("Only positive values supported for maxItems");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't get comments for node with ID that does not exist and status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanNotGetCommentsOnNonExistentFile() throws Exception
|
||||
{
|
||||
FileModel nonexistentFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
nonexistentFile.setNodeRef("ABC");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(nonexistentFile).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nonexistentFile.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can't get comments for node that exists but is not a document or a folder and status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanNotGetCommentsOnLink() throws Exception
|
||||
{
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
fileWithNodeRefFromLink.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F"));
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(fileWithNodeRefFromLink).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, fileWithNodeRefFromLink.getNodeRef()))
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify get comments from node with invalid network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void getCommentsWithInvalidNetwork() throws Exception
|
||||
{
|
||||
networkUserModel.setDomain("invalidNetwork");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify get comments from node with empty network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void getCommentsWithEmptyNetwork() throws Exception
|
||||
{
|
||||
networkUserModel.setDomain("");
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if manager adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithManagerAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if collaborator adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithCollaboratorAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that if contributor adds one comment, it will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@Bug(id = "ACE-4614")
|
||||
public void addCommentWithContributorAndCheckThatCommentIsReturned() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.getPagination().assertThat().field("totalItems").is("1")
|
||||
.assertThat().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify that consumer cannot add a comment and no comments will be returned in getComments response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithConsumerAndCheckThatCommentIsNotReturned() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().paginationField("totalItems").is("0");
|
||||
comments.assertThat().paginationField("count").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add one comment with Manager and check that returned person is the right one")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithManagerCheckReturnedPersonIsTheRightOne() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
UserModel user1 = dataUser.createRandomTestUser();
|
||||
dataUser.addUserToSite(user1, siteModel, UserRole.SiteManager);
|
||||
|
||||
restClient.authenticateUser(user1).withCoreAPI().usingResource(file).addComment(comment);
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.getOneRandomEntry().onModel().getCreatedBy().assertThat().field("firstName").is(user1.getUsername() + " FirstName")
|
||||
.assertThat().field("lastName").is("LN-" + user1.getUsername());
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add one comment with Collaborator and check that returned company details are correct")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addCommentWithCollaboratorCheckReturnedCompanyDetails() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.getOneRandomEntry().onModel().getCreatedBy().getCompany()
|
||||
.assertThat().field("organization").isNull()
|
||||
.assertThat().field("address1").isNull()
|
||||
.assertThat().field("address2").isNull()
|
||||
.assertThat().field("address3").isNull()
|
||||
.assertThat().field("postcode").isNull()
|
||||
.assertThat().field("telephone").isNull()
|
||||
.assertThat().field("fax").isNull()
|
||||
.assertThat().field("email").isNull();
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Manager and Collaborator users and verify valid request using skipCount. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithManagerCollaboratorVerifySkipCountParamIsApplied() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("skipCount=1")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("skipCount").is("1");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Admin and Collaborator users and verify valid request using maxItems. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithAdminCollaboratorVerifyMaxItemsParamIsApplied() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("maxItems=1")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", comment2)
|
||||
.and().paginationField("count").is("1");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Add 2 comments with Manager and Admin users and verify valid request using properties. Check that param is applied")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithAdminManagerVerifyPropertiesParamIsApplied() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(file).addComment(comment2);
|
||||
|
||||
comments = restClient.authenticateUser(adminUserModel).withParams("properties=createdBy,modifiedBy")
|
||||
.withCoreAPI().usingResource(file).getNodeComments();
|
||||
comments.assertThat().entriesListIsNotEmpty()
|
||||
.and().paginationField("count").is("2");
|
||||
comments.assertThat().paginationField("totalItems").is("2");
|
||||
|
||||
comments.getEntries().get(0).onModel().getCreatedBy()
|
||||
.assertThat().field("firstName").is(usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername() + " FirstName")
|
||||
.assertThat().field("lastName").is("LN-" + usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername());
|
||||
|
||||
comments.getEntries().get(1).onModel().getCreatedBy()
|
||||
.assertThat().field("firstName").is("Administrator")
|
||||
.assertThat().field("id").is("admin");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void addTwoCommentsWithManagerCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComments(comment, comment2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).usingParams("maxItems=0").getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
restClient.assertLastError().descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
|
||||
restClient.assertLastError().stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
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.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class UpdateCommentCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestCommentModel commentModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestCommentModelsCollection comments;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment");
|
||||
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef()))
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary("An invalid argument was received");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200")
|
||||
// @Bug(id="REPO-1011")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user");
|
||||
comments = restClient.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200")
|
||||
// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify entry content in response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
commentModel.assertThat().field("content").is("This is the updated comment with admin user");
|
||||
}
|
||||
}
|
||||
+218
-41
@@ -8,8 +8,11 @@ import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestCommentModelsCollection;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.LinkModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
@@ -21,27 +24,201 @@ import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class UpdateCommentFullTests extends RestTest
|
||||
{
|
||||
public class UpdateCommentTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, networkUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestCommentModel commentModel, returnedCommentModel;
|
||||
private RestCommentModelsCollection comments;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestCommentModelsCollection comments;;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String firstComment = "This is a new comment";
|
||||
private String updatedComment = "This is the updated comment";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator,
|
||||
UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
networkUserModel = dataUser.createRandomTestUser();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
String updatedContent = "This is the updated comment with admin user";
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent)
|
||||
.assertThat().field("content").isNotEmpty()
|
||||
.and().field("content").is(updatedContent);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user.");
|
||||
UserModel incorrectUserModel = new UserModel("userName", "password");
|
||||
restClient.authenticateUser(incorrectUserModel)
|
||||
.withCoreAPI().usingResource(document).updateComment(commentModel, "try to update");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify entry content in response")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void checkEntryContentInResponse() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with admin user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
commentModel.assertThat().field("content").is("This is the updated comment with admin user");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user updates comments created by admin user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager");
|
||||
restClient.withCoreAPI().usingResource(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);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can update his own comment and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor");
|
||||
String updatedContent = "This is the updated comment with Contributor user";
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, updatedContent);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Consumer user can not update comments created by admin user and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void consumerIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Consumer user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can update his own comment and status code is 200")
|
||||
// @Bug(id="REPO-1011")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator");
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can not update comments of another user and status code is 200")
|
||||
// @Bug(id="MNT-2502",description="seems it's one old issue: also logged as MNT-2502, MNT-2346")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
|
||||
public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify update comment with inexistent nodeId returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void canNotUpdateCommentIfNodeIdIsNotSet() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
FolderModel content = FolderModel.getRandomFolderModel();
|
||||
content.setNodeRef("node ref that does not exist");
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary("node ref that does not exist was not found");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify if commentId is not set the status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void canNotUpdateCommentIfCommentIdIsNotSet() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
RestCommentModel comment = new RestCommentModel();
|
||||
String id = "comment id that does not exist";
|
||||
comment.setId(id);
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(comment, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, id));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
|
||||
content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(content).addComment("This is a new comment");
|
||||
|
||||
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
|
||||
content.setNodeRef(link.getNodeRef().replace("workspace://SpacesStore/", "workspace%3A%2F%2FSpacesStore%2F"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(content).updateComment(commentModel, "This is the updated comment.");
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, content.getNodeRef()))
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user is not able to update with empty comment body and status code is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary("An invalid argument was received");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify updated comment by Manager is listed when calling getComments and status code is 200")
|
||||
// @Bug(id="REPO-1011")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void updatedCommentByManagerIsListed() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document).updateComment(commentModel, "This is the updated comment with Manager user");
|
||||
comments = restClient.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", "This is the updated comment with Manager user");
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Manager user can update a comment with a large string")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -59,7 +236,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCommentModel.assertThat().field("content").is(longString);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Manager user can update a comment with a short string")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -77,7 +254,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCommentModel.assertThat().field("content").is(shortString);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Collaborator user can update a comment with special characters")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -95,7 +272,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCommentModel.assertThat().field("content").is(specialChars);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Check that you cannot update comment with Consumer then call getComments and check new comment is not listed")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -116,7 +293,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
.and().entriesListDoesNotContain("content", updatedComment)
|
||||
.and().paginationField("totalItems").is("1");
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Update comment with Contributor then call getComments and check new comment is listed")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -138,7 +315,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
.and().entriesListDoesNotContain("content", firstComment)
|
||||
.and().paginationField("totalItems").is("1");
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Update comment with Collaborator then call getComments and check new comment is listed")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -177,7 +354,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
returnedCommentModel.assertThat().field("modifiedBy.id").is(manager.getUsername())
|
||||
.and().field("content").is(updatedComment);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Delete comment with Admin then try to update it")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -195,7 +372,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Manager user can update a comment with multi byte content")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -213,7 +390,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCommentModel.assertThat().field("content").is(multiByte);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify Admin user can update a comment with properties parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -233,7 +410,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
.assertThat().field("modifiedBy.id").is(manager.getUsername())
|
||||
.assertThat().fieldsCount().is(4);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Update comment with invalid node")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -249,7 +426,7 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef()));
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify update comment from node with invalid network id returns status code 401")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
@@ -262,24 +439,24 @@ public class UpdateCommentFullTests extends RestTest
|
||||
restClient.authenticateUser(networkUserModel).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
|
||||
description= "Verify User can not update comment to a not joined private site. Status code returned is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser();
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify User can not update comment to a not joined private site. Status code returned is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
|
||||
public void userCanNotUpdateCommentToANotJoinedPrivateSiteDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser();
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
commentModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).addComment(firstComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY);
|
||||
}
|
||||
}
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingResource(file).updateComment(commentModel, updatedComment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
|
||||
.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user