From 631814268a44d0f14678998396649b8a43d9a6e9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 15 Jan 2013 13:22:52 +0000 Subject: [PATCH] fix more unit tests git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1433398 13f79535-47bb-0310-9956-ffa450edef68 --- .../rbac/ldap/LdapRbacManagerTest.java | 5 ++++ .../tests/AbstractRbacManagerTestCase.java | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManagerTest.java b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManagerTest.java index bba03da7..e9c46def 100644 --- a/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManagerTest.java +++ b/redback-rbac/redback-rbac-providers/redback-rbac-ldap/src/test/java/org/apache/archiva/redback/rbac/ldap/LdapRbacManagerTest.java @@ -297,4 +297,9 @@ public class LdapRbacManagerTest { return size + 1; } + + protected boolean supportChildRole() + { + return false; + } } diff --git a/redback-rbac/redback-rbac-tests/src/main/java/org/apache/archiva/redback/tests/AbstractRbacManagerTestCase.java b/redback-rbac/redback-rbac-tests/src/main/java/org/apache/archiva/redback/tests/AbstractRbacManagerTestCase.java index cd5b16e9..84ace15e 100644 --- a/redback-rbac/redback-rbac-tests/src/main/java/org/apache/archiva/redback/tests/AbstractRbacManagerTestCase.java +++ b/redback-rbac/redback-rbac-tests/src/main/java/org/apache/archiva/redback/tests/AbstractRbacManagerTestCase.java @@ -295,10 +295,26 @@ public abstract class AbstractRbacManagerTestCase assertEventTracker( 1, 0, 0, 0, true, true ); } + /** + * ldap doesn't support child roles + * + * @return + */ + protected boolean supportChildRole() + { + return true; + } + @Test public void testAddGetChildRole() throws RbacManagerException { + if ( !supportChildRole() ) + { + log.info( "child role feature not supported by the RBACManager impl: {}", + rbacManager.getClass().getName() ); + return; + } RBACManager manager = rbacManager; assertNotNull( manager ); @@ -383,7 +399,7 @@ public abstract class AbstractRbacManagerTestCase manager.saveUserAssignment( assignment ); - assertEquals( incAssignements( 1 ), manager.getAllUserAssignments().size() ); + assertEquals( 1, manager.getAllUserAssignments().size() ); assertEquals( 1, manager.getAllRoles().size() ); UserAssignment ua = manager.getUserAssignment( adminPrincipal ); @@ -416,7 +432,7 @@ public abstract class AbstractRbacManagerTestCase assignment = manager.saveUserAssignment( assignment ); assertEquals( 1, assignment.getRoleNames().size() ); - assertEquals( 1, manager.getAssignedRoles( adminPrincipal ).size() ); + assertEquals( incAssignements( 1 ), manager.getAssignedRoles( adminPrincipal ).size() ); } @Test @@ -432,7 +448,7 @@ public abstract class AbstractRbacManagerTestCase admin = manager.saveRole( admin ); - assertEquals( incAssignements( 1 ), manager.getAllRoles().size() ); + assertEquals( 1, manager.getAllRoles().size() ); String adminPrincipal = "admin"; @@ -442,7 +458,7 @@ public abstract class AbstractRbacManagerTestCase manager.saveUserAssignment( ua ); - assertEquals( incAssignements( 1 ), manager.getAllUserAssignments().size() ); + assertEquals( 1, manager.getAllUserAssignments().size() ); Set assignedPermissions = manager.getAssignedPermissions( adminPrincipal );