ldap rbacmanager pass tck

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1433400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-15 13:23:50 +00:00
parent fe2ebb0961
commit 18dbda5efb
4 changed files with 13 additions and 7 deletions

View File

@ -437,8 +437,7 @@ public class LdapRbacManager
{ {
if ( !userRoles.contains( roleName ) ) if ( !userRoles.contains( roleName ) )
{ {
// TODO real role with permission ? unassignedRoles.add( rbacImpl.getRole( roleName ) );
unassignedRoles.add( new RoleImpl( roleName ) );
} }
} }
return unassignedRoles; return unassignedRoles;
@ -707,6 +706,13 @@ public class LdapRbacManager
try try
{ {
ldapRoleMapper.saveRole( role.getName() ); ldapRoleMapper.saveRole( role.getName() );
if ( !role.getChildRoleNames().isEmpty() )
{
for ( String roleName : role.getChildRoleNames() )
{
ldapRoleMapper.saveRole( roleName );
}
}
fireRbacRoleSaved( role ); fireRbacRoleSaved( role );
} }
catch ( MappingException e ) catch ( MappingException e )
@ -771,8 +777,6 @@ public class LdapRbacManager
} }
} }
for ( String role : currentUserRoles ) for ( String role : currentUserRoles )
{ {
if ( !userAssignment.getRoleNames().contains( role ) && writableLdap ) if ( !userAssignment.getRoleNames().contains( role ) && writableLdap )

View File

@ -300,6 +300,6 @@ public class LdapRbacManagerTest
protected boolean supportChildRole() protected boolean supportChildRole()
{ {
return false; return true;
} }
} }

View File

@ -21,6 +21,7 @@ ldap.config.groups.role.user-admin=User Administrator
ldap.config.groups.role.sys-admin=System Administrator ldap.config.groups.role.sys-admin=System Administrator
ldap.config.groups.role.trusted-dev=Trusted Developer ldap.config.groups.role.trusted-dev=Trusted Developer
ldap.config.groups.role.developer=Developer ldap.config.groups.role.developer=Developer
ldap.config.groups.role.super-developer=SUPER_DEVELOPER
ldap.config.groups.role.thetestrole=Test Role ldap.config.groups.role.thetestrole=Test Role

View File

@ -426,13 +426,14 @@ public abstract class AbstractRbacManagerTestCase
adminRole = manager.saveRole( adminRole ); adminRole = manager.saveRole( adminRole );
String adminPrincipal = "admin"; // don't use admin as ldap group need at least one member
String adminPrincipal = "theadmin";
UserAssignment assignment = manager.createUserAssignment( adminPrincipal ); UserAssignment assignment = manager.createUserAssignment( adminPrincipal );
assignment.addRoleName( adminRole ); assignment.addRoleName( adminRole );
assignment = manager.saveUserAssignment( assignment ); assignment = manager.saveUserAssignment( assignment );
assertEquals( 1, assignment.getRoleNames().size() ); assertEquals( 1, assignment.getRoleNames().size() );
assertEquals( incAssignements( 1 ), manager.getAssignedRoles( adminPrincipal ).size() ); assertEquals( 1, manager.getAssignedRoles( adminPrincipal ).size() );
} }
@Test @Test