Search in sources :

Example 6 with UserInfo

use of org.pentaho.di.repository.UserInfo 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 7 with UserInfo

use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.

the class AbsSecurityProviderTest method setUp.

@Before
public void setUp() {
    provider = new AbsSecurityProvider(new PurRepository(), new PurRepositoryMeta(), new UserInfo(), mock(ServiceManager.class));
    provider = spy(provider);
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) UserInfo(org.pentaho.di.repository.UserInfo) Before(org.junit.Before)

Example 8 with UserInfo

use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.

the class PurRepositorySecurityManagerTest method saveUserInfo_NormalizesInfo_FailsIfStillBreaches.

@Test(expected = KettleException.class)
public void saveUserInfo_NormalizesInfo_FailsIfStillBreaches() throws Exception {
    UserInfo info = new UserInfo("    ");
    manager.saveUserInfo(info);
}
Also used : UserInfo(org.pentaho.di.repository.UserInfo) Test(org.junit.Test)

Example 9 with UserInfo

use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.

the class PurRepositorySecurityManagerTest method saveUserInfo_NormalizesInfo_PassesIfNoViolations.

@Test
public void saveUserInfo_NormalizesInfo_PassesIfNoViolations() throws Exception {
    IUser info = new UserInfo("login    ");
    ArgumentCaptor<IUser> captor = ArgumentCaptor.forClass(IUser.class);
    manager.saveUserInfo(info);
    verify(roleDelegate).createUser(captor.capture());
    info = captor.getValue();
    assertEquals("Spaces should be trimmed", "login", info.getLogin());
}
Also used : IUser(org.pentaho.di.repository.IUser) UserInfo(org.pentaho.di.repository.UserInfo) Test(org.junit.Test)

Example 10 with UserInfo

use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.

the class ExplorerHarness method main.

/**
 * @param args
 */
@SuppressWarnings("nls")
public static void main(String[] args) {
    KettleDatabaseRepositoryMeta repositoryMeta;
    KettleDatabaseRepository repository;
    @SuppressWarnings("unused") UserInfo userInfo;
    repositoryMeta = new KettleDatabaseRepositoryMeta();
    repositoryMeta.setName("Kettle Database Repository");
    repositoryMeta.setDescription("Kettle database test repository");
    DatabaseMeta connection = new DatabaseMeta();
    connection.setDatabaseType("Hypersonic");
    connection.setHostname("localhost");
    connection.setDBName("kettle_repository_4x");
    connection.setDBPort("9002");
    connection.setUsername("sa");
    repositoryMeta.setConnection(connection);
    userInfo = new UserInfo("admin", "admin", "Administrator", "The system administrator", true);
    repository = new KettleDatabaseRepository();
    repository.init(repositoryMeta);
    @SuppressWarnings("unused") RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

        public boolean open(UIRepositoryContent element, String revision) throws Exception {
            System.out.println("Name: ".concat(element.getName()));
            System.out.println("Type: ".concat(element.getRepositoryElementType().name()));
            System.out.println("Directory: ".concat(element.getRepositoryDirectory().toString()));
            System.out.println("Revision: ".concat(revision == null ? "null" : revision));
            // do not close explorer
            return false;
        }

        @Override
        public boolean error(String message) throws Exception {
            System.out.println("Error message: ".concat(message));
            return true;
        }
    };
/*
     * try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new
     * RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) {
     * e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) {
     * e.printStackTrace(); }
     */
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) UserInfo(org.pentaho.di.repository.UserInfo) KettleDatabaseRepository(org.pentaho.di.repository.kdr.KettleDatabaseRepository) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

UserInfo (org.pentaho.di.repository.UserInfo)19 Test (org.junit.Test)10 IUser (org.pentaho.di.repository.IUser)6 Before (org.junit.Before)4 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 LongObjectId (org.pentaho.di.repository.LongObjectId)2 RepositoryExtended (org.pentaho.di.repository.RepositoryExtended)2 UIEERepositoryUser (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEERepositoryUser)2 UISecurityRole (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UISecurityRole)2 IUIUser (org.pentaho.di.ui.repository.repositoryexplorer.model.IUIUser)2 UIRepositoryUser (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryUser)2 ITenant (org.pentaho.platform.api.mt.ITenant)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 RepositoryFileProxyFactory (org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)2 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)2 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)2 TestContextManager (org.springframework.test.context.TestContextManager)2 Date (java.util.Date)1 Matchers.anyString (org.mockito.Matchers.anyString)1