Search in sources :

Example 16 with UserInfo

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

the class UIRepositoryDirectoryTest method testRefresh.

@Test
public void testRefresh() throws Exception {
    RepositoryDirectory root = new RepositoryDirectory();
    LongObjectId rootObjectId = new LongObjectId(0L);
    root.setObjectId(rootObjectId);
    RepositoryDirectory dir = new RepositoryDirectory();
    dir.setObjectId(new LongObjectId(1L));
    root.addSubdirectory(dir);
    RepositoryExtended repo = mock(RepositoryExtended.class);
    UserInfo userInfo = new UserInfo();
    userInfo.setAdmin(true);
    Mockito.when(repo.getUserInfo()).thenReturn(userInfo);
    RepositoryDirectory rd = Mockito.mock(RepositoryDirectory.class);
    Mockito.when(rd.findDirectory(Mockito.eq(rootObjectId))).thenReturn(Mockito.mock(RepositoryDirectory.class));
    Mockito.when(repo.loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, true, true, true)).thenReturn(rd);
    UIRepositoryDirectory uiDir = new UIRepositoryDirectory(root, null, repo);
    uiDir.refresh();
    Mockito.verify(repo).loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, true, true, true);
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) UserInfo(org.pentaho.di.repository.UserInfo) LongObjectId(org.pentaho.di.repository.LongObjectId) Test(org.junit.Test)

Example 17 with UserInfo

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

the class UserRoleDelegateTest method createUser_CreatesSuccessfully_WhenNameIsUnique.

@Test
public void createUser_CreatesSuccessfully_WhenNameIsUnique() throws Exception {
    final String name = "user";
    delegate.createUser(new UserInfo(name));
    verify(roleWebService).createUser(any(ProxyPentahoUser.class));
}
Also used : UserInfo(org.pentaho.di.repository.UserInfo) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 18 with UserInfo

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

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

the class RepositoryExplorerDialog method newUser.

public void newUser() {
    UserDialog ud = new UserDialog(shell, SWT.NONE, rep, new UserInfo());
    IUser ui = ud.open();
    if (ui != null) {
        /**
         *************************
         * Removed by sboden as the user dialog already saves the id on pressing ok. Related defect #4228 on javaforge.
         *
         * // See if this user already exists... long uid = rep.getUserID(ui.getLogin()); if (uid<=0) { ui.saveRep(rep); }
         * else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
         * mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.New.AlreadyExists.Message"));
         * mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.User.New.AlreadyExists.Title")); mb.open(); }
         ***************************
         */
        // Refresh tree...
        refreshTree();
    }
}
Also used : IUser(org.pentaho.di.repository.IUser) UserInfo(org.pentaho.di.repository.UserInfo)

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