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));
}
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));
}
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());
}
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);
}
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();
}
}
Aggregations