Search in sources :

Example 1 with EERoleInfo

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));
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo) Test(org.junit.Test)

Example 2 with EERoleInfo

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));
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo) Test(org.junit.Test)

Example 3 with EERoleInfo

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();
    }
}
Also used : UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with EERoleInfo

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();
    }
}
Also used : UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with EERoleInfo

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());
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo) Test(org.junit.Test)

Aggregations

EERoleInfo (org.pentaho.di.repository.pur.model.EERoleInfo)9 Test (org.junit.Test)8 IRole (org.pentaho.di.repository.pur.model.IRole)5 HashSet (java.util.HashSet)3 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)3 UIRepositoryRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole)3 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 IUser (org.pentaho.di.repository.IUser)1 UserInfo (org.pentaho.di.repository.UserInfo)1 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)1 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)1 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)1 UIRepositoryUser (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser)1