tenantManager.createTenant( mainTenant_2, SUB_TENANT2_2, adminRoleName, authenticatedRoleName, "Anonymous" );
userRoleDaoProxy.createUser( subTenant2_2, "admin", "password", "", new String[]{adminRoleName} );
login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );
IPentahoRole pentahoRole;
userRoleDaoProxy.createRole( mainTenant_1, ROLE_1, ROLE_DESCRIPTION_1, null );
pentahoRole = userRoleDaoProxy.getRole( mainTenant_1, ROLE_1 );
assertEquals( pentahoRole.getTenant(), mainTenant_1 );
assertEquals( pentahoRole.getName(), ROLE_1 );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
int DEFAULT_ROLE_COUNT = 3;
List<IPentahoRole> roles = userRoleDaoProxy.getRoles( mainTenant_1 );
assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );
for ( IPentahoRole role : roles ) {
if ( role.getName() == ROLE_1 ) {
pentahoRole = role;
}
}
assertEquals( pentahoRole.getTenant(), mainTenant_1 );
assertEquals( pentahoRole.getName(), ROLE_1 );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_1 );
logout();
login( "admin", mainTenant_1, new String[]{adminRoleName, authenticatedRoleName} );
try {
userRoleDaoProxy.createRole( mainTenant_1, ROLE_1, ROLE_DESCRIPTION_1, null );
fail( "Exception not thrown" );
} catch ( Throwable th ) {
assertNotNull( th );
}
logout();
login( "admin", mainTenant_2, new String[]{adminRoleName, authenticatedRoleName} );
pentahoRole = userRoleDaoProxy.createRole( mainTenant_2, ROLE_1, ROLE_DESCRIPTION_2, null );
pentahoRole = userRoleDaoProxy.getRole( mainTenant_2, ROLE_1 );
assertEquals( pentahoRole.getTenant(), mainTenant_2 );
assertEquals( pentahoRole.getName(), ROLE_1 );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_2 );
roles = userRoleDaoProxy.getRoles( mainTenant_2 );
assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );
for ( IPentahoRole role : roles ) {
if ( role.getName() == ROLE_1 ) {
pentahoRole = role;
}
}
assertEquals( pentahoRole.getTenant(), mainTenant_2 );
assertEquals( pentahoRole.getName(), ROLE_1 );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_2 );
logout();
login( "admin", subTenant2_1, new String[]{adminRoleName, authenticatedRoleName} );
try {
pentahoRole = userRoleDaoProxy.createRole( mainTenant_2, ROLE_1, ROLE_DESCRIPTION_1, null );
fail( "Exception not thrown" );
} catch ( Throwable th ) {
assertNotNull( th );
}
userRoleDaoProxy.createRole( null, ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant2_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_3, null );
pentahoRole =
userRoleDaoProxy.getRole( null, ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant2_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getTenant(), subTenant2_1 );
assertEquals( pentahoRole.getName(), ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant2_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_3 );
roles = userRoleDaoProxy.getRoles( subTenant2_1 );
assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );
for ( IPentahoRole role : roles ) {
if ( role.getName() == ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant2_1.getRootFolderAbsolutePath() ) {
pentahoRole = role;
}
}
assertEquals( pentahoRole.getTenant(), subTenant2_1 );
assertEquals( pentahoRole.getName(), ROLE_3 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant2_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_3 );
logout();
login( "admin", subTenant1_1, new String[]{adminRoleName, authenticatedRoleName} );
try {
pentahoRole = userRoleDaoProxy.createRole( subTenant2_1, ROLE_3, ROLE_DESCRIPTION_3, null );
fail( "Exception not thrown" );
} catch ( Throwable th ) {
assertNotNull( th );
}
logout();
login( "admin", subTenant1_1, new String[]{adminRoleName, authenticatedRoleName} );
pentahoRole =
userRoleDaoProxy.createRole( null, ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant1_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_4, null );
pentahoRole =
userRoleDaoProxy.getRole( null, ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant1_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getTenant(), subTenant1_1 );
assertEquals( pentahoRole.getName(), ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant1_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_4 );
roles = userRoleDaoProxy.getRoles( subTenant1_1 );
assertTrue( roles.size() == 1 + DEFAULT_ROLE_COUNT );
for ( IPentahoRole role : roles ) {
if ( role.getName() == ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant1_1.getRootFolderAbsolutePath() ) {
pentahoRole = role;
}
}
assertEquals( pentahoRole.getTenant(), subTenant1_1 );
assertEquals( pentahoRole.getName(), ROLE_4 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER
+ subTenant1_1.getRootFolderAbsolutePath() );
assertEquals( pentahoRole.getDescription(), ROLE_DESCRIPTION_4 );
logout();
login( "admin", subTenant2_1, new String[]{adminRoleName, authenticatedRoleName} );
try {
pentahoRole = userRoleDaoProxy.createRole( subTenant1_1, ROLE_3, ROLE_DESCRIPTION_3, null );