Search in sources :

Example 1 with UIRepositoryRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole 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();
    }
}
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) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) UIEESecurityUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEESecurityUser) Test(org.junit.Test)

Example 2 with UIRepositoryRole

use of org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryRole 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 3 with UIRepositoryRole

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

the class UIEESecurityTest method testUpdateUser.

@Test
public void testUpdateUser() throws Exception {
    try {
        UIEERepositoryUser userToAdd = new UIEERepositoryUser(new EEUserInfo());
        userToAdd.setName("newuser");
        userToAdd.setPassword("newpassword");
        userToAdd.setDescription("new description");
        Set<IUIRole> rolesToAssign = new HashSet<IUIRole>();
        rolesToAssign.add(new UIRepositoryRole(ctoRole));
        rolesToAssign.add(new UIRepositoryRole(isRole));
        rolesToAssign.add(new UIRepositoryRole(adminRole));
        rolesToAssign.add(new UIRepositoryRole(authenticatedRole));
        userToAdd.setRoles(rolesToAssign);
        security.addUser(userToAdd);
        IUIUser selectedUser = security.getSelectedUser();
        selectedUser.setPassword("newpassword123");
        selectedUser.setDescription("new description 123");
        ((IUIEEUser) selectedUser).addRole(new UIRepositoryRole(ctoRole));
        ((IUIEEUser) selectedUser).addRole(new UIRepositoryRole(isRole));
        ((IUIEEUser) selectedUser).removeRole(new UIRepositoryRole(adminRole));
        ((IUIEEUser) selectedUser).removeRole(new UIRepositoryRole(authenticatedRole));
        security.updateUser(selectedUser, rolesToAssign);
        // $NON-NLS-1$
        assertEquals(selectedUser.getPassword(), "newpassword123");
        // $NON-NLS-1$
        assertEquals(selectedUser.getDescription(), "new description 123");
        assertEquals(security.getSelectedUser(), selectedUser);
        assertEquals(security.getUserList().size(), 5);
    } 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) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIEEUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIEEUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with UIRepositoryRole

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

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

Aggregations

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