use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testCheckName.
@Test
public void testCheckName() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
char[] jcrEncodedSymbols = { '%', '/', ':', '[', ']', '*', '|', '\t', '\r', '\n' };
Set<Character> generalSetSymbols = new LinkedHashSet<Character>();
for (char c : jcrEncodedSymbols) {
generalSetSymbols.add(c);
}
for (char c : JcrRepositoryFileUtils.getReservedChars()) {
generalSetSymbols.add(c);
}
for (Character character : generalSetSymbols) {
testSymbol(character, true);
}
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testGetTree.
@Test
public void testGetTree() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
RepositoryFileTree root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getRootFolderPath(), true, 0, null));
assertNotNull(root.getFile());
assertNull(root.getChildren());
root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getRootFolderPath(), true, 1, null));
assertNotNull(root.getFile());
assertNotNull(root.getChildren());
assertFalse(root.getChildren().isEmpty());
assertNull(root.getChildren().get(0).getChildren());
root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getHomeFolderPath(), true, -1, null));
assertNotNull(root.getFile());
assertNotNull(root.getChildren());
assertFalse(root.getChildren().isEmpty());
assertTrue(root.getChildren().get(0).getChildren().isEmpty());
root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getHomeFolderPath(), true, -1, "*uz*"));
assertEquals(1, root.getChildren().size());
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testFileCreator.
@Test
public void testFileCreator() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
String sampleString1 = "sampleString1";
String sampleString2 = "sampleString2";
RepositoryFile newFile1 = createSampleFile(parentFolderPath, "helloworld.sample1", sampleString1, true, 1, true);
RepositoryFile newFile2 = createSampleFile(parentFolderPath, "helloworld.sample2", sampleString2, true, 1, true);
RepositoryFile.Builder builder = new RepositoryFile.Builder(newFile1);
builder.creatorId((String) newFile2.getId());
final String mimeType = "text/plain";
final String dataString = "Hello World!";
final String encoding = "UTF-8";
byte[] data = dataString.getBytes(encoding);
ByteArrayInputStream dataStream = new ByteArrayInputStream(data);
final SimpleRepositoryFileData content = new SimpleRepositoryFileData(dataStream, encoding, mimeType);
RepositoryFile updatedFile = repo.updateFile(builder.build(), content, null);
RepositoryFile reconstituedFile = repo.getFileById(updatedFile.getId());
assertEquals(reconstituedFile.getCreatorId(), newFile2.getId());
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testWriteOnFileToMove.
@Test
public void testWriteOnFileToMove() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
defaultBackingRepositoryLifecycleManager.newTenant();
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
RepositoryFile parentFolder = repo.getFile(ClientRepositoryPaths.getUserHomeFolderPath(PentahoSessionHolder.getSession().getName()));
RepositoryFile srcFolder = new RepositoryFile.Builder("src").folder(true).build();
RepositoryFile destFolder = new RepositoryFile.Builder("dest").folder(true).build();
srcFolder = repo.createFolder(parentFolder.getId(), srcFolder, null);
destFolder = repo.createFolder(parentFolder.getId(), destFolder, null);
RepositoryFile newFile = createSampleFile(srcFolder.getPath(), "helloworld.sample", "ddfdf", false, 83);
RepositoryFileAcl acl = new RepositoryFileAcl.Builder(newFile.getId(), userNameUtils.getPrincipleId(tenantAcme, USERNAME_TIFFANY), RepositoryFileSid.Type.USER).entriesInheriting(false).ace(userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY), RepositoryFileSid.Type.USER, RepositoryFilePermission.READ).build();
repo.updateAcl(acl);
// moved; this should fail
try {
repo.moveFile(newFile.getId(), destFolder.getPath(), null);
fail();
} catch (UnifiedRepositoryAccessDeniedException e) {
// ignore
}
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testListHomeFolders.
/**
* A user should only be able to see his home folder (unless your the admin).
*/
// @Test
public void testListHomeFolders() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
userRoleDao.createUser(tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null);
login(USERNAME_TIFFANY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
List<RepositoryFile> children = repo.getChildren(new RepositoryRequest(String.valueOf(repo.getFile(ClientRepositoryPaths.getHomeFolderPath()).getId()), true, -1, null));
assertEquals(1, children.size());
}
Aggregations