Search in sources :

Example 81 with RepositoryFileAcl

use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.

the class RepositoryFileImportFileHandlerTest method testImportNewFolderWithManifestApplied.

@Test
public void testImportNewFolderWithManifestApplied() throws Exception {
    ImportTestBuilder importTesterBuilder = new ImportTestBuilder();
    importTesterBuilder.folder(true).path("/").hasManifest(true).applyAclSettings(true).overwriteAclSettings(true).build().initialSetup().execute();
    RepositoryFile repositoryFile = mockRepository.getFile("/" + TARGET_RESOURCE_NAME);
    assertNotNull(repositoryFile);
    assertTrue(repositoryFile.isFolder());
    RepositoryFileAcl acl = mockRepository.getAcl(repositoryFile.getId());
    assertHasManifestPermissions(acl);
    assertHasManifestOwner(acl);
}
Also used : RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 82 with RepositoryFileAcl

use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryAuthorizationIT method testGetAcl2.

@Test
public void testGetAcl2() 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 newFolder = new RepositoryFile.Builder("test").folder(true).versioned(true).build();
    newFolder = repo.createFolder(parentFolder.getId(), newFolder, null);
    RepositoryFileAcl acl = repo.getAcl(newFolder.getId());
    RepositoryFileAcl newAcl = new RepositoryFileAcl.Builder(acl).entriesInheriting(false).ace(new RepositoryFileSid(userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY)), RepositoryFilePermission.ALL).build();
    repo.updateAcl(newAcl);
    RepositoryFileAcl fetchedAcl = repo.getAcl(newFolder.getId());
    assertEquals(1, fetchedAcl.getAces().size());
}
Also used : RepositoryFileSid(org.pentaho.platform.api.repository2.unified.RepositoryFileSid) ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 83 with RepositoryFileAcl

use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryAuthorizationIT method testDeleteInheritingFile.

/**
 * Tests parent ACL's contribution to decision. // This test is bogus, it doesn't actually try the delete
 */
@Test
public void testDeleteInheritingFile() 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 newFile = createSampleFile(repo.getFile(ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY)).getPath(), "helloworld.sample", "ddfdf", false, 83);
    RepositoryFileAcl acl = new RepositoryFileAcl.Builder(newFile.getId(), userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY), RepositoryFileSid.Type.USER).entriesInheriting(false).build();
    repo.updateAcl(acl);
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 84 with RepositoryFileAcl

use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryAuthorizationIT method testAdminCreate.

@Test
public void testAdminCreate() 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 });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    final String expectedName = "helloworld.sample";
    final String sampleString = "Ciao World!";
    final boolean sampleBoolean = true;
    final int sampleInteger = 99;
    final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
    RepositoryFile newFile = createSampleFile(parentFolderPath, expectedName, sampleString, sampleBoolean, sampleInteger);
    RepositoryFileAcl acls = repo.getAcl(newFile.getId());
    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder(acls);
    newAclBuilder.entriesInheriting(false).ace(userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY), RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL);
    repo.updateAcl(newAclBuilder.build());
    // newFile = repo.getFile(newFile.getPath());
    JcrRepositoryDumpToFile dumpToFile = new JcrRepositoryDumpToFile(testJcrTemplate, jcrTransactionTemplate, repositoryAdminUsername, "dumpTestAdminCreate", JcrRepositoryDumpToFile.Mode.CUSTOM);
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    try {
        repo.deleteFile(newFile.getId(), null);
    } finally {
        dumpToFile.execute();
    }
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) JcrRepositoryDumpToFile(org.pentaho.platform.repository2.unified.jcr.JcrRepositoryDumpToFile) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Example 85 with RepositoryFileAcl

use of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryAuthorizationIT method testInheritingNodeRemoval.

@Test
public void testInheritingNodeRemoval() 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);
    final String parentFolderPath = ClientRepositoryPaths.getPublicFolderPath();
    RepositoryFile parentFolder = repo.getFile(parentFolderPath);
    DataNode node = new DataNode("kdjd");
    node.setProperty("ddf", "ljsdfkjsdkf");
    DataNode newChild1 = node.addNode("herfkmdx");
    NodeRepositoryFileData data = new NodeRepositoryFileData(node);
    RepositoryFile repoFile = repo.createFile(parentFolder.getId(), new RepositoryFile.Builder("test").build(), data, null);
    RepositoryFileAcl acl = repo.getAcl(repoFile.getId());
    RepositoryFileSid suzySid = new RepositoryFileSid(userNameUtils.getPrincipleId(tenantAcme, USERNAME_SUZY));
    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder(acl).ace(suzySid, EnumSet.of(RepositoryFilePermission.READ, RepositoryFilePermission.WRITE));
    repo.updateAcl(newAclBuilder.build());
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    repoFile = repo.getFile(repoFile.getPath());
    node = new DataNode("kdjd");
    node.setProperty("foo", "bar");
    newChild1 = node.addNode("sdfsdf");
    data = new NodeRepositoryFileData(node);
    repo.updateFile(repoFile, data, "testUpdate");
}
Also used : RepositoryFileSid(org.pentaho.platform.api.repository2.unified.RepositoryFileSid) ITenant(org.pentaho.platform.api.mt.ITenant) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) Matchers.anyString(org.mockito.Matchers.anyString) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) Test(org.junit.Test)

Aggregations

RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)99 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)73 Test (org.junit.Test)50 ITenant (org.pentaho.platform.api.mt.ITenant)25 RepositoryFileSid (org.pentaho.platform.api.repository2.unified.RepositoryFileSid)23 RepositoryFileAce (org.pentaho.platform.api.repository2.unified.RepositoryFileAce)15 Node (javax.jcr.Node)13 Matchers.anyString (org.mockito.Matchers.anyString)13 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)13 Serializable (java.io.Serializable)12 Session (javax.jcr.Session)12 JcrCallback (org.springframework.extensions.jcr.JcrCallback)12 ArrayList (java.util.ArrayList)11 RepositoryException (javax.jcr.RepositoryException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 IOException (java.io.IOException)9 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)9 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)8 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)8 InputStream (java.io.InputStream)7