use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole in project pentaho-kettle by pentaho.
the class UISecurityRoleTest method testAddRole.
@Test
public void testAddRole() throws Exception {
try {
UISecurityRole role = new UISecurityRole();
List<IUIUser> rusers = new ArrayList<IUIUser>();
for (UserInfo userInfo : users) {
rusers.add(new UIEERepositoryUser(userInfo));
}
role.setAvailableUsers(rusers);
role.setMode(Mode.ADD);
role.setName("newrole");
role.setDescription("new description");
List<Object> usersToAssign = new ArrayList<Object>();
usersToAssign.add(new UIRepositoryUser(suzyUser));
usersToAssign.add(new UIRepositoryUser(tiffanyUser));
usersToAssign.add(new UIRepositoryUser(joeUser));
role.assignUsers(usersToAssign);
// Should have exactly 7 roles
assertEquals(role.getMode(), Mode.ADD);
// $NON-NLS-1$
assertEquals(role.getName(), "newrole");
// $NON-NLS-1$
assertEquals(role.getDescription(), "new description");
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(joeUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(tiffanyUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(suzyUser)));
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole in project pentaho-kettle by pentaho.
the class UISecurityRoleTest method testEditRole.
@Test
public void testEditRole() throws Exception {
try {
UISecurityRole role = new UISecurityRole();
List<IUIUser> rusers = new ArrayList<IUIUser>();
for (UserInfo userInfo : users) {
rusers.add(new UIEERepositoryUser(userInfo));
}
role.setRole(new UIRepositoryRole(adminRole), rusers);
role.setMode(Mode.EDIT);
role.setDescription("new description");
List<Object> usersToAssign = new ArrayList<Object>();
usersToAssign.add(new UIRepositoryUser(suzyUser));
usersToAssign.add(new UIRepositoryUser(tiffanyUser));
List<Object> usersToUnAssign = new ArrayList<Object>();
usersToUnAssign.add(new UIRepositoryUser(patUser));
usersToUnAssign.add(new UIRepositoryUser(joeUser));
role.assignUsers(usersToAssign);
role.unassignUsers(usersToUnAssign);
// Should have exactly 7 roles
assertEquals(role.getMode(), Mode.EDIT);
// $NON-NLS-1$
assertEquals(role.getDescription(), "new description");
Assert.assertFalse(contains(role.getAssignedUsers(), new UIRepositoryUser(joeUser)));
Assert.assertFalse(contains(role.getAssignedUsers(), new UIRepositoryUser(patUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(tiffanyUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(suzyUser)));
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole in project pentaho-kettle by pentaho.
the class EESecurityController method createModel.
@Override
protected void createModel() throws Exception {
super.createModel();
securityRole = new UISecurityRole();
}
Aggregations