fix tests

This commit is contained in:
cagache
2016-11-24 11:11:40 +02:00
parent a2bf381638
commit 35fb448929
2 changed files with 13 additions and 17 deletions
@@ -7,12 +7,7 @@ import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.rest.model.RestCommentModelsCollection;
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.model.*;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
@@ -43,7 +38,7 @@ public class UpdateCommentsCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405")
@Bug(id="MNT-16904")
public void canNotUpdateCommentIfNodeIdIsNeitherDoumentOrFolder() throws JsonToModelConversionException, Exception
public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception
{
FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
@@ -61,7 +56,7 @@ public class UpdateCommentsCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400")
public void adminIsNotAbleToUpdateWithEptyCommentBody() throws JsonToModelConversionException, Exception
public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
@@ -83,16 +78,15 @@ public class UpdateCommentsCoreTests extends RestTest
comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user");
}
@Bug(id="")
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update comments of another user and status code is 200")
public void collaboratorIsAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comments of another user and status code is 200")
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));
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
restClient.assertStatusCodeIs(HttpStatus.OK);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
}
@TestRail(section = { TestGroup.REST_API,
@@ -41,7 +41,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200")
public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception
public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
@@ -54,7 +54,7 @@ public class UpdateCommentsSanityTests extends RestTest
@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")
public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
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");
@@ -67,7 +67,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200")
public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
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");
@@ -91,7 +91,7 @@ public class UpdateCommentsSanityTests extends RestTest
@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")
public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
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");
@@ -104,9 +104,11 @@ public class UpdateCommentsSanityTests extends RestTest
@Bug(id="MNT-16904")
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).getNodeComments();
.withCoreAPI().usingResource(document).updateComment(commentModel, "try to update");
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}