use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class PurRepositorySecurityManagerTest method createRole_NormalizesInfo_FailsIfStillBreaches.
@Test(expected = KettleException.class)
public void createRole_NormalizesInfo_FailsIfStillBreaches() throws Exception {
IRole info = new EERoleInfo(" ", "");
manager.createRole(info);
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UserRoleDelegateTest method createRole_CreatesSuccessfully_WhenNameIsUnique.
@Test
public void createRole_CreatesSuccessfully_WhenNameIsUnique() throws Exception {
final String name = "role";
delegate.createRole(new EERoleInfo(name));
verify(roleWebService).createRole(any(ProxyPentahoRole.class));
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UserRoleHelperTest method mockSecurityManager.
private static IRoleSupportSecurityManager mockSecurityManager(final boolean eeUsers) throws KettleException {
IRoleSupportSecurityManager manager = mock(IRoleSupportSecurityManager.class);
when(manager.constructUser()).thenAnswer(new Answer<IUser>() {
@Override
public IUser answer(InvocationOnMock invocation) throws Throwable {
return eeUsers ? new EEUserInfo() : new UserInfo();
}
});
when(manager.constructRole()).thenAnswer(new Answer<IRole>() {
@Override
public IRole answer(InvocationOnMock invocation) throws Throwable {
return new EERoleInfo();
}
});
return manager;
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UIEESecurityTest method testUpdateRole.
@Test
public void testUpdateRole() throws Exception {
try {
IUIRole roleToAdd = new UIRepositoryRole(new EERoleInfo());
roleToAdd.setName("newrole");
roleToAdd.setDescription("new description");
Set<IUIUser> usersToAssign = new HashSet<IUIUser>();
usersToAssign.add(new UIRepositoryUser(suzyUser));
usersToAssign.add(new UIRepositoryUser(tiffanyUser));
usersToAssign.add(new UIRepositoryUser(joeUser));
roleToAdd.setUsers(usersToAssign);
security.addRole(roleToAdd);
security.setSelectedRole(findRole("newrole"));
IUIRole selectedRole = security.getSelectedRole();
selectedRole.setDescription("new description 123");
selectedRole.addUser(new UIRepositoryUser(patUser));
selectedRole.removeUser(new UIRepositoryUser(suzyUser));
selectedRole.removeUser(new UIRepositoryUser(tiffanyUser));
security.updateRole(selectedRole, usersToAssign);
// $NON-NLS-1$
assertEquals(selectedRole.getDescription(), "new description 123");
assertEquals(security.getSelectedRole(), selectedRole);
assertEquals(security.getRoleList().size(), 9);
} catch (Exception e) {
Assert.fail();
}
}
Aggregations