Search in sources :

Example 1 with UserInfo

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

the class UserRoleDelegateTest method createUser_ProhibitsToCreate_WhenNameCollides.

@Test(expected = KettleException.class)
public void createUser_ProhibitsToCreate_WhenNameCollides() throws Exception {
    final String name = "user";
    IUser existing = new UserInfo(name);
    when(roleWebService.getUsers()).thenReturn(new ProxyPentahoUser[] { convertToPentahoProxyUser(existing) });
    delegate.createUser(new UserInfo(name));
}
Also used : IUser(org.pentaho.di.repository.IUser) UserInfo(org.pentaho.di.repository.UserInfo) Test(org.junit.Test)

Example 2 with UserInfo

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

the class UserRoleDelegateTest method createUser_CreatesSuccessfully_WhenNameDiffersInCase.

@Test
public void createUser_CreatesSuccessfully_WhenNameDiffersInCase() throws Exception {
    final String name = "user";
    final String upperCased = name.toUpperCase();
    IUser existing = new UserInfo(upperCased);
    when(roleWebService.getUsers()).thenReturn(new ProxyPentahoUser[] { convertToPentahoProxyUser(existing) });
    delegate.createUser(new UserInfo(name));
    verify(roleWebService).createUser(any(ProxyPentahoUser.class));
}
Also used : IUser(org.pentaho.di.repository.IUser) UserInfo(org.pentaho.di.repository.UserInfo) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 3 with UserInfo

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

the class UIEERepositoryDirectoryIT method setUp.

@Before
public void setUp() throws Exception {
    this.testContextManager = new TestContextManager(getClass());
    this.testContextManager.prepareTestInstance(this);
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    mp.defineInstance(IAclService.class, new Boolean(false));
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    super.setUp();
    KettleEnvironment.init();
    // programmatically register plugins, annotation based plugins do not get loaded unless
    // they are in kettle's plugins folder.
    JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
    StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    setUpUser();
    PurRepository purRep = (PurRepository) repository;
    final PurRepositoryConnector purRepositoryConnector = new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef());
    purRep.setPurRepositoryConnector(purRepositoryConnector);
    purRep.setTest(repo);
    repository.connect(EXP_LOGIN, "password");
    login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
    RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
    Serializable repositoryFileId = repositoryFile.getId();
    List<RepositoryFile> files = repo.getChildren(repositoryFileId);
    StringBuilder buf = new StringBuilder();
    for (RepositoryFile file : files) {
        buf.append("\n").append(file);
    }
    assertTrue("files not deleted: " + buf, files.isEmpty());
}
Also used : Serializable(java.io.Serializable) PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryConnector(org.pentaho.di.repository.pur.PurRepositoryConnector) UserInfo(org.pentaho.di.repository.UserInfo) TestContextManager(org.springframework.test.context.TestContextManager) ITenant(org.pentaho.platform.api.mt.ITenant) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 4 with UserInfo

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

the class UISecurityRoleTest 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 UserInfo("joe", "password", "joe", "joe", true);
    patUser = new UserInfo("pat", "password", "pat", "pat", true);
    suzyUser = new UserInfo("suzy", "password", "suzy", "suzy", true);
    tiffanyUser = new UserInfo("tiffany", "password", "tiffany", "tiffany", true);
    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);
}
Also used : UserInfo(org.pentaho.di.repository.UserInfo) Before(org.junit.Before)

Example 5 with UserInfo

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

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