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
|
* Assign RM role to user
|
||||||
|
*
|
||||||
* @param userName User's username
|
* @param userName User's username
|
||||||
* @param userRole User's RM role, one of {@link UserRoles} roles
|
* @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
|
// override v1 baseURI and basePath
|
||||||
RequestSpecification spec = new RequestSpecBuilder()
|
RequestSpecification spec = new RequestSpecBuilder()
|
||||||
.setBaseUri(client.getApiUrl())
|
.setBaseUri(client.getApiUrl())
|
||||||
.setBasePath("/")
|
.setBasePath("/")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = given()
|
Response response = given()
|
||||||
.spec(spec)
|
.spec(spec)
|
||||||
.log().all()
|
.log().all()
|
||||||
.pathParam("role", userRole)
|
.pathParam("role", userRole)
|
||||||
.pathParam("authority", userName)
|
.pathParam("authority", userName)
|
||||||
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
|
.param("alf_ticket", client.getAlfTicket(adminUser.getUsername(),
|
||||||
adminUser.getPassword()))
|
adminUser.getPassword()))
|
||||||
.when()
|
.when()
|
||||||
.post("/rm/roles/{role}/authorities/{authority}")
|
.post("/rm/roles/{role}/authorities/{authority}")
|
||||||
.prettyPeek()
|
.prettyPeek()
|
||||||
.andReturn();
|
.andReturn();
|
||||||
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,34 +129,76 @@ public class RMUserAPI extends RMModelRequest
|
|||||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||||
|
|
||||||
JsonObject bodyJson = buildObject()
|
JsonObject bodyJson = buildObject()
|
||||||
.addArray("permissions")
|
.addArray("permissions")
|
||||||
.addObject()
|
.addObject()
|
||||||
.add("authority", user.getUsername())
|
.add("authority", user.getUsername())
|
||||||
.add("role", permission.permissionId)
|
.add("role", permission.permissionId)
|
||||||
.end()
|
.end()
|
||||||
.getJson();
|
.getJson();
|
||||||
|
|
||||||
// override v1 baseURI and basePath
|
// override v1 baseURI and basePath
|
||||||
RequestSpecification spec = new RequestSpecBuilder()
|
RequestSpecification spec = new RequestSpecBuilder()
|
||||||
.setBaseUri(client.getApiUrl())
|
.setBaseUri(client.getApiUrl())
|
||||||
.setBasePath("/")
|
.setBasePath("/")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// execute an "old-style" API call
|
// execute an "old-style" API call
|
||||||
Response response = given()
|
Response response = given()
|
||||||
.spec(spec)
|
.spec(spec)
|
||||||
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
.auth().basic(adminUser.getUsername(), adminUser.getPassword())
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body(bodyJson.toString())
|
.body(bodyJson.toString())
|
||||||
.pathParam("nodeId", filePlanComponentId)
|
.pathParam("nodeId", filePlanComponentId)
|
||||||
.log().all()
|
.log().all()
|
||||||
.when()
|
.when()
|
||||||
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
.post("/node/workspace/SpacesStore/{nodeId}/rmpermissions")
|
||||||
.prettyPeek()
|
.prettyPeek()
|
||||||
.andReturn();
|
.andReturn();
|
||||||
getRmRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
|
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
|
* 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)
|
public boolean createUser(String userName, String userPassword, String userEmail)
|
||||||
{
|
{
|
||||||
UserModel adminUser = getRmRestWrapper().getTestUser();
|
UserModel adminUser = getRmRestWrapper().getTestUser();
|
||||||
AlfrescoHttpClient client = getAlfrescoHttpClient();
|
final AlfrescoHttpClient client = getAlfrescoHttpClient();
|
||||||
|
|
||||||
JsonObject body = buildObject()
|
JsonObject body = buildObject()
|
||||||
.add("userName", userName)
|
.add("userName", userName)
|
||||||
@@ -177,7 +220,7 @@ public class RMUserAPI extends RMModelRequest
|
|||||||
.add("email", userEmail)
|
.add("email", userEmail)
|
||||||
.getJson();
|
.getJson();
|
||||||
|
|
||||||
RequestSpecification spec = new RequestSpecBuilder()
|
final RequestSpecification spec = new RequestSpecBuilder()
|
||||||
.setBaseUri(client.getApiUrl())
|
.setBaseUri(client.getApiUrl())
|
||||||
.setBasePath("/")
|
.setBasePath("/")
|
||||||
.setAuth(basic(adminUser.getUsername(), adminUser.getPassword()))
|
.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 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 MOVE_ACTIONS_API = "action/rm-move-to/site/rm/documentLibrary/{0}";
|
||||||
private static final String CREATE_HOLDS_API = "{0}type/rma:hold/formprocessor";
|
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";
|
private static final String RM_HOLDS_API = "{0}rma/holds";
|
||||||
|
|
||||||
/** http client factory */
|
/** http client factory */
|
||||||
@@ -218,8 +218,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
*/
|
*/
|
||||||
public void assignRoleToUser(String adminUser, String adminPassword, String userName, String role)
|
public void assignRoleToUser(String adminUser, String adminPassword, String userName, String role)
|
||||||
{
|
{
|
||||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
final AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||||
String reqURL = MessageFormat.format(
|
final String reqURL = MessageFormat.format(
|
||||||
RM_ROLES_AUTHORITIES,
|
RM_ROLES_AUTHORITIES,
|
||||||
client.getApiUrl(),
|
client.getApiUrl(),
|
||||||
role,
|
role,
|
||||||
|
@@ -86,7 +86,7 @@ public class RoleService
|
|||||||
*/
|
*/
|
||||||
public void addCapabilitiesToRole(UserRoles role, Set<String> capabilities)
|
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);
|
roleCapabilities.addAll(capabilities);
|
||||||
|
|
||||||
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
||||||
@@ -101,7 +101,7 @@ public class RoleService
|
|||||||
*/
|
*/
|
||||||
public void removeCapabilitiesFromRole(UserRoles role, Set<String> capabilities)
|
public void removeCapabilitiesFromRole(UserRoles role, Set<String> capabilities)
|
||||||
{
|
{
|
||||||
Set<String> roleCapabilities = getRoleCapabilities(role.roleId);
|
final Set<String> roleCapabilities = getRoleCapabilities(role.roleId);
|
||||||
roleCapabilities.removeAll(capabilities);
|
roleCapabilities.removeAll(capabilities);
|
||||||
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
getRmRolesAndActionsAPI().updateRole(getDataUser().getAdminUser().getUsername(), getDataUser().getAdminUser().getPassword(),
|
||||||
role.roleId, role.displayName, roleCapabilities);
|
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.UnfiledContainer;
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
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.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.RMSiteAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
@@ -613,6 +614,37 @@ public class BaseRMRestTest extends RestTest
|
|||||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
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
|
* Returns search results for the given search term
|
||||||
*
|
*
|
||||||
@@ -783,7 +815,6 @@ public class BaseRMRestTest extends RestTest
|
|||||||
documentLibrary.setNodeRef(nodes.get(0).onModel().getId());
|
documentLibrary.setNodeRef(nodes.get(0).onModel().getId());
|
||||||
return documentLibrary;
|
return documentLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given file has record aspect
|
* Checks if the given file has record aspect
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user