mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-6129 Use roles from UserRoles.
This commit is contained in:
@@ -24,8 +24,13 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.model.user;
|
package org.alfresco.rest.rm.community.model.user;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for RM user roles
|
* Constants for RM user roles
|
||||||
*
|
*
|
||||||
@@ -39,4 +44,8 @@ public class UserRoles
|
|||||||
public static final String ROLE_RM_POWER_USER = "PowerUser";
|
public static final String ROLE_RM_POWER_USER = "PowerUser";
|
||||||
public static final String ROLE_RM_SECURITY_OFFICER = "SecurityOfficer";
|
public static final String ROLE_RM_SECURITY_OFFICER = "SecurityOfficer";
|
||||||
public static final String ROLE_RM_USER = "User";
|
public static final String ROLE_RM_USER = "User";
|
||||||
|
|
||||||
|
/** The ids of the default RM roles. */
|
||||||
|
public static final Set<String> RM_ROLES = newHashSet(ROLE_RM_ADMIN, ROLE_RM_MANAGER, ROLE_RM_POWER_USER,
|
||||||
|
ROLE_RM_SECURITY_OFFICER, ROLE_RM_USER);
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,8 @@ import static java.util.Collections.singleton;
|
|||||||
|
|
||||||
import static com.google.common.collect.Sets.newHashSet;
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
|
|
||||||
|
import static org.alfresco.rest.rm.community.model.user.UserRoles.RM_ROLES;
|
||||||
|
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -50,17 +52,12 @@ import org.testng.annotations.Test;
|
|||||||
*/
|
*/
|
||||||
public class RMRolesTests extends BaseRMRestTest
|
public class RMRolesTests extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
/** The name of the RM user role. */
|
|
||||||
private static final String RM_USER = "User";
|
|
||||||
/** The id of the view records capability. */
|
/** The id of the view records capability. */
|
||||||
public static final String VIEW_RECORDS_CAP = "ViewRecords";
|
public static final String VIEW_RECORDS_CAP = "ViewRecords";
|
||||||
/** The id of the declare records capability. */
|
/** The id of the declare records capability. */
|
||||||
public static final String DECLARE_RECORDS_CAP = "DeclareRecords";
|
public static final String DECLARE_RECORDS_CAP = "DeclareRecords";
|
||||||
/** A list of capabilities. */
|
/** A list of capabilities. */
|
||||||
private static final java.util.HashSet<String> CAPABILITIES = newHashSet(VIEW_RECORDS_CAP, DECLARE_RECORDS_CAP);
|
private static final java.util.HashSet<String> CAPABILITIES = newHashSet(VIEW_RECORDS_CAP, DECLARE_RECORDS_CAP);
|
||||||
/** The names of the expected default RM roles. */
|
|
||||||
private static final Set<String> ROLES = newHashSet("Administrator", "RecordsManager", "PowerUser",
|
|
||||||
"SecurityOfficer", RM_USER);
|
|
||||||
/** The API for managing RM roles and capabilities. */
|
/** The API for managing RM roles and capabilities. */
|
||||||
@Autowired
|
@Autowired
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||||
@@ -71,7 +68,7 @@ public class RMRolesTests extends BaseRMRestTest
|
|||||||
{
|
{
|
||||||
Set<String> configuredRoles = rmRolesAndActionsAPI
|
Set<String> configuredRoles = rmRolesAndActionsAPI
|
||||||
.getConfiguredRoles(getAdminUser().getUsername(), getAdminUser().getPassword());
|
.getConfiguredRoles(getAdminUser().getUsername(), getAdminUser().getPassword());
|
||||||
ROLES.forEach(role -> assertTrue("Could not found role " + role, configuredRoles.contains(role)));
|
RM_ROLES.forEach(role -> assertTrue("Could not found role " + role, configuredRoles.contains(role)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check that the RM user has the capability to view and declare records. */
|
/** Check that the RM user has the capability to view and declare records. */
|
||||||
@@ -79,7 +76,7 @@ public class RMRolesTests extends BaseRMRestTest
|
|||||||
public void checkCapabilitiesForUser()
|
public void checkCapabilitiesForUser()
|
||||||
{
|
{
|
||||||
Set<String> capabilities = rmRolesAndActionsAPI
|
Set<String> capabilities = rmRolesAndActionsAPI
|
||||||
.getCapabilitiesForRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_USER);
|
.getCapabilitiesForRole(getAdminUser().getUsername(), getAdminUser().getPassword(), ROLE_RM_USER);
|
||||||
assertEquals("Unexpected capabilities found for RM User.", capabilities, CAPABILITIES);
|
assertEquals("Unexpected capabilities found for RM User.", capabilities, CAPABILITIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user