use of org.pentaho.platform.web.http.api.resources.LogicalRoleAssignments in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testSetLogicalRoles.
@Test
public void testSetLogicalRoles() {
String roleName = "testRole";
ArrayList<String> roleList = new ArrayList<>();
roleList.add("org.pentaho.repository.read");
roleList.add("org.pentaho.repository.create");
LogicalRoleAssignment roleAssignment = mock(LogicalRoleAssignment.class);
when(roleAssignment.getRoleName()).thenReturn(roleName);
when(roleAssignment.getLogicalRoles()).thenReturn(roleList);
ArrayList<LogicalRoleAssignment> roles = new ArrayList<>();
roles.add(roleAssignment);
LogicalRoleAssignments roleAssignments = mock(LogicalRoleAssignments.class);
when(roleAssignments.getAssignments()).thenReturn(roles);
setupMockSessionUser(SESSION_USER_NAME, true);
IRoleAuthorizationPolicyRoleBindingDao roleBindingDao = mock(IRoleAuthorizationPolicyRoleBindingDao.class);
PentahoSystem.registerObject(roleBindingDao);
userRoleService.setLogicalRoles(roleAssignments);
verify(roleBindingDao).setRoleBindings(roleName, roleList);
}
use of org.pentaho.platform.web.http.api.resources.LogicalRoleAssignments in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testSetLogicalRolesSecurityException.
@Test(expected = SecurityException.class)
public void testSetLogicalRolesSecurityException() {
LogicalRoleAssignments roleAssignments = mock(LogicalRoleAssignments.class);
setupMockSessionUser(SESSION_USER_NAME, false);
userRoleService.setLogicalRoles(roleAssignments);
}
Aggregations