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) (2)
This commit is contained in:
@@ -1,109 +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 DeleteCommentSanityTests 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.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);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Collaborator");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes own comments and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Contributor");
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user cannot delete comments and status code returned is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
public void consumerIsNotAbleToDeleteComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment added by Manager");
|
||||
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.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);
|
||||
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin");
|
||||
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
|
||||
restClient.authenticateUser(nonexistentModel);
|
||||
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -1,146 +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.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.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 GetCommentsSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private UserModel userModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String content = "This is a new comment";
|
||||
private RestCommentModelsCollection comments;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document).addComment(content);
|
||||
|
||||
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(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
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.SANITY })
|
||||
public void managerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
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.SANITY })
|
||||
public void contributorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
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.SANITY })
|
||||
public void collaboratorIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
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.SANITY })
|
||||
public void consumerIsAbleToRetrieveComments() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
|
||||
@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(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify Manager user gets comments created by another user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
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(document).addComment(contentManager);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
comments = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", contentManager)
|
||||
.and().entriesListContains("content", content);
|
||||
}
|
||||
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.COMMENTS}, executionType= ExecutionType.SANITY,
|
||||
description= "Verify admin user gets comments created by another user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
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(document).addComment(contentCollaborator);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
comments = restClient.authenticateUser(adminUserModel).withCoreAPI()
|
||||
.usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
comments.assertThat().entriesListContains("content", contentCollaborator)
|
||||
.and().entriesListContains("content", content);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +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.FolderModel;
|
||||
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 UpdateCommentSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestCommentModel commentModel;
|
||||
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 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 Manager user updates comments created by admin user and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
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.SANITY, description = "Verify Contributor user can update his own comment and status code is 200")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
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.SANITY, description = "Verify Consumer user can not update comments created by admin user and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
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.SANITY, 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.SANITY })
|
||||
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.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 update comment with inexistent nodeId returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
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.SANITY, description = "Verify if commentId is not set the status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS })
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user