From 98708463021ad6985954d8cabdbdbd8361be0660 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Thu, 2 Feb 2017 10:21:40 +0200 Subject: [PATCH 1/2] added tests for UpdateTagFullTests --- .../rest/tags/UpdateTagFullTests.java | 161 ++++++++++++++++++ .../rest/tags/UpdateTagSanityTests.java | 2 +- 2 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java new file mode 100644 index 000000000..1d8a9242c --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -0,0 +1,161 @@ +package org.alfresco.rest.tags; + +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.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.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.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class UpdateTagFullTests extends RestTest +{ + private UserModel adminUserModel; + private FileModel document; + private SiteModel siteModel; + private RestTagModel oldTag; + private DataUser.ListUserWithRoles usersWithRoles; + private RestTagModel returnedModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + 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 addTagToDocument() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide large string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideLargeStringTag() throws JsonToModelConversionException, Exception + { + String largeStringTag = RandomStringUtils.randomAlphanumeric(10000); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(largeStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide short string for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideShortStringTag() throws JsonToModelConversionException, Exception + { + String shortStringTag = RandomStringUtils.randomAlphanumeric(2); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(shortStringTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager user can provide string with special chars for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void managerIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws JsonToModelConversionException, Exception + { + String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(specialCharsString); + } + + @TestRail(section = { TestGroup.REST_API, + TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403." + + "Check default error model schema.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception + { + String newTag = "newTag"; + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can provide existing tag for new tag value.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void adminIsAbleToUpdateTagsProvideExistingTag() throws JsonToModelConversionException, Exception + { + String existingTag = "oldTag"; + RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingResource(document).addTag(existingTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + restClient.authenticateUser(adminUserModel); + returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(existingTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can delete a tag, add tag and update it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminDeleteTagAddTagUpdateTag() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingResource(document).deleteTag(oldTag); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + String newTag = "addTag"; + RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify Admin user can update a tag, delete tag and add it.") + @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) + @Bug(id="REPO-1828") + public void withAdminUpdateTagDeleteTagAddTag() throws JsonToModelConversionException, Exception + { + String newTag = "addTag"; + + returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag); + restClient.assertStatusCodeIs(HttpStatus.OK); + returnedModel.assertThat().field("tag").is(newTag); + + restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.withCoreAPI().usingResource(document).addTag(newTag); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } +} diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index 567148d6c..b50ceb2ab 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -51,7 +51,7 @@ public class UpdateTagSanityTests extends RestTest } @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200") - @Bug(id="MNT-16917") + @Bug(id="REPO-1828") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception { From f9443cc479875f60c78a3128c1c0a3f004fe81df Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Mon, 6 Feb 2017 10:55:28 +0200 Subject: [PATCH 2/2] updated tests UpdateTag Full and Sanity tests --- .../alfresco/rest/tags/UpdateTagFullTests.java | 17 ----------------- .../rest/tags/UpdateTagSanityTests.java | 7 +++++-- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java index 1d8a9242c..d8dcb0066 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagFullTests.java @@ -3,7 +3,6 @@ package org.alfresco.rest.tags; 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.rest.model.RestTagModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; @@ -88,22 +87,6 @@ public class UpdateTagFullTests extends RestTest returnedModel.assertThat().field("tag").is(specialCharsString); } - @TestRail(section = { TestGroup.REST_API, - TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403." - + "Check default error model schema.") - @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) - public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception - { - String newTag = "newTag"; - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingTag(oldTag).update(newTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) - .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user can provide existing tag for new tag value.") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL }) diff --git a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java index b50ceb2ab..4b6bb81ae 100644 --- a/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/UpdateTagSanityTests.java @@ -74,11 +74,14 @@ public class UpdateTagSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403") @Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY }) - public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception + public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingTag(oldTag).update(randomTag); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED) + .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); } @TestRail(section = { TestGroup.REST_API,