Search in sources :

Example 1 with LogicalRoleAssignments

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);
}
Also used : IRoleAuthorizationPolicyRoleBindingDao(org.pentaho.platform.security.policy.rolebased.IRoleAuthorizationPolicyRoleBindingDao) LogicalRoleAssignments(org.pentaho.platform.web.http.api.resources.LogicalRoleAssignments) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) LogicalRoleAssignment(org.pentaho.platform.web.http.api.resources.LogicalRoleAssignment) Test(org.junit.Test)

Example 2 with LogicalRoleAssignments

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);
}
Also used : LogicalRoleAssignments(org.pentaho.platform.web.http.api.resources.LogicalRoleAssignments) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 LogicalRoleAssignments (org.pentaho.platform.web.http.api.resources.LogicalRoleAssignments)2 ArrayList (java.util.ArrayList)1 Matchers.anyString (org.mockito.Matchers.anyString)1 IRoleAuthorizationPolicyRoleBindingDao (org.pentaho.platform.security.policy.rolebased.IRoleAuthorizationPolicyRoleBindingDao)1 LogicalRoleAssignment (org.pentaho.platform.web.http.api.resources.LogicalRoleAssignment)1