Search in sources :

Example 6 with JcrRepositoryDumpToFile

use of org.pentaho.platform.repository2.unified.jcr.JcrRepositoryDumpToFile in project pentaho-platform by pentaho.

the class RepositoryTenantManagerIT method testIsSubTenant.

@Test
public void testIsSubTenant() {
    loginAsSysTenantAdmin();
    ITenant mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(mainTenant_1, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    ITenant mainTenant_2 = tenantManager.createTenant(systemTenant, MAIN_TENANT_2, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(mainTenant_2, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    ITenant subTenant1_1 = tenantManager.createTenant(mainTenant_1, SUB_TENANT1_1, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(subTenant1_1, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    ITenant subTenant1_2 = tenantManager.createTenant(mainTenant_1, SUB_TENANT1_2, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(subTenant1_2, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    ITenant subTenant2_1 = tenantManager.createTenant(mainTenant_2, SUB_TENANT2_1, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(subTenant2_1, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    ITenant subTenant2_2 = tenantManager.createTenant(mainTenant_2, SUB_TENANT2_2, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(subTenant2_2, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    assertTrue(tenantManager.isSubTenant(mainTenant_1, mainTenant_1));
    assertTrue(tenantManager.isSubTenant(mainTenant_2, mainTenant_2));
    assertTrue(tenantManager.isSubTenant(mainTenant_1, subTenant1_2));
    assertTrue(tenantManager.isSubTenant(mainTenant_1, subTenant1_1));
    assertFalse(tenantManager.isSubTenant(mainTenant_1, subTenant2_1));
    assertFalse(tenantManager.isSubTenant(mainTenant_1, subTenant2_2));
    assertFalse(tenantManager.isSubTenant(mainTenant_2, subTenant1_2));
    assertFalse(tenantManager.isSubTenant(mainTenant_2, subTenant1_1));
    assertTrue(tenantManager.isSubTenant(mainTenant_2, subTenant2_1));
    assertTrue(tenantManager.isSubTenant(mainTenant_2, subTenant2_2));
    assertTrue(tenantManager.isSubTenant(subTenant2_2, subTenant2_2));
    assertTrue(tenantManager.isSubTenant(subTenant1_2, subTenant1_2));
    JcrRepositoryDumpToFile dumpToFile = new JcrRepositoryDumpToFile(testJcrTemplate, jcrTransactionTemplate, repositoryAdminUsername, "c:/tmp/testdump122", Mode.CUSTOM);
    dumpToFile.execute();
    cleanupUserAndRoles(mainTenant_1);
    cleanupUserAndRoles(mainTenant_2);
    cleanupUserAndRoles(subTenant1_1);
    cleanupUserAndRoles(subTenant1_2);
    cleanupUserAndRoles(subTenant2_1);
    cleanupUserAndRoles(subTenant2_2);
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) JcrRepositoryDumpToFile(org.pentaho.platform.repository2.unified.jcr.JcrRepositoryDumpToFile) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ITenant (org.pentaho.platform.api.mt.ITenant)6 JcrRepositoryDumpToFile (org.pentaho.platform.repository2.unified.jcr.JcrRepositoryDumpToFile)6 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)5 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)3 Matchers.anyString (org.mockito.Matchers.anyString)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Serializable (java.io.Serializable)1 RepositoryFileAce (org.pentaho.platform.api.repository2.unified.RepositoryFileAce)1 RepositoryFileSid (org.pentaho.platform.api.repository2.unified.RepositoryFileSid)1 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)1 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)1 UnifiedRepositoryException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryException)1 VersionSummary (org.pentaho.platform.api.repository2.unified.VersionSummary)1 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)1 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)1