Search in sources :

Example 1 with UIEERepositoryUser

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

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

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

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

the class EESecurityController method updateUser.

/**
 * updateUser method is called when user has click ok on a edit user dialog. The method updates the user
 *
 * @throws Exception
 */
@Override
protected void updateUser() {
    if (service != null) {
        try {
            UIEERepositoryUser uiUser = (UIEERepositoryUser) eeSecurity.getSelectedUser();
            Set<IUIRole> previousRoleList = new HashSet<IUIRole>();
            previousRoleList.addAll(uiUser.getRoles());
            uiUser.setDescription(eeSecurityUser.getDescription());
            uiUser.setPassword(eeSecurityUser.getPassword());
            uiUser.setRoles(new HashSet<IUIRole>(eeSecurityUser.getAssignedRoles()));
            service.updateUser(uiUser.getUserInfo());
            eeSecurity.updateUser(uiUser, previousRoleList);
            userDialog.hide();
        } catch (Throwable th) {
            if (mainController == null || !mainController.handleLostRepository(th)) {
                messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
                messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
                messageBox.setMessage(BaseMessages.getString(PKG, "UpdateUser.UnableToUpdateUser", th.getLocalizedMessage()));
                messageBox.open();
            }
        }
    }
}
Also used : UIEERepositoryUser(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet)

Example 5 with UIEERepositoryUser

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

the class UIEESecurityTest method testRemoveUser.

@Test
public void testRemoveUser() 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();
        int removeUserIndex = security.getSelectedUserIndex();
        security.removeUser("newuser");
        assertEquals(security.getSelectedUserIndex(), removeUserIndex - 1);
        assertEquals(security.getUserList().size(), 4);
    } 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) EEUserInfo(org.pentaho.di.repository.pur.model.EEUserInfo) IUIRole(org.pentaho.di.ui.repository.pur.repositoryexplorer.IUIRole) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

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