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