use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testDeleteRoles.
@Test
public void testDeleteRoles() throws Exception {
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
rolesObj[0] = new ProxyPentahoRole("testRole1");
try {
service.deleteRoles(rolesObj);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
service.deleteRoles(rolesObj);
Assert.assertEquals(1, roles.size());
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToPentahoProxyRoles.
public static ProxyPentahoRole[] convertToPentahoProxyRoles(Set<IRole> roles) {
ProxyPentahoRole[] proxyRoles = new ProxyPentahoRole[roles.size()];
int i = 0;
for (IRole role : roles) {
proxyRoles[i++] = convertToPentahoProxyRole(role);
}
return proxyRoles;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToListFromProxyPentahoRoles.
public static List<IRole> convertToListFromProxyPentahoRoles(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
List<IRole> roleList = new ArrayList<IRole>();
List<ProxyPentahoRole> roles = info.getRoles();
List<UserToRoleAssignment> assignments = info.getAssignments();
for (ProxyPentahoRole role : roles) {
roleList.add(convertFromProxyPentahoRole(role, assignments, rsm));
}
return roleList;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-kettle by pentaho.
the class UserRoleHelper method convertToSetFromProxyPentahoRoles.
private static Set<IRole> convertToSetFromProxyPentahoRoles(ProxyPentahoRole[] roles, IRoleSupportSecurityManager rsm) {
Set<IRole> roleSet = new HashSet<IRole>();
for (ProxyPentahoRole role : roles) {
IRole roleInfo = null;
try {
roleInfo = rsm.constructRole();
} catch (KettleException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
roleInfo.setDescription(role.getDescription());
roleInfo.setName(role.getName());
roleSet.add(roleInfo);
}
return roleSet;
}
use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testCreateDuplicateRole.
@Test
public void testCreateDuplicateRole() throws UserRoleException {
UserRoleDaoMock userRoleDao = Mockito.mock(UserRoleDaoMock.class);
Mockito.doThrow(new AlreadyExistsException("That role already exists.")).when(userRoleDao).createRole(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
UserRoleWebService userRoleWebService = new UserRoleWebService() {
@Override
protected IUserRoleDao getDao() throws UserRoleException {
return userRoleDao;
}
};
ProxyPentahoRole proxyPentahoRole = new ProxyPentahoRole("testrole");
try {
userRoleWebService.createRole(proxyPentahoRole);
Assert.fail();
} catch (AlreadyExistsException e) {
Assert.assertEquals(0, e.getStackTrace().length);
}
}
Aggregations