mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'remotes/origin/release/V3.1' into merge/RM-6577_MergeIERMTests
This commit is contained in:
@@ -84,6 +84,7 @@ public class RMUserAPI extends RMModelRequest
|
||||
|
||||
/**
|
||||
* Assign RM role to user
|
||||
*
|
||||
* @param userName User's username
|
||||
* @param userRole User's RM role, one of {@link UserRoles} roles
|
||||
*/
|
||||
@@ -96,21 +97,21 @@ public class RMUserAPI extends RMModelRequest
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.log().all()
|
||||
.pathParam("role", userRole)
|
||||
.pathParam("authority", userName)
|
||||
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
|
||||
adminUser.getPassword()))
|
||||
.when()
|
||||
.post("/rm/roles/{role}/authorities/{authority}")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
.spec(spec)
|
||||
.log().all()
|
||||
.pathParam("role", userRole)
|
||||
.pathParam("authority", userName)
|
||||
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
|
||||
adminUser.getPassword()))
|
||||
.when()
|
||||
.post("/rm/roles/{role}/authorities/{authority}")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
@@ -128,34 +129,76 @@ public class RMUserAPI extends RMModelRequest
|
||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
.addArray("permissions")
|
||||
.addObject()
|
||||
.add("authority", user.getUsername())
|
||||
.add("role", permission.permissionId)
|
||||
.end()
|
||||
.getJson();
|
||||
.add("authority", user.getUsername())
|
||||
.add("role", permission.permissionId)
|
||||
.end()
|
||||
.getJson();
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
// execute an "old-style" API call
|
||||
Response response = given()
|
||||
.spec(spec)
|
||||
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", filePlanComponentId)
|
||||
.log().all()
|
||||
.when()
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
.spec(spec)
|
||||
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", filePlanComponentId)
|
||||
.log().all()
|
||||
.when()
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set permission inheritance on a file plan component
|
||||
*
|
||||
* @param filePlanComponentId The id of the file plan component on which inherited permission should be set
|
||||
* @param isInherited true if the permission is inherited
|
||||
* false if the permission inheritance is disabled
|
||||
*/
|
||||
public void setUserPermissionInheritance(String filePlanComponentId, Boolean isInherited)
|
||||
{
|
||||
final UserModel adminUser = getRmRestWrapper().getTestUser();
|
||||
|
||||
// get an "old-style" REST API client
|
||||
final AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
final JsonObject bodyJson = buildObject()
|
||||
.addArray("permissions")
|
||||
.end()
|
||||
.add("isInherited", isInherited)
|
||||
.getJson();
|
||||
|
||||
// override v1 baseURI and basePath
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.build();
|
||||
|
||||
// execute an "old-style" API call
|
||||
final Response response = given()
|
||||
.spec(spec)
|
||||
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
||||
.contentType(ContentType.JSON)
|
||||
.body(bodyJson.toString())
|
||||
.pathParam("nodeId", filePlanComponentId)
|
||||
.log().all()
|
||||
.when()
|
||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||
.prettyPeek()
|
||||
.andReturn();
|
||||
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a user with the given name using the old APIs
|
||||
*
|
||||
@@ -167,7 +210,7 @@ public class RMUserAPI extends RMModelRequest
|
||||
public boolean createUser(String userName, String userPassword, String userEmail)
|
||||
{
|
||||
UserModel adminUser = getRmRestWrapper().getTestUser();
|
||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
final AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||
|
||||
JsonObject body = buildObject()
|
||||
.add("userName", userName)
|
||||
@@ -177,7 +220,7 @@ public class RMUserAPI extends RMModelRequest
|
||||
.add("email", userEmail)
|
||||
.getJson();
|
||||
|
||||
RequestSpecification spec = new RequestSpecBuilder()
|
||||
final RequestSpecification spec = new RequestSpecBuilder()
|
||||
.setBaseUri(client.getApiUrl())
|
||||
.setBasePath("/")
|
||||
.setAuth(basic(adminUser.getUsername(), adminUser.getPassword()))
|
||||
|
@@ -86,7 +86,7 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RMRolesAndActionsAPI.class);
|
||||
private static final String MOVE_ACTIONS_API = "action/rm-move-to/site/rm/documentLibrary/{0}";
|
||||
private static final String CREATE_HOLDS_API = "{0}type/rma:hold/formprocessor";
|
||||
/** The URI to view the configured roles and capabilities. */
|
||||
/** The URI to add items to hold.*/
|
||||
private static final String RM_HOLDS_API = "{0}rma/holds";
|
||||
|
||||
/** http client factory */
|
||||
@@ -218,8 +218,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
||||
*/
|
||||
public void assignRoleToUser(String adminUser, String adminPassword, String userName, String role)
|
||||
{
|
||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
String reqURL = MessageFormat.format(
|
||||
final AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||
final String reqURL = MessageFormat.format(
|
||||
RM_ROLES_AUTHORITIES,
|
||||
client.getApiUrl(),
|
||||
role,
|
||||
|
@@ -86,7 +86,7 @@ public class RoleService
|
||||
*/
|
||||
public void addCapabilitiesToRole(UserRoles role, Set<String> capabilities)
|
||||
{
|
||||
Set<String> roleCapabilities = new HashSet<>(getRoleCapabilities(role.roleId));
|
||||
final Set<String> roleCapabilities = new HashSet<>(getRoleCapabilities(role.roleId));
|
||||
roleCapabilities.addAll(capabilities);
|
||||
|
||||
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
||||
@@ -101,7 +101,7 @@ public class RoleService
|
||||
*/
|
||||
public void removeCapabilitiesFromRole(UserRoles role, Set<String> capabilities)
|
||||
{
|
||||
Set<String> roleCapabilities = getRoleCapabilities(role.roleId);
|
||||
final Set<String> roleCapabilities = getRoleCapabilities(role.roleId);
|
||||
roleCapabilities.removeAll(capabilities);
|
||||
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
||||
role.roleId, role.displayName, roleCapabilities);
|
||||
|
@@ -73,6 +73,7 @@ import org.alfresco.rest.rm.community.model.transfercontainer.TransferContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
@@ -590,9 +591,9 @@ public class BaseRMRestTest extends RestTest
|
||||
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
|
||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a record
|
||||
* Delete a record
|
||||
*
|
||||
* @param recordId the id of the record to delete
|
||||
*/
|
||||
@@ -613,6 +614,37 @@ public class BaseRMRestTest extends RestTest
|
||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a test user with rm role
|
||||
*
|
||||
* @param userRole the rm role
|
||||
* @return the created user model
|
||||
*/
|
||||
protected UserModel createUserWithRMRole(String userRole)
|
||||
{
|
||||
UserModel rmUser = getDataUser().createRandomTestUser();
|
||||
getRestAPIFactory().getRMUserAPI().assignRoleToUser(rmUser.getUsername(), userRole);
|
||||
assertStatusCode(OK);
|
||||
return rmUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a test user with rm role and permissions over the record category
|
||||
*
|
||||
* @param userRole the rm role
|
||||
* @param userPermission the permissions over the record category
|
||||
* @param recordCategory the category on which user has permissions
|
||||
* @return the created user model
|
||||
*/
|
||||
protected UserModel createUserWithRMRoleAndCategoryPermission(String userRole, RecordCategory recordCategory,
|
||||
UserPermissions userPermission)
|
||||
{
|
||||
UserModel rmUser = createUserWithRMRole(userRole);
|
||||
getRestAPIFactory().getRMUserAPI().addUserPermission(recordCategory.getId(), rmUser, userPermission);
|
||||
assertStatusCode(OK);
|
||||
return rmUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns search results for the given search term
|
||||
*
|
||||
@@ -666,7 +698,7 @@ public class BaseRMRestTest extends RestTest
|
||||
|
||||
/**
|
||||
* Returns the list of node names returned by search results for the given search term
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* @param term
|
||||
* @param sortby
|
||||
@@ -715,7 +747,7 @@ public class BaseRMRestTest extends RestTest
|
||||
|
||||
/**
|
||||
* Returns the property value for the given property name and nodeRef of the search results
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
* @param term
|
||||
* @param nodeRef
|
||||
@@ -783,7 +815,6 @@ public class BaseRMRestTest extends RestTest
|
||||
documentLibrary.setNodeRef(nodes.get(0).onModel().getId());
|
||||
return documentLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given file has record aspect
|
||||
*
|
||||
|
Reference in New Issue
Block a user