Search in sources :

Example 6 with EERoleInfo

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

Example 7 with EERoleInfo

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

Example 8 with EERoleInfo

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;
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) IRole(org.pentaho.di.repository.pur.model.IRole) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IUser(org.pentaho.di.repository.IUser) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) UserInfo(org.pentaho.di.repository.UserInfo) EERoleInfo(org.pentaho.di.repository.pur.model.EERoleInfo)

Example 9 with EERoleInfo

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