Search in sources :

Example 1 with UIRepositoryUser

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser 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();
    }
}
Also used : UIEERepositoryUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) ArrayList(java.util.ArrayList) UserInfo(org.pentaho.di.repository.UserInfo) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) UISecurityRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole) Test(org.junit.Test)

Example 2 with UIRepositoryUser

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser 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();
    }
}
Also used : UIEERepositoryUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser) UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) ArrayList(java.util.ArrayList) UserInfo(org.pentaho.di.repository.UserInfo) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) UISecurityRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole) Test(org.junit.Test)

Example 3 with UIRepositoryUser

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser 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)

Example 4 with UIRepositoryUser

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser in project pentaho-kettle by pentaho.

the class UIEESecurityTest method init.

@Before
public void init() {
    roles.add(adminRole);
    roles.add(anonymousRole);
    roles.add(authenticatedRole);
    roles.add(ceoRole);
    roles.add(ctoRole);
    roles.add(devRole);
    roles.add(devmgrRole);
    roles.add(isRole);
    joeUser = new EEUserInfo("joe", "password", "joe", "joe", true);
    patUser = new EEUserInfo("pat", "password", "pat", "pat", true);
    suzyUser = new EEUserInfo("suzy", "password", "suzy", "suzy", true);
    tiffanyUser = new EEUserInfo("tiffany", "password", "tiffany", "tiffany", true);
    joeUser.addRole(roles.get(0));
    joeUser.addRole(roles.get(2));
    joeUser.addRole(roles.get(3));
    suzyUser.addRole(roles.get(2));
    suzyUser.addRole(roles.get(4));
    suzyUser.addRole(roles.get(7));
    patUser.addRole(roles.get(2));
    patUser.addRole(roles.get(5));
    tiffanyUser.addRole(roles.get(2));
    tiffanyUser.addRole(roles.get(5));
    tiffanyUser.addRole(roles.get(6));
    adminRole.addUser(joeUser);
    adminRole.addUser(patUser);
    anonymousRole.addUser(tiffanyUser);
    authenticatedRole.addUser(joeUser);
    authenticatedRole.addUser(patUser);
    authenticatedRole.addUser(suzyUser);
    authenticatedRole.addUser(tiffanyUser);
    ceoRole.addUser(joeUser);
    ctoRole.addUser(patUser);
    devmgrRole.addUser(joeUser);
    devmgrRole.addUser(patUser);
    isRole.addUser(joeUser);
    isRole.addUser(suzyUser);
    users.add(joeUser);
    users.add(patUser);
    users.add(suzyUser);
    users.add(tiffanyUser);
    rroles = new ArrayList<IUIRole>();
    for (IRole EERoleInfo : roles) {
        IUIRole role = new UIRepositoryRole(EERoleInfo);
        rroles.add(role);
    }
    rusers = new ArrayList<IUIUser>();
    for (IUser eEUserInfo : users) {
        rusers.add(new UIRepositoryUser(eEUserInfo));
    }
    security.setUserList(rusers);
    security.setRoleList(rroles);
}
Also used : IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) IRole(org.pentaho.di.repository.pur.model.IRole) UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIUser(org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser) IUser(org.pentaho.di.repository.IUser) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) Before(org.junit.Before)

Example 5 with UIRepositoryUser

use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser 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();
    }
}
Also used : IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) IRole(org.pentaho.di.repository.pur.model.IRole) UIRepositoryRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole) ArrayList(java.util.ArrayList) UIRepositoryUser(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) UIEESecurityUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser) Test(org.junit.Test)

Aggregations

UIRepositoryUser (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser)5 Test (org.junit.Test)4 UIRepositoryRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole)4 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)4 ArrayList (java.util.ArrayList)3 IUIRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole)3 UserInfo (org.pentaho.di.repository.UserInfo)2 IRole (org.pentaho.di.repository.pur.model.IRole)2 UIEERepositoryUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser)2 UISecurityRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole)2 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 IUser (org.pentaho.di.repository.IUser)1 EERoleInfo (org.pentaho.di.repository.pur.model.EERoleInfo)1 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)1 UIEESecurityUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser)1