diff --git a/src/test/java/org/alfresco/rest/fileplancomponents/FilePlanTests.java b/src/test/java/org/alfresco/rest/fileplancomponents/FilePlanTests.java index 4969e5ebcd..45bbc41c5b 100644 --- a/src/test/java/org/alfresco/rest/fileplancomponents/FilePlanTests.java +++ b/src/test/java/org/alfresco/rest/fileplancomponents/FilePlanTests.java @@ -174,7 +174,7 @@ public class FilePlanTests extends BaseRestTest /** * Given that a file plan exists * When I ask the API to delete the file plan - * Then the 405 response code is returned. (see https://docs.google.com/document/d/1l4tcAnZotJR6qTHI4LFi62dy_i5Zuk-9ImDXDHpD_rA/edit?ts=578f7b64# page 20 and36) + * Then the 403 response code is returned. */ @Test ( @@ -195,7 +195,7 @@ public class FilePlanTests extends BaseRestTest /** * Given that RM site exists * When I ask to create the file plan - * Then the 405 response code is returned. (see https://docs.google.com/document/d/1l4tcAnZotJR6qTHI4LFi62dy_i5Zuk-9ImDXDHpD_rA/edit?ts=578f7b64# page 20) + * Then the 403 response code is returned. */ @Test ( diff --git a/src/test/java/org/alfresco/rest/site/RMSiteTests.java b/src/test/java/org/alfresco/rest/site/RMSiteTests.java index 4ebd4a9589..c503a96758 100644 --- a/src/test/java/org/alfresco/rest/site/RMSiteTests.java +++ b/src/test/java/org/alfresco/rest/site/RMSiteTests.java @@ -20,13 +20,16 @@ import static org.alfresco.rest.TestData.ANOTHER_ADMIN; import static org.alfresco.rest.TestData.DEFAULT_EMAIL; import static org.alfresco.rest.TestData.DEFAULT_PASSWORD; import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; +import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.OK; import static org.springframework.social.alfresco.api.entities.Site.Visibility.PUBLIC; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import com.google.gson.JsonObject; @@ -35,7 +38,10 @@ import org.alfresco.rest.BaseRestTest; import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.fileplancomponents.RecordCategoryTest; import org.alfresco.rest.model.site.RMSite; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.report.Bug; import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; @@ -53,9 +59,17 @@ public class RMSiteTests extends BaseRestTest { @Autowired private UserService userService; + + + /** + * Given that RM module is installed + * When I want to create the rm site with specific title, description and compliance + * Then the RM site is created + * + */ @Test ( - description = "Create RM site as admin user with Standard Compliance" + description = "Create RM site as admin user with Standard Compliance" ) public void createRMSiteAsAdminUser() throws Exception { @@ -84,11 +98,17 @@ public class RMSiteTests extends BaseRestTest assertEquals(rmSite.getDescription(), RM_DESCRIPTION); assertEquals(rmSite.getCompliance(), STANDARD); assertEquals(rmSite.getVisibility(), PUBLIC); + assertEquals(rmSite.getRole(), UserRole.SiteManager.toString()); } + /** + * Given that RM site exists + * When I want to create the RM site + * Then the response code 409 (Site with the given identifier already exists) is return + */ @Test ( - description = "Create RM site when site already exist with admin user" + description = "Create RM site when site already exist with admin user" ) public void createRMSiteWhenSiteExists() throws Exception { @@ -114,9 +134,14 @@ public class RMSiteTests extends BaseRestTest restWrapper.assertStatusCodeIs(CONFLICT); } + /** + * Given that RM site exists + * When I want to delete the RM site + * Then RM site is successfully deleted + */ @Test ( - description = "Delete RM site as admin user" + description = "Delete RM site as admin user" ) public void deleteRMSite() throws Exception { @@ -129,9 +154,14 @@ public class RMSiteTests extends BaseRestTest restWrapper.assertStatusCodeIs(NO_CONTENT); } + /** + * Given that RM site exists + * When I GET the retrieve the RM site details + * Then RM site details are returned + */ @Test ( - description = "GET RM site as admin user" + description = "GET the RM site as admin user" ) public void getRMSite() throws Exception { @@ -141,8 +171,9 @@ public class RMSiteTests extends BaseRestTest RMSite rmSite = rmSiteAPI.getSite(); if (!siteRMExist()) { - // Verify the status code + // Verify the status code when rm site doesn't exist restWrapper.assertStatusCodeIs(NOT_FOUND); + createRMSiteIfNotExists(); } else { @@ -155,10 +186,16 @@ public class RMSiteTests extends BaseRestTest } } + /** + * Given that an user is created and RM site doesn't exist + * When the user wants to create a RM site with DOD compliance + * Then RM site is created + */ @Test ( - description = "Create RM site as an admin user created with DOD compliance" + description = "Create RM site with DOD compliance as an another admin user" ) + @Bug (id="RM-4289") public void createRMSiteAsAnotherAdminUser() throws Exception { rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); @@ -196,5 +233,84 @@ public class RMSiteTests extends BaseRestTest assertEquals(rmSite.getDescription(), RM_DESCRIPTION); assertEquals(rmSite.getCompliance(), DOD5015); assertEquals(rmSite.getVisibility(), PUBLIC); + assertEquals(rmSite.getRole(), UserRole.SiteManager.toString()); + } + + /** + * Given that RM site exist + * When a new created user want to update the RM site details (title or description) + * Then 403 response status code is return + * When the admin user wants to update the RM site details (title or description) + * Then RM site details are updated + */ + @Test + public void updateRMSiteDetailsAsAdmin()throws Exception + { + String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric(); + String NEW_DESCRIPTION=RM_DESCRIPTION+ RandomData.getRandomAlphanumeric(); + + // Build the RM site properties + JsonObject rmSiteToUpdate = buildObject() + .add(TITLE, NEW_TITLE) + .add(DESCRIPTION, NEW_DESCRIPTION) + .getJson(); + + rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + if (!siteRMExist()) + { + createRMSiteIfNotExists(); + } + + rmSiteAPI.usingRestWrapper().disconnect(); + UserModel nonRMuser = dataUser.createRandomTestUser("testUser"); + rmSiteAPI.usingRestWrapper().authenticateUser(nonRMuser); + + // Create the RM site + RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); + + // Verify the status code + rmSiteAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + + rmSiteAPI.usingRestWrapper().disconnect(); + rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // Update the RM Site + rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); + + // Verify the response status code + rmSiteAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // Verify the returned file plan component + assertEquals(rmSite.getId(), RM_ID); + assertEquals(rmSite.getTitle(), NEW_TITLE); + assertEquals(rmSite.getDescription(), NEW_DESCRIPTION); + assertNotNull(rmSite.getCompliance()); + assertEquals(rmSite.getVisibility(), PUBLIC); + + } + + + /** + * Given that RM site exist + * When the admin user wants to update the RM site compliance + * Then RM site compliance is not updated + */ + @Test + public void updateRMSiteComplianceAsAdmin() throws Exception + { + rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + if (!siteRMExist()) + { + createRMSiteIfNotExists(); + } + // Build the RM site properties + JsonObject rmSiteToUpdate = buildObject() + .add(COMPLIANCE, DOD5015.toString()) + .getJson(); + // Update the RM site + RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); + + // Verify the response status code + rmSiteAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST); } }