From 08bc7d45997bd3aeab26c671e93199ccabe033f4 Mon Sep 17 00:00:00 2001 From: dhrn <14145706+dhrn@users.noreply.github.com> Date: Mon, 8 Feb 2021 15:48:05 +0530 Subject: [PATCH] [REPO-5317] integration test for REPO-5184 and REPO-5185 (#222) --- .../rest/sites/groups/AddSiteGroupTests.java | 280 ++++++++++++++++++ .../rest/sites/groups/GetSiteGroupTests.java | 135 +++++++++ .../rest/sites/groups/GetSiteGroupsTests.java | 275 +++++++++++++++++ .../sites/groups/RemoveSiteGroupTests.java | 197 ++++++++++++ .../sites/groups/UpdateSiteGroupTests.java | 187 ++++++++++++ .../sites/members/GetSiteMembersTests.java | 32 +- 6 files changed, 1105 insertions(+), 1 deletion(-) create mode 100644 packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/AddSiteGroupTests.java create mode 100644 packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java create mode 100644 packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupsTests.java create mode 100644 packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/RemoveSiteGroupTests.java create mode 100644 packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/AddSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/AddSiteGroupTests.java new file mode 100644 index 0000000000..6090d1a011 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/AddSiteGroupTests.java @@ -0,0 +1,280 @@ +package org.alfresco.rest.sites.groups; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteGroupModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class AddSiteGroupTests extends RestTest +{ + private UserModel adminUserModel; + private SiteModel publicSiteModel, moderatedSiteModel; + private ListUserWithRoles publicSiteUsersWithRoles; + private String addMemberJson, addMembersJson; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + publicSiteUsersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, + UserRole.SiteManager, + UserRole.SiteCollaborator, + UserRole.SiteConsumer, + UserRole.SiteContributor); + addMemberJson = "{\"role\":\"%s\",\"id\":\"%s\"}"; + addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not be added to an inexistent site and gets status code 404") + public void notAbleToAddGroupToAnInExistentSite() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + SiteModel inexistentSite = new SiteModel("inexistentSite"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addSiteGroup(getId(group), UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that inexistent group can not be added to site and gets status code 404") + public void notAbleToAddInExistentGroupToSite() throws Exception + { + GroupModel group = new GroupModel("inExistentGroup"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addSiteGroup(group.getGroupIdentifier(), UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY) + .containsSummary(String.format("An authority was not found for %s", group.getGroupIdentifier())) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that user can not add group that is already present and gets status code 409") + public void notAbleToAddGroupThatIsAlreadyAPresent() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addSiteGroup(getId(group), UserRole.SiteManager); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addSiteGroup(getId(group), UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, getId(group), moderatedSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several groups with different roles can be added once in a row to a site and gets status code 201") + public void addSeveralGroupsWithDifferentRolesToASite() throws Exception + { + GroupModel firstGroup = dataGroup.createRandomGroup(); + GroupModel secondGroup = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, UserRole.SiteContributor, getId(firstGroup), UserRole.SiteCollaborator, getId(secondGroup)); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several groups with same roles can be added once in a row to a site and gets status code 201") + public void addSeveralGroupsWithSameRolesToASite() throws Exception + { + GroupModel firstGroup = dataGroup.createRandomGroup(); + GroupModel secondGroup = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, UserRole.SiteCollaborator, getId(firstGroup), UserRole.SiteCollaborator, getId(secondGroup)); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") + public void addSeveralGroupsThatAreAlreadyAddedToASite() throws Exception + { + GroupModel firstGroup = dataGroup.createRandomGroup(); + GroupModel secondGroup = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + String json = String.format(addMembersJson, UserRole.SiteCollaborator, getId(firstGroup), UserRole.SiteCollaborator, getId(secondGroup)); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, getId(firstGroup), publicSiteModel.getId())) ; + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Add new site group membership request by providing an empty body") + public void addSiteGroupsUsingEmptyBody() throws Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "", "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "No content to map due to end-of-input")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Check lower and upper case letters for role field") + public void checkLowerUpperCaseLettersForRole() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + String json = String.format(addMemberJson, "SITEMANAGER", getId(group)); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format("An authority was not found for GROUP_site_%s_%s", publicSiteModel.getId(), "SITEMANAGER")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + json = String.format(addMemberJson, "sitemanager", getId(group)); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format("An authority was not found for GROUP_site_%s_%s", publicSiteModel.getId(), "sitemanager")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Check empty value for user role") + public void checkEmptyValueForRole() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + String json = String.format(addMemberJson, "", getId(group)); + restClient.authenticateUser(adminUserModel).withCoreAPI(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/group-members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); + restClient.processModel(RestSiteGroupModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsErrorKey(String.format(RestErrorModel.NO_CONTENT, "N/A")) + .containsSummary(String.format(RestErrorModel.NO_CONTENT, "N/A")) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that manager is able to add site group membership and gets status code CREATED (201)") + public void managerIsAbleToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteCollaborator) + .assertThat() + .field("id").is(getId(group)) + .and() + .field("role").is(UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site collaborator is not able to add site group membership and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteCollaborator); + + restClient.assertLastError().containsSummary("The current user does not have permissions to modify the membership details of the site"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION}) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site contributor is not able to add site group membership and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteContributor); + + restClient.assertLastError().containsSummary("The current user does not have permissions to modify the membership details of the site"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that site consumer is not able to add site group membership and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteConsumer);; + + restClient.assertLastError().containsSummary("The current user does not have permissions to modify the membership details of the site"); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that admin user is able to add site group membership and gets status code CREATED (201)") + public void adminIsAbleToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteConsumer) + .assertThat() + .field("id").is(getId(group)) + .and() + .field("role").is(UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to add site group membership") + public void unauthenticatedUserIsNotAuthorizedToAddSiteGroup() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") + public void addManagerToPublicSite() throws Exception + { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(group), UserRole.SiteManager) + .assertThat() + .field("id").is(getId(group)) + .and() + .field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + } + + String getId(GroupModel group) { + return "GROUP_" + group.getGroupIdentifier(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java new file mode 100644 index 0000000000..3fd0d483ef --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java @@ -0,0 +1,135 @@ +package org.alfresco.rest.sites.groups; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetSiteGroupTests extends RestTest +{ + private UserModel adminUser; + private SiteModel publicSiteModel; + private DataUser.ListUserWithRoles usersWithRoles; + private GroupModel manager, consumer; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + consumer = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(consumer, dataUser.createRandomTestUser()); + + manager = dataGroup.createRandomGroup(); + dataGroup.addListOfUsersToGroup(consumer, dataUser.createRandomTestUser()); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(manager), UserRole.SiteManager); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(consumer), UserRole.SiteConsumer); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user can get site group and gets status code OK (200)") + public void getSiteGroupWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteGroup(getId(manager)) + .and().field("id").is(getId(manager)) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site group call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteGroup() throws JsonToModelConversionException, Exception + { + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).getSiteGroup(getId(consumer)); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager role doesn't get a site group of inexistent site and status code is Not Found (404)") + public void getSiteGroupOfInexistentSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).getSiteGroup(getId(consumer)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, invalidSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager role doesn't get non site group of inexistent site and status code is Not Found (404)") + public void getSiteGroupForNonSiteGroup() throws Exception + { + GroupModel nonGroup = dataGroup.createRandomGroup(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteGroup(getId(nonGroup)); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Given authority is not a member of the site")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager role doesn't get not existing site group and status code is Not Found (404)") + public void getSiteGroupForInexistentSiteGroup() throws Exception + { + GroupModel inexistentGroup = new GroupModel("inexistentGroup"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteGroup(getId(inexistentGroup)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format("An authority was not found for %s", getId(inexistentGroup))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager role can get site group for empty siteId") + public void getSiteGroupForEmptySiteId() throws Exception + { + SiteModel emptySite = new SiteModel(""); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(emptySite).getSiteGroup(getId(consumer)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Manager role gets site groups with Manager role and status code is OK (200)") + public void getSiteGroupWithManagerRole() throws Exception + { + GroupModel anotherManager = dataGroup.createRandomGroup(); + restClient.withCoreAPI().usingSite(publicSiteModel).addSiteGroup(getId(anotherManager), UserRole.SiteManager); + + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteGroup(getId(anotherManager)) + .assertThat().field("id").is(getId(anotherManager)) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + String getId(GroupModel group) { + return "GROUP_" + group.getGroupIdentifier(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupsTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupsTests.java new file mode 100644 index 0000000000..c02f24f868 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupsTests.java @@ -0,0 +1,275 @@ +package org.alfresco.rest.sites.groups; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.*; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +public class GetSiteGroupsTests extends RestTest +{ + private SiteModel publicSite, moderatedSite; + private List publicSiteGroups, moderatedSiteGroups; + private DataUser.ListUserWithRoles publicSiteUsers; + private UserModel siteCreator; + private UserModel regularUser; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + siteCreator = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); + + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + publicSiteGroups = addGroupToSite(publicSite,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + moderatedSiteGroups = addGroupToSite(moderatedSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite).usingParams("properties=role,id").getSiteGroups(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify Manager role gets site groups and gets status code OK (200)") + public void getSiteGroupsWithManagerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSite).getSiteGroups() + .assertThat() + .entriesListCountIs(4) + .and().entriesListContains("id", getId(publicSiteGroups.get(0))) + .and().entriesListContains("role", UserRole.SiteManager.name()) + .and().entriesListContains("id", getId(publicSiteGroups.get(1))) + .and().entriesListContains("role", UserRole.SiteCollaborator.name()) + .and().entriesListContains("id", getId(publicSiteGroups.get(2))) + .and().entriesListContains("role", UserRole.SiteConsumer.name()) + .and().entriesListContains("id", getId(publicSiteGroups.get(3))) + .and().entriesListContains("role", UserRole.SiteContributor.name()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Collaborator role gets site groups and gets status code OK (200)") + public void getSiteGroupsWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSite).getSiteGroups() + .assertThat() + .entriesListCountIs(4) + .and().entriesListContains("id", getId(publicSiteGroups.get(1))) + .and().entriesListContains("role", UserRole.SiteCollaborator.name()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Contributor role gets site groups and gets status code OK (200)") + public void getSiteGroupsWithContributorRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSite).getSiteGroups() + .assertThat() + .entriesListCountIs(4) + .and().entriesListContains("id", getId(publicSiteGroups.get(3))) + .and().entriesListContains("role", UserRole.SiteContributor.name()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify Consumer role gets site groups and gets status code OK (200)") + public void getSiteGroupsWithConsumerRole() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSite).getSiteGroups() + .assertThat() + .entriesListCountIs(4) + .and().entriesListContains("id", getId(publicSiteGroups.get(2))) + .and().entriesListContains("role", UserRole.SiteConsumer.name()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin user gets site groups and gets status code OK (200)") + public void getSiteGroupsWithAdminUser() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingSite(publicSite).getSiteGroups() + .assertThat() + .entriesListCountIs(4) + .and().entriesListContains("id", getId(publicSiteGroups.get(0))) + .and().entriesListContains("role", UserRole.SiteManager.name()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site groups call returns status code 401") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteGroups() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSite, UserRole.SiteManager); + restClient.authenticateUser(userModel).withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site members call returns status code 404 if siteId does not exist") + public void checkStatusCodeForNonExistentSiteId() throws Exception + { + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI() + .usingSite("NonExistentSiteId").getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY) + .assertLastError().containsSummary(String.format("Site %s does not exist", "NonExistentSiteId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site groups call returns status code 400 for invalid maxItems") + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(regularUser).withParams("maxItems=0").withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withParams("maxItems=A").withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site groups call returns status code 400 for invalid skipCount ") + public void checkStatusCodeForInvalidSkipCount() throws Exception + { + restClient.authenticateUser(regularUser).withParams("skipCount=A") + .withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.withParams("skipCount=-1") + .withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets public site groups and status code is 200") + public void getPublicSiteGroups() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(regularUser).withCoreAPI().usingSite(publicSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().entriesListCountIs(4).assertThat() + .entriesListContains("id", getId(publicSiteGroups.get(0))) + .and().entriesListContains("id", getId(publicSiteGroups.get(1))) + .and().entriesListContains("id", getId(publicSiteGroups.get(2))) + .and().entriesListContains("id", getId(publicSiteGroups.get(3))) + .and().paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site groups and status code is 200") + public void getModeratedSiteGroups() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(regularUser).withCoreAPI().usingSite(moderatedSite).getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().entriesListCountIs(4).assertThat() + .entriesListContains("id", getId(moderatedSiteGroups.get(0))).and() + .entriesListContains("id", getId(moderatedSiteGroups.get(1))).and() + .entriesListContains("id", getId(moderatedSiteGroups.get(2))).and() + .entriesListContains("id", getId(moderatedSiteGroups.get(3))).and() + .paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site groups with properties parameter applied and status code is 200") + public void getModeratedSiteGroupsUsingPropertiesParameter() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite).usingParams("properties=role,id").getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().entriesListCountIs(4) + .and().entriesListDoesNotContain("person") + .and().entriesListContains("role", UserRole.SiteManager.toString()) + .and().entriesListContains("id", getId(moderatedSiteGroups.get(0))) + .and().entriesListContains("role", UserRole.SiteContributor.toString()) + .and().entriesListContains("id", getId(moderatedSiteGroups.get(1))) + .and().entriesListContains("role", UserRole.SiteCollaborator.toString()) + .and().entriesListContains("id", getId(moderatedSiteGroups.get(2))) + .and().entriesListContains("role", UserRole.SiteConsumer.toString()) + .and().entriesListContains("id", getId(moderatedSiteGroups.get(3))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site groups with skipCount parameter applied") + public void getModeratedSiteGroupsUsingSkipCountParameter() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite).usingParams("skipCount=2").getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().paginationField("count").is("2"); + siteGroups.assertThat().paginationField("skipCount").is("2"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site groups with high skipCount parameter applied") + public void getModeratedSiteGroupsUsingHighSkipCountParameter() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite).usingParams("skipCount=100").getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().paginationField("count").is("0"); + siteGroups.assertThat().paginationField("skipCount").is("100"); + siteGroups.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site groups with maxItems parameter applied and check all pagination fields") + public void getModeratedSiteGroupsUsingMaxItemsParameter() throws Exception + { + RestSiteGroupModelsCollection siteGroups = restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite).usingParams("maxItems=1").getSiteGroups(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteGroups.assertThat().paginationField("count").is("1"); + siteGroups.assertThat().paginationField("hasMoreItems").is("true"); + siteGroups.assertThat().paginationField("maxItems").is("1"); + siteGroups.assertThat().paginationField("totalItems").is("4"); + siteGroups.assertThat().entriesListCountIs(1); + } + + List addGroupToSite(SiteModel siteModel, UserRole ...roles) { + List groups = new ArrayList(); + for (UserRole role: roles) { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(siteModel).addSiteGroup(getId(group), role); + groups.add(group); + } + return groups; + } + + String getId(GroupModel group) { + return "GROUP_" + group.getGroupIdentifier(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/RemoveSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/RemoveSiteGroupTests.java new file mode 100644 index 0000000000..da16419d11 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/RemoveSiteGroupTests.java @@ -0,0 +1,197 @@ +package org.alfresco.rest.sites.groups; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.GroupModel; +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; + +import java.util.ArrayList; +import java.util.List; + +public class RemoveSiteGroupTests extends RestTest +{ + private SiteModel publicSiteModel, privateSiteModel; + private UserModel adminUserModel; + private DataUser.ListUserWithRoles usersWithRoles; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUserModel = dataUser.getAdminUser(); + UserModel siteCreator = dataUser.createRandomTestUser(); + + publicSiteModel = dataSite.usingUser(siteCreator).createPublicRandomSite(); + privateSiteModel = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + addGroupToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify manager can delete site group and gets status code 204, 'No Content'") + public void siteManagerIsAbleToDeleteSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteConsumer).get(0); + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + Utility.sleep(300, 30000, () -> restClient.withCoreAPI().usingSite(publicSiteModel) + .getSiteGroups().assertThat().entriesListDoesNotContain("id", getId(group))); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify collaborator cannot delete site group and gets status code 403, 'Forbidden'") + public void siteCollaboratorIsNotAbleToDeleteSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteConsumer).get(0); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + Utility.sleep(300, 30000, () -> restClient.withCoreAPI() + .usingSite(publicSiteModel).getSiteGroups() + .assertThat().entriesListContains("id", getId(group))); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify contributor cannot delete site group and gets status code 403, 'Forbidden'") + public void siteContributorIsNotAbleToDeleteSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteConsumer).get(0); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + Utility.sleep(300, 30000, () -> restClient.withCoreAPI().usingSite(publicSiteModel) + .getSiteGroups().assertThat().entriesListContains("id", getId(group))); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify consumer cannot delete site member and gets status code 403, 'Forbidden'") + public void siteConsumerIsNotAbleToDeleteSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteConsumer).get(0); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + + Utility.sleep(300, 30000, () -> restClient.withCoreAPI().usingSite(publicSiteModel) + .getSiteGroups().assertThat().entriesListContains("id", getId(group))); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, + TestGroup.SITES }, executionType = ExecutionType.SANITY, description = "Verify that unauthenticated user is not able to delete site group") + public void unauthenticatedUserIsNotAuthorizedToDeleteSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteConsumer).get(0); + + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser).withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify manager can NOT delete site group for an inexistent user and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteInexistentSiteGroup() throws Exception + { + GroupModel inexistentUser = new GroupModel("inexistentUser"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(inexistentUser)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format("An authority was not found for %s", getId(inexistentUser))); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify manager can NOT delete site group for a non site group and gets status code 400, 'Bad Request'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteNotSiteGroup() throws Exception + { + GroupModel nonMember = dataGroup.createRandomGroup(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(nonMember)); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format("Given authority is not a member of the site")); + } + + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that manager can NOT delete site group for an invalid site and gets status code 404, 'Not Found'") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void managerIsNotAbleToDeleteSiteMemberOfInvalidSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + GroupModel testGroupModel = dataGroup.createRandomGroup(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).deleteSiteGroup(getId(testGroupModel)); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "invalidSite")); + } + + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can delete a site group of private site and gets status code 204") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsAbleToDeletePrivateSiteGroup() throws Exception + { + GroupModel group = addGroupToSite(privateSiteModel, UserRole.SiteConsumer).get(0); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin can not delete a site group twice and gets status code 404 for the second attempt") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @Bug(id="ACE-5447") + public void adminIsNotAbleToRemoveSiteGroupTwice() throws Exception + { + GroupModel group = addGroupToSite(publicSiteModel, UserRole.SiteContributor).get(0); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).deleteSiteGroup(getId(group)); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Given authority is not a member of the site"); + } + + List addGroupToSite(SiteModel siteModel, UserRole ...roles) { + List groups = new ArrayList(); + for (UserRole role: roles) { + GroupModel group = dataGroup.createRandomGroup(); + restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingSite(siteModel).addSiteGroup(getId(group), role); + groups.add(group); + } + return groups; + } + + String getId(GroupModel group) { + return "GROUP_" + group.getGroupIdentifier(); + } +} + diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java new file mode 100644 index 0000000000..e143b732d9 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java @@ -0,0 +1,187 @@ +package org.alfresco.rest.sites.groups; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.GroupModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UpdateSiteGroupTests extends RestTest +{ + private UserModel adminUser, siteCreator; + private GroupModel regularGroup; + private SiteModel publicSite; + private DataUser.ListUserWithRoles publicSiteUsers; + private GroupModel groupToBeUpdated; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + siteCreator = dataUser.createRandomTestUser(); + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + publicSiteUsers = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + regularGroup = dataGroup.createRandomGroup(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that collaborator is not able to update site group membership and gets status code FORBIDDEN (403)") + public void collaboratorIsNotAbleToUpdateSiteGroup() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSite).addSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor is not able to update site membership and gets status code FORBIDDEN (403)") + public void contributorIsNotAbleToUpdateSiteGroup() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSite).addSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that consumer is not able to update site group and gets status code FORBIDDEN (403)") + public void consumerIsNotAbleToUpdateSiteGroup() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSite).addSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY); + restClient.assertLastError() + .containsSummary(String.format("The current user does not have permissions to modify the membership details of the site %s.", publicSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify that admin is able to update site member and gets status code OK (200)") + public void adminIsAbleToUpdateSiteGroup() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSite).addSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteCollaborator) + .assertThat().field("id").is(getId(groupToBeUpdated)) + .and().field("role").is(UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify that unauthenticated user is not able to update site member") + + public void unauthenticatedUserIsNotAuthorizedToUpdateSiteGroup() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSite).addSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restClient.withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteCollaborator); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site group request returns status code 404 when nonexistent siteId is used") + public void updateSiteGroupOfNonexistentSite() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + SiteModel deletedSite = dataSite.usingUser(adminUser).createPublicRandomSite(); + dataSite.deleteSite(deletedSite); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(deletedSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, deletedSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when personId is not member of the site") + public void updateNotASiteMember() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("authority is not a member of the site"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when personId does not exist") + public void updateNonexistentSiteMember() throws Exception + { + GroupModel nonexistentUser = new GroupModel("nonexistentUser"); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(nonexistentUser), UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format("An authority was not found for %s", getId(nonexistentUser))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 404 when empty siteId is used") + public void updateSiteMemberUsingEmptySiteId() throws Exception + { + restClient.authenticateUser(adminUser).withCoreAPI().usingSite("").updateSiteGroup(getId(regularGroup), UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 405 when empty personId is used") + public void updateSiteMemberUsingEmptyPersonId() throws Exception + { + GroupModel emptyGroup = new GroupModel(""); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(emptyGroup), UserRole.SiteConsumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format("An authority was not found for %s", getId(emptyGroup))); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if update site member request returns status code 400 when invalid role is used") + public void updateSiteMemberUsingInvalidRole() throws Exception + { + groupToBeUpdated = dataGroup.createRandomGroup(); + restClient.authenticateUser(siteCreator).withCoreAPI(); + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).updateSiteGroup(getId(groupToBeUpdated), UserRole.SiteConsumer); + String json = JsonBodyGenerator.keyValueJson("role","invalidRole"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/group-members/{groupId}", publicSite.getId(), getId(groupToBeUpdated)); + restClient.processModel(RestSiteMemberModel.class, request); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary("authority is not a member of the site"); + } + + String getId(GroupModel group) { + return "GROUP_" + group.getGroupIdentifier(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java index c3b3f5496b..804fd85629 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java @@ -6,6 +6,7 @@ import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.rest.model.RestSiteMemberModelsCollection; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.GroupModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -20,7 +21,7 @@ import org.testng.annotations.Test; */ public class GetSiteMembersTests extends RestTest { - private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2, moderatedSite3; + private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2, moderatedSite3, moderatedSite4; private RestSiteMemberModelsCollection siteMembers; private ListUserWithRoles usersWithRoles, moderatedSiteUsers; private UserModel regularUser, privateSiteConsumer, siteCreator; @@ -38,6 +39,7 @@ public class GetSiteMembersTests extends RestTest moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); moderatedSite2 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); moderatedSite3 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + moderatedSite4 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); dataUser.addUserToSite(privateSiteConsumer, moderatedSite3, UserRole.SiteConsumer); @@ -351,4 +353,32 @@ public class GetSiteMembersTests extends RestTest .and().entriesListContains("role", UserRole.SiteManager.toString()) .and().entriesListContains("id", siteCreator.getUsername()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if isMemberOfGroup if user part of the group") + public void verifyIsMemberOfGroupProps() throws Exception + { + GroupModel firstGroup = dataGroup.createRandomGroup(); + UserModel user = dataUser.createRandomTestUser(); + dataGroup.addListOfUsersToGroup(firstGroup, user); + + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite4).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(1); + + restClient.withCoreAPI().usingSite(moderatedSite4).addSiteGroup("GROUP_" + firstGroup.getGroupIdentifier(), UserRole.SiteCollaborator); + + siteMembers = restClient.withCoreAPI().usingSite(moderatedSite4).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(2); + siteMembers.getEntryByIndex(0).assertThat().field("isMemberOfGroup").isNotNull(); + siteMembers.getEntryByIndex(1).assertThat().field("isMemberOfGroup").isNotNull(); + + siteMembers = restClient.withCoreAPI().usingSite(moderatedSite4).usingParams("where=(isMemberOfGroup=false)").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(1); + siteMembers.getEntries().get(0).assertThat().field("isMemberOfGroup").is(false); + } }