use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser in project pentaho-kettle by pentaho.
the class UIEESecurityUserTest method testAddUser.
@Test
public void testAddUser() throws Exception {
try {
UIEESecurityUser user = new UIEESecurityUser(sm);
List<IUIRole> rroles = new ArrayList<IUIRole>();
for (IRole EERoleInfo : roles) {
rroles.add(new UIRepositoryRole(EERoleInfo));
}
user.clear();
user.setAvailableRoles(rroles);
user.setMode(Mode.ADD);
user.setName("newuser");
user.setPassword("newpassword");
user.setDescription("new description");
List<Object> rolesToAssign = new ArrayList<Object>();
rolesToAssign.add(new UIRepositoryRole(ctoRole));
rolesToAssign.add(new UIRepositoryRole(isRole));
rolesToAssign.add(new UIRepositoryRole(adminRole));
rolesToAssign.add(new UIRepositoryRole(authenticatedRole));
user.assignRoles(rolesToAssign);
assertEquals(user.getMode(), Mode.ADD);
// $NON-NLS-1$
assertEquals(user.getName(), "newuser");
// $NON-NLS-1$
assertEquals(user.getPassword(), "newpassword");
// $NON-NLS-1$
assertEquals(user.getDescription(), "new description");
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(adminRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(authenticatedRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(ctoRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(isRole)));
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser in project pentaho-kettle by pentaho.
the class UIEESecurityUserTest method testEditUser.
@Test
public void testEditUser() throws Exception {
try {
UIEESecurityUser user = new UIEESecurityUser(sm);
List<IUIRole> rroles = new ArrayList<IUIRole>();
for (IRole EERoleInfo : roles) {
rroles.add(new UIRepositoryRole(EERoleInfo));
}
user.setUser(new UIRepositoryUser(joeUser), rroles);
user.setMode(Mode.EDIT);
user.setPassword("newpassword");
user.setDescription("new description");
List<Object> rolesToAssign1 = new ArrayList<Object>();
rolesToAssign1.add(new UIRepositoryRole(adminRole));
rolesToAssign1.add(new UIRepositoryRole(authenticatedRole));
user.assignRoles(rolesToAssign1);
List<Object> rolesToAssign = new ArrayList<Object>();
rolesToAssign.add(new UIRepositoryRole(ctoRole));
rolesToAssign.add(new UIRepositoryRole(isRole));
List<Object> rolesToUnAssign = new ArrayList<Object>();
rolesToUnAssign.add(new UIRepositoryRole(adminRole));
rolesToUnAssign.add(new UIRepositoryRole(authenticatedRole));
user.assignRoles(rolesToAssign);
user.unassignRoles(rolesToUnAssign);
// Should have exactly 7 roles
assertEquals(user.getMode(), Mode.EDIT);
// $NON-NLS-1$
assertEquals(user.getPassword(), "newpassword");
// $NON-NLS-1$
assertEquals(user.getDescription(), "new description");
Assert.assertFalse(contains(user.getAssignedRoles(), new UIRepositoryRole(adminRole)));
Assert.assertFalse(contains(user.getAssignedRoles(), new UIRepositoryRole(authenticatedRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(ctoRole)));
Assert.assertTrue(contains(user.getAssignedRoles(), new UIRepositoryRole(isRole)));
} catch (Exception e) {
Assert.fail();
}
}
Aggregations