From 239366e539773336f058ed91bca7a60ec41cc7b5 Mon Sep 17 00:00:00 2001 From: Valentin Popa Date: Wed, 23 Nov 2016 12:21:29 +0200 Subject: [PATCH 01/15] CORE-REST API: rate (post /nodes/{nodeId}/ratings) --- .../rest/ratings/AddRatingCoreTests.java | 217 ++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java diff --git a/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java new file mode 100644 index 000000000..fe2a5e1c7 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/ratings/AddRatingCoreTests.java @@ -0,0 +1,217 @@ +package org.alfresco.rest.ratings; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.ErrorModel; +import org.alfresco.utility.model.FileModel; +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; +import org.alfresco.utility.report.Bug; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE }) +public class AddRatingCoreTests extends RestTest +{ + private UserModel userModel; + private SiteModel siteModel; + private UserModel adminUser; + private FolderModel folderModel; + private FileModel document; + private ListUserWithRoles usersWithRoles; + private RestRatingModel returnedRatingModel; //placeholder for returned model + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + adminUser = dataUser.getAdminUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + } + + @BeforeMethod + public void setUp() throws Exception + { + folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder(); + document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if unknown rating scheme is provided status code is 400") + public void unknownRatingSchemeReturnsBadRequest() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "invalidRate")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if nodeId does not exist status code 404 is returned") + public void invalidNodeIdReturnsNotFound() throws Exception + { + document.setNodeRef(RandomStringUtils.randomAlphanumeric(10)); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef())); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if nodeId provided cannot be rated 405 status code is returned") + @Bug(id = "MNT-16904") + public void likeResourceThatCannotBeRated() throws Exception + { + LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink(); + document.setNodeRef(link.getNodeRef()); + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to like a file") + public void managerIsAbleToLikeAFile() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to like a folder") + public void managerIsAbleToLikeAFolder() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to rate a folder") + public void managerIsAbleToRateAFolder() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager is able to rate a file") + public void managerIsAbleToRateAFile() throws Exception + { + returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding like again has no effect on a file") + public void fileCanBeLikedTwice() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that adding rate again has no effect on a file") + public void fileCanBeRatedTwice() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5") + .and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that rate is not added if empty rating object is provided") + public void addRateUsingEmptyRatingObject() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating(""); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + "No content to map to Object due to end of input")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if empty rate id is provided status code is 400") + public void addRateUsingEmptyValueForId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT, + "N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if empty rating is provided status code is 400") + public void addRateUsingEmptyValueForMyRating() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_LIKE_RATING)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}"); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_FIVESTAR_RATING)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate a comment") + public void addRatingToAComment() throws Exception + { + RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment"); + document.setNodeRef(comment.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user is not able to rate a tag") + public void addRatingToATag() throws Exception + { + RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag"); + document.setNodeRef(tag.getId()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument(); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + + restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5); + restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE)); + } + +} \ No newline at end of file From ce99c122d3edebd53770924016b5e5ae36f6d2ac Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 14:27:09 +0200 Subject: [PATCH 02/15] added bug annotation --- .../rest/comments/DeleteCommentsSanityTests.java | 16 ++++++++-------- .../rest/people/DeleteSiteMemberSanityTests.java | 3 ++- .../rest/sites/GetSiteMembersSanityTests.java | 3 ++- .../alfresco/rest/tags/DeleteTagSanityTests.java | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java index cce059c56..359a3f27d 100644 --- a/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/DeleteCommentsSanityTests.java @@ -6,10 +6,8 @@ import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModel; 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.model.*; +import org.alfresco.utility.report.Bug; import org.alfresco.utility.testrail.ExecutionType; import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpStatus; @@ -76,14 +74,16 @@ public class DeleteCommentsSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); } + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, - TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails") - public void managerIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception + TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails") + 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); - comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by Manager"); restClient.withCoreAPI().usingResource(document).deleteComment(comment); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index f93657375..48540caac 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -115,7 +115,8 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } - + + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to delete another member of the site") diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java index acf806253..752cfa6f4 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteMembersSanityTests.java @@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; @@ -108,6 +109,6 @@ public class GetSiteMembersSanityTests extends RestTest dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); restClient.authenticateUser(userModel) .withCoreAPI().usingSite(siteModel).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED); } } diff --git a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java index 8d55a4699..97a23746a 100644 --- a/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/DeleteTagSanityTests.java @@ -13,6 +13,7 @@ import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.StatusModel; 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; @@ -112,6 +113,7 @@ public class DeleteTagSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); } + @Bug(id="MNT-16904") @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails") public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception From 7376e179e6d7060be85c58d71cac0f1e02d79577 Mon Sep 17 00:00:00 2001 From: Paul Brodner Date: Wed, 23 Nov 2016 16:30:43 +0200 Subject: [PATCH 03/15] mark tests for network --- .../networks/RestGetNetworksForPersonSanityTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java index bb75fb85e..c19dbe4c9 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworksForPersonSanityTests.java @@ -28,7 +28,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest } @Bug(id = "MNT-16904") - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status") @@ -41,7 +41,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty") @@ -52,7 +52,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = TestGroup.COMMENTS) + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status") @@ -63,8 +63,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); } - @Test(groups = TestGroup.COMMENTS) - @TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, + @Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS}) + @TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY, description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status") public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception From 82c7844ce1251937793e4fc96fe1b77155ad06ef Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 16:54:35 +0200 Subject: [PATCH 04/15] fix error summary for 5.2 --- .../org/alfresco/rest/comments/GetCommentsCoreTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java index b0ff5e71c..d2325405b 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsCoreTests.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE }) public class GetCommentsCoreTests extends RestTest { - private UserModel adminUserModel, userModel; + private UserModel adminUserModel, userModel, networkUserModel; private FileModel document; private SiteModel siteModel; private String comment = "This is a new comment"; @@ -30,6 +30,7 @@ public class GetCommentsCoreTests extends RestTest { 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() @@ -48,7 +49,7 @@ public class GetCommentsCoreTests extends RestTest restClient.authenticateUser(adminUserModel).withParams("maxItems=0") .withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Only positive values supported for maxItems"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION, @@ -105,7 +106,7 @@ public class GetCommentsCoreTests extends RestTest @Bug(id = "MNT-16904") public void getCommentsWithInvalidNetwork() throws Exception { - userModel.setDomain("invalidNetwork"); + networkUserModel.setDomain("invalidNetwork"); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } @@ -115,7 +116,7 @@ public class GetCommentsCoreTests extends RestTest @Bug(id = "MNT-16904") public void getCommentsWithEmptyNetwork() throws Exception { - userModel.setDomain(""); + networkUserModel.setDomain(""); restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 8a711d84fe82e5504d37d830df6099642cad2072 Mon Sep 17 00:00:00 2001 From: Andreea Nechifor Date: Wed, 23 Nov 2016 16:58:51 +0200 Subject: [PATCH 05/15] update testRail --- e2e-test/resources/default.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index 9f87e0902..ca02e1224 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -29,9 +29,10 @@ rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1 testManagement.endPoint=https://alfresco.testrail.com/ testManagement.username=tas.alfresco@gmail.com testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S -testManagement.project=7 +testManagement.project=1 testManagement.testRun=Automation testManagement.justUploadTest=false +testManagement.suiteId=1 # The location of the reports path reports.path=./target/reports From a0dd95422e2f6a7d113e6b52da2ed8044524f076 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:11:55 +0200 Subject: [PATCH 06/15] fix error summary for 5.2 --- .../java/org/alfresco/rest/ratings/GetRatingsCoreTests.java | 4 ++-- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java index 916504147..b41e2c7fa 100644 --- a/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/ratings/GetRatingsCoreTests.java @@ -44,7 +44,7 @@ public class GetRatingsCoreTests extends RestTest { restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document) .getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .containsSummary("Only positive values supported for maxItems"); } @TestRail(section = { TestGroup.REST_API, @@ -54,7 +54,7 @@ public class GetRatingsCoreTests extends RestTest { restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document) .getLikeRating(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() - .containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .containsSummary("Invalid paging parameter skipCount:AB"); } @TestRail(section = { TestGroup.REST_API, diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index cba567e89..8a1b5914c 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -54,7 +54,7 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(userModel).withParams("maxItems=0") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Only positive values supported for maxItems"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, @@ -64,7 +64,7 @@ public class GetSitesCoreTests extends RestTest restClient.authenticateUser(userModel).withParams("skipCount=A") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument")); + .assertLastError().containsSummary("Invalid paging parameter skipCount:A"); } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, From 140d83fd5848b9a596c954231143930a14a5d037 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:22:08 +0200 Subject: [PATCH 07/15] updated scenario for 5.2 --- e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java index 8a1b5914c..c4766c1cb 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesCoreTests.java @@ -71,7 +71,7 @@ public class GetSitesCoreTests extends RestTest description= "Verify User gets sites ordered by name ascendant and status code is 200") public void getSitesOrderedByNameASC() throws Exception { - sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=name ASC") + sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.OK); sites.assertThat().entriesListIsNotEmpty(); From 50bf1ea8d44ba1129edaf5f9939ec8a0789ea28e Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:22:27 +0200 Subject: [PATCH 08/15] added bug annotation --- .../org/alfresco/rest/comments/UpdateCommentsCoreTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index a314e0502..16a30be53 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -82,7 +82,8 @@ public class UpdateCommentsCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); 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 From 439a18442a859f72583cdc9e46acbfd5d53b2fa1 Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 23 Nov 2016 17:39:32 +0200 Subject: [PATCH 09/15] call getSites using maxItems parameter --- .../rest/sites/GetSitesSanityTests.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java index 3414c662c..3e0353f01 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSitesSanityTests.java @@ -23,12 +23,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) public class GetSitesSanityTests extends RestTest { - @Autowired - DataUser dataUser; - - @Autowired - DataSite dataSite; - private UserModel adminUserModel; private UserModel userModel; private ListUserWithRoles usersWithRoles; @@ -38,7 +32,6 @@ public class GetSitesSanityTests extends RestTest public void dataPreparation() throws Exception { adminUserModel = dataUser.getAdminUser(); - restClient.authenticateUser(adminUserModel); siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); } @@ -46,8 +39,7 @@ public class GetSitesSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)") public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -59,7 +51,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Collaborator role gets sites information and gets status code OK (200)") public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=1000") .withCoreAPI().getSites().assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) .and().paginationExist(); @@ -72,7 +64,7 @@ public class GetSitesSanityTests extends RestTest public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -85,7 +77,7 @@ public class GetSitesSanityTests extends RestTest public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -97,7 +89,7 @@ public class GetSitesSanityTests extends RestTest description = "Verify user with Admin user gets sites information and gets status code OK (200)") public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception { - restClient.authenticateUser(adminUserModel) + restClient.authenticateUser(adminUserModel).withParams("maxItems=1000") .withCoreAPI().getSites() .assertThat().entriesListIsNotEmpty() .assertThat().entriesListContains("id", siteModel.getId()) @@ -114,7 +106,7 @@ public class GetSitesSanityTests extends RestTest userModel = dataUser.createRandomTestUser(); userModel.setPassword("user wrong password"); dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager); - restClient.authenticateUser(userModel) + restClient.authenticateUser(userModel).withParams("maxItems=1000") .withCoreAPI().getSites(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } From 71627b53370a1c225856a85ed52ff062d198c363 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 10:09:10 +0200 Subject: [PATCH 10/15] try to fix tests --- .../rest/tags/GetTagsSanityTests.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java index 0adb153dd..d9f05070e 100644 --- a/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/tags/GetTagsSanityTests.java @@ -8,11 +8,7 @@ import org.alfresco.utility.Utility; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.FileModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.StatusModel; -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; @@ -42,12 +38,10 @@ public class GetTagsSanityTests extends RestTest document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); tagValue = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue); - tagValue2 = RandomData.getRandomName("tag"); - restClient.withCoreAPI().usingResource(document).addTag(tagValue2); + restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2); - Utility.waitToLoopTime(5); + Utility.waitToLoopTime(60); } @@ -55,7 +49,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -66,7 +60,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -77,7 +71,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -88,7 +82,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception { restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) @@ -99,7 +93,7 @@ public class GetTagsSanityTests extends RestTest public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception { restClient.authenticateUser(adminUserModel); - RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags(); + RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags(); restClient.assertStatusCodeIs(HttpStatus.OK); returnedCollection.assertThat().entriesListIsNotEmpty() .and().entriesListContains("tag", tagValue.toLowerCase()) From a2bf38163893b04516b7a0c839db6018fafb186c Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 10:46:10 +0200 Subject: [PATCH 11/15] removed bug annotation --- .../java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java | 1 - .../java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java | 1 - 2 files changed, 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java index 52e8f7e43..468a752a6 100644 --- a/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/favorites/GetFavoritesCoreTests.java @@ -229,7 +229,6 @@ public class GetFavoritesCoreTests extends RestTest .and().paginationField("totalItems").is("2"); } - @Bug(id="MNT-17146") @TestRail(section = { TestGroup.REST_API, TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404") public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception diff --git a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java index 06530bd58..26001e020 100644 --- a/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/people/GetFavoriteSiteCoreTests.java @@ -42,7 +42,6 @@ public class GetFavoriteSiteCoreTests extends RestTest .assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser")); } - @Bug(id="MNT-17146") @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify invalid request returns status 404 when siteId does not exist") From 35fb448929769be5edf84780b830532d0541a48d Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 11:11:40 +0200 Subject: [PATCH 12/15] fix tests --- .../rest/comments/UpdateCommentsCoreTests.java | 18 ++++++------------ .../comments/UpdateCommentsSanityTests.java | 12 +++++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java index 16a30be53..32465a959 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsCoreTests.java @@ -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, diff --git a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java index 3c762ba94..fe30b9575 100644 --- a/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/UpdateCommentsSanityTests.java @@ -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); } From b546a1e548a9b18d4354ad8f2355564921096fb5 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 15:04:30 +0200 Subject: [PATCH 13/15] added network test group --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index e87bf2563..558cfb19d 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,6 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +@Test(groups = TestGroup.NETWORKS) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; From 1645ae17755d32a2f5173005d2b4aacefdd887a6 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 24 Nov 2016 15:07:27 +0200 Subject: [PATCH 14/15] added network test group --- .../rest/networks/RestGetNetworkForPersonSanityTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java index 558cfb19d..28580e5e2 100644 --- a/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/networks/RestGetNetworkForPersonSanityTests.java @@ -10,7 +10,7 @@ import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -@Test(groups = TestGroup.NETWORKS) +@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS }) public class RestGetNetworkForPersonSanityTests extends RestTest { private UserModel adminUserModel; From 235b37e18b1ede74d9a9af7a85bf454edad52f90 Mon Sep 17 00:00:00 2001 From: Cristina Jalba Date: Thu, 24 Nov 2016 16:46:51 +0200 Subject: [PATCH 15/15] Fixing DeleteSiteMemberSanityTests --- .../rest/people/DeleteSiteMemberSanityTests.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java index 48540caac..e49e3b6f0 100644 --- a/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/people/DeleteSiteMemberSanityTests.java @@ -68,7 +68,6 @@ public class DeleteSiteMemberSanityTests extends RestTest @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site collaborator does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -78,14 +77,12 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site contributor does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -95,14 +92,12 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Verify site consumer does not have permission to delete another member of the site") - @Bug(id="ACE-5444") public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception { UserModel newUser = dataUser.createRandomTestUser("testUser"); @@ -112,8 +107,7 @@ public class DeleteSiteMemberSanityTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel); - restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) - .assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId())); } @Bug(id="MNT-16904")