use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UserRoleDelegateTest method createRole_ProhibitsToCreate_WhenNameCollides.
@Test(expected = KettleException.class)
public void createRole_ProhibitsToCreate_WhenNameCollides() throws Exception {
final String name = "role";
IRole existing = new EERoleInfo(name);
when(roleWebService.getRoles()).thenReturn(new ProxyPentahoRole[] { convertToPentahoProxyRole(existing) });
delegate.createRole(new EERoleInfo(name));
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UserRoleDelegateTest method createRole_CreatesSuccessfully_WhenNameDiffersInCase.
@Test(expected = KettleException.class)
public void createRole_CreatesSuccessfully_WhenNameDiffersInCase() throws Exception {
final String name = "role";
final String upperCased = name.toUpperCase();
IRole existing = new EERoleInfo(upperCased);
when(roleWebService.getRoles()).thenReturn(new ProxyPentahoRole[] { convertToPentahoProxyRole(existing) });
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 UIEESecurityTest method testAddRole.
@Test
public void testAddRole() throws Exception {
try {
security.setSelectedDeck(ObjectRecipient.Type.ROLE);
UIRepositoryRole roleToAdd = new UIRepositoryRole(new EERoleInfo());
roleToAdd.setName("newrole");
roleToAdd.setDescription("new description");
Set<EEUserInfo> usersToAssign = new HashSet<EEUserInfo>();
usersToAssign.add(suzyUser);
usersToAssign.add(tiffanyUser);
usersToAssign.add(joeUser);
security.addRole(roleToAdd);
assertEquals(security.getSelectedRole(), roleToAdd);
assertEquals(security.getSelectedDeck(), ObjectRecipient.Type.ROLE);
assertEquals(security.getRoleList().size(), 9);
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class UIEESecurityTest method testRemoveRole.
@Test
public void testRemoveRole() throws Exception {
try {
UIRepositoryRole roleToAdd = new UIRepositoryRole(new EERoleInfo());
roleToAdd.setName("newrole");
roleToAdd.setDescription("new description");
Set<EEUserInfo> usersToAssign = new HashSet<EEUserInfo>();
usersToAssign.add(suzyUser);
usersToAssign.add(tiffanyUser);
usersToAssign.add(joeUser);
security.addRole(roleToAdd);
// IUIRole selectedRole = security.getSelectedRole();
int removeRoleIndex = security.getSelectedRoleIndex();
security.removeRole("newrole");
assertEquals(security.getSelectedRoleIndex(), removeRoleIndex - 1);
assertEquals(security.getRoleList().size(), 8);
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.repository.pur.model.EERoleInfo in project pentaho-kettle by pentaho.
the class PurRepositorySecurityManagerTest method createRole_NormalizesInfo_PassesIfNoViolations.
@Test
public void createRole_NormalizesInfo_PassesIfNoViolations() throws Exception {
IRole info = new EERoleInfo("role ", "");
ArgumentCaptor<IRole> captor = ArgumentCaptor.forClass(IRole.class);
manager.createRole(info);
verify(roleDelegate).createRole(captor.capture());
info = captor.getValue();
assertEquals("Spaces should be trimmed", "role", info.getName());
}
Aggregations