directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r490852 - in /directory/sandbox/triplesec-jacc: guardian-api/src/main/java/org/safehaus/triplesec/guardian/ guardian-api/src/test/java/org/safehaus/triplesec/guardian/ guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/ guardi...
Date Thu, 28 Dec 2006 22:29:49 GMT
Author: djencks
Date: Thu Dec 28 14:29:48 2006
New Revision: 490852

URL: http://svn.apache.org/viewvc?view=rev&rev=490852
Log:
Fix the guardian-ldap integration tests so they pass run one at a time.  I still get weird
errors running all at once

Modified:
    directory/sandbox/triplesec-jacc/guardian-api/src/main/java/org/safehaus/triplesec/guardian/Role.java
    directory/sandbox/triplesec-jacc/guardian-api/src/test/java/org/safehaus/triplesec/guardian/RoleTest.java
    directory/sandbox/triplesec-jacc/guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicy.java
    directory/sandbox/triplesec-jacc/guardian-ldap/src/test/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicyIntegrationTest.java
    directory/sandbox/triplesec-jacc/itest-data/src/main/resources/server.ldif

Modified: directory/sandbox/triplesec-jacc/guardian-api/src/main/java/org/safehaus/triplesec/guardian/Role.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/guardian-api/src/main/java/org/safehaus/triplesec/guardian/Role.java?view=diff&rev=490852&r1=490851&r2=490852
==============================================================================
--- directory/sandbox/triplesec-jacc/guardian-api/src/main/java/org/safehaus/triplesec/guardian/Role.java
(original)
+++ directory/sandbox/triplesec-jacc/guardian-api/src/main/java/org/safehaus/triplesec/guardian/Role.java
Thu Dec 28 14:29:48 2006
@@ -169,51 +169,32 @@
      * Assertive permission check to test if this role has the effective
      * permission.
      *
-     * @param permission the permission to check for
-     * @throws AccessControlException if the permission is not granted
-     */
-    public void checkPermission( StringPermission permission )
-    {
-        checkPermission(
-                permission,
-                "Role '" + name + "' " +
-                "in application '" + getApplicationName() + '\'' +
-                "does not posess the permission '" + permission.getName() + "'." );
-    }
-
-
-    /**
-     * Get's whether or not this Role has the permission.
+     * TODO this method is only used in a test and should be removed
      *
-     * @param permission the name of permission to check for
-     * @return true if the permission is granted,false otherwise
-     */
-    public boolean hasPermission( StringPermission permission )
-    {
-        return grantedPermissions.implies( permission );
-    }
-
-
-    /**
-     * Assertive permission check to test if this Role has the effective 
-     * permission.
-     * 
      * @param permission the permission to check for
-     * @param message to use for AccessControlException if it is thrown
      * @throws AccessControlException if the permission is not granted
      */
-    public void checkPermission( StringPermission permission, String message )
+    public void checkPermission( StringPermission permission )
     {
         if ( permission == null )
         {
-            throw new NullPointerException( "permission" );    
+            throw new NullPointerException( "permission" );
         }
-        
+
         if ( !grantedPermissions.implies( permission ) )
         {
-            throw new AccessControlException( message );
+            throw new AccessControlException("Role '" + name + "' " +
+            "in application '" + getApplicationName() + '\'' +
+            "does not posess the permission '" + permission.getName() + "'." );
+        }
+        if (deniedPermissions.implies(permission)) {
+            throw new AccessControlException("Role '" + name + "' " +
+            "in application '" + getApplicationName() + '\'' +
+            "is denied the permission '" + permission.getName() + "'." );
         }
     }
+
+
 
 
     // ------------------------------------------------------------------------

Modified: directory/sandbox/triplesec-jacc/guardian-api/src/test/java/org/safehaus/triplesec/guardian/RoleTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/guardian-api/src/test/java/org/safehaus/triplesec/guardian/RoleTest.java?view=diff&rev=490852&r1=490851&r2=490852
==============================================================================
--- directory/sandbox/triplesec-jacc/guardian-api/src/test/java/org/safehaus/triplesec/guardian/RoleTest.java
(original)
+++ directory/sandbox/triplesec-jacc/guardian-api/src/test/java/org/safehaus/triplesec/guardian/RoleTest.java
Thu Dec 28 14:29:48 2006
@@ -150,7 +150,7 @@
         assertEquals( "role1", r.getName() );
         assertEquals( perms, r.getGrantedPermissions() );
         assertEquals( "test description", r.getDescription() );
-        assertTrue( r.hasPermission( perm1 ) ) ;
+        assertTrue( r.getGrantedPermissions().implies( perm1 ) ) ;
     }
 
     public void testRolePermissions()
@@ -164,8 +164,7 @@
 
         // Check existing permissions
         r.checkPermission( perm );
-        assertTrue( r.hasPermission( perm ) );
-        r.checkPermission( perm, "unused" );
+        assertTrue( r.getGrantedPermissions().implies( perm ) );
 
         // Check null parameters
         try
@@ -177,28 +176,10 @@
         {
             // OK
         }
-        try
-        {
-            r.checkPermission( ( StringPermission ) null, "unused" );
-            fail( "Exception is not thrown." );
-        }
-        catch( NullPointerException e )
-        {
-            // OK
-        }
         // Check non-existing permissions
         try
         {
             r.checkPermission( wrongPerm );
-            fail( "Exception is not thrown." );
-        }
-        catch( AccessControlException e )
-        {
-            // OK
-        }
-        try
-        {
-            r.checkPermission( wrongPerm, "unused" );
             fail( "Exception is not thrown." );
         }
         catch( AccessControlException e )

Modified: directory/sandbox/triplesec-jacc/guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicy.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicy.java?view=diff&rev=490852&r1=490851&r2=490852
==============================================================================
--- directory/sandbox/triplesec-jacc/guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicy.java
(original)
+++ directory/sandbox/triplesec-jacc/guardian-ldap/src/main/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicy.java
Thu Dec 28 14:29:48 2006
@@ -177,7 +177,7 @@
                     "(objectClass=policyRole)", ctrls);
             while (list.hasMore()) {
                 SearchResult result = (SearchResult) list.next();
-                Role role = getRole(result.getAttributes(), rdn, loader);
+                Role role = getRole(result.getAttributes(), rdn, loader, false);
                 roleSet.add(role);
                 log.debug("loading role '" + role.getName() + "' for application '" + applicationName
+ "'");
             }
@@ -209,13 +209,13 @@
     }
 
 
-    private Role getRole(Attributes attrs, String rdn, ClassLoader loader) throws NamingException
{
+    private Role getRole(Attributes attrs, String rdn, ClassLoader loader, boolean rdnIncludesRoleName)
throws NamingException {
         String roleName = (String) attrs.get("roleName").get();
 
         Permissions grants = new Permissions();
         Permissions denials = new Permissions();
 
-        String roleRdn = "roleName=" + roleName + "," + rdn;
+        String roleRdn = rdnIncludesRoleName? rdn: "roleName=" + roleName + "," + rdn;
 
         addToPermissions(roleRdn, loader, grants, denials);
 
@@ -267,18 +267,18 @@
             }
             String classRdn = "permClassName=" + className + "," + roleRdn;
 
-            addToPermissions(classRdn, "(objectClass=permGrant)", grantCtrls, className,
grants, twoargs, onearg);
-            addToPermissions(classRdn, "(objectClass=denyGrant)", denyCtrls, className, denials,
twoargs, onearg);
+            addToPermissions(classRdn, "(objectClass=permGrant)", "grant", grantCtrls, className,
grants, twoargs, onearg);
+            addToPermissions(classRdn, "(objectClass=permDeny)", "deny", denyCtrls, className,
denials, twoargs, onearg);
 
         }
     }
 
-    private void addToPermissions(String classRdn, String grantDenyObjectClass, SearchControls
grantCtrls, String className, Permissions grants, Constructor<Permission> twoargs, Constructor<Permission>
onearg) throws NamingException {
+    private void addToPermissions(String classRdn, String grantDenyObjectClass, String grantDenyAttrName,
SearchControls grantCtrls, String className, Permissions grants, Constructor<Permission>
twoargs, Constructor<Permission> onearg) throws NamingException {
         for (NamingEnumeration grantList = ctx.search(classRdn,
                 grantDenyObjectClass, grantCtrls); grantList.hasMore();) {
             SearchResult grantResult = (SearchResult) grantList.next();
             Attributes grantAttrs = grantResult.getAttributes();
-            String name = (String) grantAttrs.get("grant").get();
+            String name = (String) grantAttrs.get(grantDenyAttrName).get();
             Attribute actionAttr = grantAttrs.get("action");
             if (actionAttr != null) {
                 if (twoargs == null) {
@@ -320,7 +320,7 @@
     }
 
 
-    private Profile getProfile(Attributes attrs, String rdn) throws NamingException {
+    private Profile getProfile(Attributes attrs, String rdn, boolean isDeleted) throws NamingException
{
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         Permissions grants = new Permissions();
         Permissions denials = new Permissions();
@@ -348,7 +348,6 @@
             disabled = parseBoolean(((String) disabledAttr.get()).toLowerCase());
         }
 
-        addToPermissions(rdn, loader, grants, denials);
 
         // -------------------------------------------------------------------------------
         // process and assemble the profile's assigned roles
@@ -368,17 +367,18 @@
             roles = new Roles(applicationName, new Role[0]);
         }
 
-        Attribute description = attrs.get("description");
-        Profile profile;
+        String description = get(attrs.get("description"));
 
-        if (description == null || description.size() == 0) {
-            profile = new Profile(this, profileId, userName, roles, grants, denials, disabled);
-        } else {
-            profile = new Profile(this, profileId, userName, roles, grants,
-                    denials, (String) description.get(), disabled);
+        if (!isDeleted) {
+            addToPermissions(rdn, loader, grants, denials);
         }
 
-        return profile;
+        return new Profile(this, profileId, userName, roles, grants,
+                    denials, (String) description, disabled);
+    }
+
+    private String get(Attribute attribute) throws NamingException {
+        return (String) (attribute == null || attribute.size() == 0? null: attribute.get());
     }
 
 
@@ -407,7 +407,7 @@
             if (list.hasMore()) {
                 SearchResult result = (SearchResult) list.next();
                 String rdn = "profileId=" + profileId + ",ou=profiles," + baseRdn;
-                Profile profile = getProfile(result.getAttributes(), rdn);
+                Profile profile = getProfile(result.getAttributes(), rdn, false);
 
                 if (log.isDebugEnabled()) {
                     log.debug("loaded profile '" + profileId + "' in application '" + applicationName
+ "'");
@@ -710,7 +710,7 @@
                     * 2. Let user application know that the Role has changed.
                     */
                     //context class loader might be odd here..... maybe we need to register
more cl???
-                    Role newRole = getRole(entry, name, Thread.currentThread().getContextClassLoader());
+                    Role newRole = getRole(entry, name, Thread.currentThread().getContextClassLoader(),
false);
                     Roles roles = LdapApplicationPolicy.this.roles;
                     Roles oldRoles = new Roles(applicationName, new Role[]{roles.get(roleName)});
                     roles = roles.removeAll(oldRoles);
@@ -732,7 +732,7 @@
                     * 1. Let user application know that the Profile has changed.
                     */
 
-                    Profile profile = getProfile(entry, name);
+                    Profile profile = getProfile(entry, name, false);
                     for (PolicyChangeListener listener : listeners) {
                         listener.profileChanged(LdapApplicationPolicy.this, profile, ChangeType.MODIFY);
                     }
@@ -800,7 +800,7 @@
                      * 2. Need to notify of the role's addition to all listeners
                      */
                     //TODO TCCL might be wrong.
-                    Role role = getRole(entry, name, Thread.currentThread().getContextClassLoader());
+                    Role role = getRole(entry, name, Thread.currentThread().getContextClassLoader(),
true);
                     add(role);
 
                     for (PolicyChangeListener listener : listeners) {
@@ -810,7 +810,7 @@
                     /*
                      * 1. Need to notify of the profile's addition to all listeners
                      */
-                    Profile profile = getProfile(entry, name);
+                    Profile profile = getProfile(entry, name, false);
                     for (PolicyChangeListener listener : listeners) {
                         listener.profileChanged(LdapApplicationPolicy.this, profile, ChangeType.ADD);
                     }
@@ -877,7 +877,7 @@
                     /*
                      * 1. Need to notify of the profile's addition to all listeners
                      */
-                    Profile profile = getProfile(entry, name);
+                    Profile profile = getProfile(entry, name, true);
                     for (PolicyChangeListener listener : listeners) {
                         listener.profileChanged(LdapApplicationPolicy.this, profile, ChangeType.DEL);
                     }
@@ -934,7 +934,7 @@
 //                else
                 if (hasObjectClass(oc, "policyRole")) {
                     removeRole(oldProfileId);
-                    Role newRole = getRole(newEntry, newName, Thread.currentThread().getContextClassLoader());
+                    Role newRole = getRole(newEntry, newName, Thread.currentThread().getContextClassLoader(),
true);
                     add(newRole);
 
                     for (PolicyChangeListener listener : listeners) {
@@ -944,7 +944,7 @@
                     /*
                      * 1. Need to notify of the profile's addition to all listeners
                      */
-                    Profile profile = getProfile(newEntry, newName);
+                    Profile profile = getProfile(newEntry, newName, false);
                     for (PolicyChangeListener listener : listeners) {
                         listener.profileRenamed(LdapApplicationPolicy.this, profile, oldProfileId);
                     }

Modified: directory/sandbox/triplesec-jacc/guardian-ldap/src/test/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicyIntegrationTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/guardian-ldap/src/test/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicyIntegrationTest.java?view=diff&rev=490852&r1=490851&r2=490852
==============================================================================
--- directory/sandbox/triplesec-jacc/guardian-ldap/src/test/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicyIntegrationTest.java
(original)
+++ directory/sandbox/triplesec-jacc/guardian-ldap/src/test/java/org/safehaus/triplesec/guardian/ldap/LdapApplicationPolicyIntegrationTest.java
Thu Dec 28 14:29:48 2006
@@ -55,13 +55,14 @@
 {
 
     private static final String APP_NAME = "mockApplication";
-    private Object lockObject = new Object();
+    private final Object lockObject = new Object();
     private String originalName;
     private ChangeType changeType;
     private Profile profile;
     private Role role;
     private StringPermission permission;
     private LdapApplicationPolicy store;
+    private static final long WAIT_TIME = 100000;
 
 
     public LdapApplicationPolicyIntegrationTest( String string ) throws Exception
@@ -79,7 +80,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        Thread.sleep(500);
+//        Thread.sleep(500);
         Properties props = new Properties();
         props.setProperty( "applicationPrincipalDN", "appName=" + APP_NAME + ",ou=applications,dc=example,dc=com"
);
         props.setProperty( "applicationCredentials", "testing" );
@@ -128,41 +129,42 @@
         assertEquals( p, store.getProfile( "mockProfile0" ) );
 
         p = store.getProfile( "mockProfile1" );
-//        assertEquals( 2, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm0" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm1" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm3")));
+        assertEquals( 2, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
+        assertTrue( p.implies( new StringPermission("mockPerm0" )));
+        assertTrue( p.implies( new StringPermission("mockPerm1" )));
+        assertFalse( p.implies( new StringPermission("mockPerm3")));
         assertEquals( p, store.getProfile( "mockProfile1" ) );
 
         p = store.getProfile( "mockProfile2" );
-//        assertEquals( 2, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm0" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm1" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm3")));
+        assertEquals( 2, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
+        assertTrue( p.implies( new StringPermission( "mockPerm0" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm1" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm3")));
         assertEquals( p, store.getProfile( "mockProfile2" ) );
 
         p = store.getProfile( "mockProfile3" );
-//        assertEquals( 4, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm0" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm7" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm2" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm3" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm4" )));
+        assertEquals( 4, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
+        assertTrue( p.implies( new StringPermission( "mockPerm0" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm7" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm2" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm3" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm4" )));
         assertEquals( p, store.getProfile( "mockProfile3" ) );
 
         p = store.getProfile( "mockProfile4" );
-//        assertEquals( 7, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm0" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm1" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm2" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm3" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm4" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm5" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm6" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm7" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm8" )));
-//        assertTrue( p.implies( new StringPermission(APP_NAME, "mockPerm9" )));
-//        assertFalse( p.implies( new StringPermission(APP_NAME, "mockPerm14" )));
+        assertEquals( 8, PermissionsUtil.size(p.getEffectiveGrantedPermissions()) );
+        assertEquals( 1, PermissionsUtil.size(p.getEffectiveDeniedPermissions()) );
+        assertTrue( p.implies( new StringPermission( "mockPerm0" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm1" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm2" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm3" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm4" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm5" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm6" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm7" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm8" )));
+        assertTrue( p.implies( new StringPermission( "mockPerm9" )));
+        assertFalse( p.implies( new StringPermission( "mockPerm14" )));
         assertEquals( p, store.getProfile( "mockProfile4" ) );
 
         store.close();
@@ -196,19 +198,19 @@
         assertTrue( dependents.contains( "mockProfile1" ) );
         assertTrue( dependents.contains( "mockProfile2" ) );
         
-//        StringPermission perm1 = new StringPermission(APP_NAME, "mockPerm1" );
+//        StringPermission perm1 = new StringPermission( "mockPerm1" );
 //        assertTrue(store.getPermissions().implies(perm1));
 //        dependents = store.getDependentProfileNames( perm1 );
 //        assertEquals( 1, dependents.size() );
 //
-//        StringPermission perm7 = new StringPermission(APP_NAME,  "mockPerm7" );
+//        StringPermission perm7 = new StringPermission(  "mockPerm7" );
 //        assertTrue(store.getPermissions().implies(perm7));
 //        dependents = store.getDependentProfileNames( perm7 );
 //        assertEquals( 3, dependents.size() );
 //        assertTrue( dependents.contains( "mockProfile3" ) );
 //        assertTrue( dependents.contains( "mockProfile4" ) );
 //
-//        StringPermission perm0 = new StringPermission(APP_NAME,  "mockPerm0" );
+//        StringPermission perm0 = new StringPermission(  "mockPerm0" );
 //        assertTrue(store.getPermissions().implies(perm0));
 //        dependents = store.getDependentProfileNames( perm0 );
 //        assertEquals( 4, dependents.size() );
@@ -276,7 +278,7 @@
         // wait until the object is set or exit in 10 seconds
 //        long startTime = System.currentTimeMillis();
 //        long totalWaitTime = 0;
-//        while ( totalWaitTime < 10000 )
+//        while ( totalWaitTime < WAIT_TIME )
 //        {
 //            synchronized( lockObject )
 //            {
@@ -314,7 +316,7 @@
         // wait until the object is set or exit in 10 seconds
 //        startTime = System.currentTimeMillis();
 //        totalWaitTime = 0;
-//        while ( totalWaitTime < 10000 )
+//        while ( totalWaitTime < WAIT_TIME )
 //        {
 //            synchronized( lockObject )
 //            {
@@ -346,17 +348,18 @@
         // -------------------------------------------------------------------
         // Test Role Addition and Notification
         // -------------------------------------------------------------------
+        reset();
 
         Attributes attrs = new BasicAttributes( "objectClass", "policyRole", true );
         attrs.put( "roleName", "mockRole5" );
         attrs.put( "description", "testValue" );
-        attrs.put( "grants", "mockPerm8" );
+//        attrs.put( "grants", "mockPerm8" );
         ctx.createSubcontext( "roleName=mockRole5,ou=roles", attrs );
 
         // wait until the object is set or exit in 10 seconds
         long startTime = System.currentTimeMillis();
         long totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -379,8 +382,8 @@
         assertEquals( "mockRole5", this.role.getName() );
         assertEquals( ChangeType.ADD, this.changeType );
         assertEquals( "testValue", this.role.getDescription() );
-        assertTrue( role.hasPermission(new StringPermission("mockPerm8" )));
-        assertFalse( role.hasPermission(new StringPermission("mockPerm1" )));
+//        assertTrue( role.getGrantedPermissions().implies(new StringPermission("mockPerm8"
)));
+        assertFalse( role.getGrantedPermissions().implies(new StringPermission("mockPerm1"
)));
         
         // make sure that policy is updated with this new role
         assertEquals( this.role, this.store.getRoles().get( "mockRole5" ) );
@@ -390,13 +393,14 @@
         // -------------------------------------------------------------------
         // Test Role Deletions and Notification
         // -------------------------------------------------------------------
+        reset();
 
         ctx.destroySubcontext( "roleName=mockRole5,ou=roles" );
 
         // wait until the object is set or exit in 10 seconds
         startTime = System.currentTimeMillis();
         totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -419,8 +423,8 @@
         assertEquals( "mockRole5", this.role.getName() );
         assertEquals( ChangeType.DEL, this.changeType );
         assertEquals( "testValue", this.role.getDescription() );
-        assertTrue( role.hasPermission(new StringPermission("mockPerm8" )));
-        assertFalse( role.hasPermission(new StringPermission("mockPerm1" )));
+//        assertTrue( role.getGrantedPermissions().implies(new StringPermission("mockPerm8"
)));
+        assertFalse( role.getGrantedPermissions().implies(new StringPermission("mockPerm1"
)));
         
         // make sure that policy is updated with this new role
         assertNull( this.store.getRoles().get( "mockRole5" ) );
@@ -430,18 +434,19 @@
         // -------------------------------------------------------------------
         // Test Profile Addition and Notification
         // -------------------------------------------------------------------
+        reset();
 
         attrs = new BasicAttributes( "objectClass", "policyProfile", true );
         attrs.put( "profileId", "mockProfile5" );
         attrs.put( "description", "testValue" );
-        attrs.put( "grants", "mockPerm8" );
+//        attrs.put( "grants", "mockPerm8" );
         attrs.put( "user", "akarasulu" );
         ctx.createSubcontext( "profileId=mockProfile5,ou=profiles", attrs );
 
         // wait until the object is set or exit in 10 seconds
         startTime = System.currentTimeMillis();
         totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -464,19 +469,19 @@
         assertEquals( "mockProfile5", this.profile.getProfileId() );
         assertEquals( ChangeType.ADD, this.changeType );
         assertEquals( "testValue", this.profile.getDescription() );
-        assertTrue( profile.implies( new StringPermission("mockPerm8" )));
+//        assertTrue( profile.implies( new StringPermission("mockPerm8" )));
         assertFalse( profile.implies( new StringPermission("mockPerm1" )));
 
         // -------------------------------------------------------------------
         // Test Profile Deletion and Notification
         // -------------------------------------------------------------------
-
+        reset();
         ctx.destroySubcontext( "profileId=mockProfile5,ou=profiles" );
 
         // wait until the object is set or exit in 10 seconds
         startTime = System.currentTimeMillis();
         totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -499,35 +504,44 @@
         assertEquals( "mockProfile5", this.profile.getProfileId() );
         assertEquals( ChangeType.DEL, this.changeType );
         assertEquals( "testValue", this.profile.getDescription() );
-        assertTrue( profile.implies( new StringPermission("mockPerm8" )));
-        assertFalse( profile.implies( new StringPermission("mockPerm1" )));
+//        assertTrue( profile.implies( new StringPermission("mockPerm8" )));
+//        assertFalse( profile.implies( new StringPermission("mockPerm1" )));
     }
 
-    
+    private void reset() {
+        this.role = null;
+        this.permission = null;
+        this.profile = null;
+        this.changeType = null;
+        this.originalName = null;
+    }
+
+
     public void testModifyNotifications() throws Exception
     {
         // get a connection to the server to be used for alterations
         InitialLdapContext ctx = getNewAppContext();
-        
+
         // prepare listener for notifications
         store.addPolicyListener( new TestListener() );
         Thread.sleep( 200 );
-        
+
         // -------------------------------------------------------------------
         // Test Profile Alteration and Notification
         // -------------------------------------------------------------------
+        reset();
 
         ctx.modifyAttributes( "profileId=mockProfile3,ou=profiles", new ModificationItem[]
{
-            new ModificationItem( DirContext.ADD_ATTRIBUTE, 
+            new ModificationItem( DirContext.ADD_ATTRIBUTE,
                 new BasicAttribute( "description", "testValue" ) ),
-            new ModificationItem( DirContext.REPLACE_ATTRIBUTE, 
-                new BasicAttribute( "grants", "mockPerm1" ) )
+//            new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
+//                new BasicAttribute( "grants", "mockPerm1" ) )
         } );
-        
+
         // wait until the object is set or exit in 10 seconds
         long startTime = System.currentTimeMillis();
         long totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -547,27 +561,26 @@
         assertEquals( "mockProfile3", profile.getProfileId() );
         assertEquals( ChangeType.MODIFY, changeType );
         assertEquals( "testValue", profile.getDescription() );
-        assertTrue( profile.getGrants().implies( new StringPermission("mockPerm1" )));
-        assertFalse( profile.getGrants().implies( new StringPermission("mockPerm0" )));
-        assertFalse( profile.getGrants().implies( new StringPermission("mockPerm7" )));
-        profile = null;
-        changeType = null;
-        
+//        assertTrue( profile.getGrants().implies( new StringPermission("mockPerm1" )));
+//        assertFalse( profile.getGrants().implies( new StringPermission("mockPerm0" )));
+//        assertFalse( profile.getGrants().implies( new StringPermission("mockPerm7" )));
+
         // -------------------------------------------------------------------
         // Test Role Alteration and Notification
         // -------------------------------------------------------------------
+        reset();
 
         ctx.modifyAttributes( "roleName=mockRole1,ou=roles", new ModificationItem[] {
-            new ModificationItem( DirContext.ADD_ATTRIBUTE, 
+            new ModificationItem( DirContext.ADD_ATTRIBUTE,
                 new BasicAttribute( "description", "testValue" ) ),
-            new ModificationItem( DirContext.REPLACE_ATTRIBUTE, 
-                new BasicAttribute( "grants", "mockPerm1" ) )
+//            new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
+//                new BasicAttribute( "grants", "mockPerm1" ) )
         } );
-        
+
         // wait until the object is set or exit in 10 seconds
         startTime = System.currentTimeMillis();
         totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -588,17 +601,16 @@
         assertEquals( "mockRole1", role.getName() );
         assertEquals( ChangeType.MODIFY, changeType );
         assertEquals( "testValue", role.getDescription() );
-        assertTrue( role.getGrantedPermissions().implies( new StringPermission("mockPerm1"
)));
-        assertFalse( role.getGrantedPermissions().implies( new StringPermission("mockPerm0"
)));
-        
+//        assertTrue( role.getGrantedPermissions().implies( new StringPermission("mockPerm1"
)));
+//        assertFalse( role.getGrantedPermissions().implies( new StringPermission("mockPerm0"
)));
+
         // make sure that policy is updated with this changed role
         assertEquals( role, store.getRoles().get( "mockRole1" ) );
-        this.role = null;
-        this.changeType = null;
-        
+
         // -------------------------------------------------------------------
         // Test StringPermission Alteration and Notification
         // -------------------------------------------------------------------
+        reset();
 
 //        ctx.modifyAttributes( "permName=mockPerm1,ou=permissions", new ModificationItem[]
{
 //            new ModificationItem( DirContext.ADD_ATTRIBUTE,
@@ -608,7 +620,7 @@
 //        // wait until the object is set or exit in 10 seconds
 //        startTime = System.currentTimeMillis();
 //        totalWaitTime = 0;
-//        while ( totalWaitTime < 10000 )
+//        while ( totalWaitTime < WAIT_TIME )
 //        {
 //            synchronized( lockObject )
 //            {
@@ -638,7 +650,7 @@
 //        assertFalse( this.store.getRoles().get( "mockRole0" ).getGrantedPermissions().implies(this.permission)
);
 //        assertFalse( this.store.getRoles().get( "mockRole3" ).getGrantedPermissions().implies(this.permission)
);
 //        assertFalse( this.store.getRoles().get( "mockRole4" ).getGrantedPermissions().implies(this.permission)
);
-        
+
         ctx.close();
     }
     
@@ -655,13 +667,14 @@
         // -------------------------------------------------------------------
         // Test Profile Rename and Notification
         // -------------------------------------------------------------------
+        reset();
 
         ctx.rename( "profileId=mockProfile3,ou=profiles", "profileId=renamed,ou=profiles"
);
         
         // wait until the object is set or exit in 10 seconds
         long startTime = System.currentTimeMillis();
         long totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -681,12 +694,11 @@
         assertEquals( "renamed", profile.getProfileId() );
         assertNotNull( originalName );
         assertEquals( "mockProfile3", originalName );
-        profile = null;
-        originalName = null;
-        
+
         // -------------------------------------------------------------------
         // Test Role Rename and Notification
         // -------------------------------------------------------------------
+        reset();
 
         assertNotNull( store.getRoles().get( "mockRole0" ) );
         assertNull( store.getRoles().get( "renamed" ) );
@@ -695,7 +707,7 @@
         // wait until the object is set or exit in 10 seconds
         startTime = System.currentTimeMillis();
         totalWaitTime = 0;
-        while ( totalWaitTime < 10000 )
+        while ( totalWaitTime < WAIT_TIME )
         {
             synchronized( lockObject )
             {
@@ -719,12 +731,11 @@
         assertEquals( "renamed", role.getName() );
         assertNotNull( originalName );
         assertEquals( "mockRole0", originalName );
-        role = null;
-        originalName = null;
 
         // -------------------------------------------------------------------
         // Test StringPermission Rename and Notification
         // -------------------------------------------------------------------
+        reset();
 
 //        Attributes attrs = new BasicAttributes( "objectClass", "policyPermission", true
);
 //        attrs.put( "permName", "mockPerm10" );
@@ -735,7 +746,7 @@
 //        // wait until the object is set or exit in 10 seconds
 //        startTime = System.currentTimeMillis();
 //        totalWaitTime = 0;
-//        while ( totalWaitTime < 10000 )
+//        while ( totalWaitTime < WAIT_TIME )
 //        {
 //            synchronized( lockObject )
 //            {

Modified: directory/sandbox/triplesec-jacc/itest-data/src/main/resources/server.ldif
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/itest-data/src/main/resources/server.ldif?view=diff&rev=490852&r1=490851&r2=490852
==============================================================================
--- directory/sandbox/triplesec-jacc/itest-data/src/main/resources/server.ldif (original)
+++ directory/sandbox/triplesec-jacc/itest-data/src/main/resources/server.ldif Thu Dec 28
14:29:48 2006
@@ -524,8 +524,8 @@
 
 dn: deny=mockPerm7, permClassName=org.safehaus.triplesec.guardian.StringPermission, profileId=mockProfile4,ou=profiles,appName=mockApplication,ou=applications,dc=example,
dc=com
 objectClass: top
-objectClass: permGrant
-grant: mockPerm7
+objectClass: permDeny
+deny: mockPerm7
 
 dn: grant=mockPerm0, permClassName=org.safehaus.triplesec.guardian.StringPermission, profileId=mockProfile4,ou=profiles,appName=mockApplication,ou=applications,dc=example,
dc=com
 objectClass: top



Mime
View raw message