directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1057293 - in /directory/apacheds/branches/apacheds-AP: core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
Date Mon, 10 Jan 2011 17:56:58 GMT
Author: elecharny
Date: Mon Jan 10 17:56:58 2011
New Revision: 1057293

URL: http://svn.apache.org/viewvc?rev=1057293&view=rev
Log:
o Forgot to update the UUID cache when removing a subentry from the SubentryCache
o Added a test for the renaming of a subentry

Modified:
    directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java

Modified: directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java?rev=1057293&r1=1057292&r2=1057293&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/administrative/SubentryCache.java
Mon Jan 10 17:56:58 2011
@@ -141,6 +141,18 @@ public class SubentryCache implements It
         Subentry[] oldSubentry = dnCache.getElement( dn );
         dnCache.remove( dn );
         
+        // Update the UUID cache
+        if ( oldSubentry != null )
+        { 
+            for ( Subentry subentry : oldSubentry )
+            {
+                if ( subentry != null )
+                {
+                    uuidCache.remove( subentry.getUuid() );
+                }
+            }
+        }
+        
         return oldSubentry;
     }
     

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java?rev=1057293&r1=1057292&r2=1057293&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
Mon Jan 10 17:56:58 2011
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Set;
+
 import org.apache.directory.server.core.administrative.AdministrativePoint;
 import org.apache.directory.server.core.administrative.Subentry;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -621,12 +623,15 @@ public class SubentryRenameOperationIT e
     // Success expected
     // -------------------------------------------------------------------
     /**
-     * Test the addition of a subentry under an AAP
+     * Test the rename of a subentry under an AAP, with 2 roles
      */
     @Test
-    @Ignore
-    public void testAddSubentryUnderAAP() throws Exception
+    public void testRenameSubentryUnderAAP() throws Exception
     {
+        DN aapDn = service.getDNFactory().create( "ou=AAP,ou=system" );
+        DN oldSubentryDn = service.getDNFactory().create( "cn=test,ou=AAP,ou=system" );
+        DN newSubentryDn = service.getDNFactory().create( "cn=test1,ou=AAP,ou=system" );
+        
         // First add an AAP
         createAAP( "ou=AAP,ou=system" );
         
@@ -636,12 +641,84 @@ public class SubentryRenameOperationIT e
             "ObjectClass: top",
             "ObjectClass: subentry", 
             "ObjectClass: collectiveAttributeSubentry",
+            "ObjectClass: accessControlSubentry",
             "cn: test",
             "subtreeSpecification: {}", 
-            "c-o: Test Org" );
+            "c-o: Test Org",
+            "prescriptiveACI: { " 
+            + "  identificationTag \"addAci\", "
+            + "  precedence 14, " 
+            + "  authenticationLevel none, " 
+            + "  itemOrUserFirst userFirst: " 
+            + "  { "
+            + "    userClasses { userGroup { \"cn=Administrators,ou=groups,ou=system\" }
}," 
+            + "    userPermissions "
+            + "    { " 
+            + "      { " 
+            + "        protectedItems { entry, allUserAttributeTypesAndValues }, "
+            + "        grantsAndDenials { grantCompare, grantRead, grantBrowse } " 
+            + "      } " 
+            + "    } " 
+            + "  } "
+            + "}" );
 
-        AddResponse response = adminConnection.add( subentry );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        AddResponse addResponse = adminConnection.add( subentry );
+        assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode()
);
+        
+        long acSeqNumber = getAcSeqNumber( "ou=AAP,ou=system" );
+        long caSeqNumber = getCaSeqNumber( "ou=AAP,ou=system" );
+
+        // Check the rename
+        ModifyDnResponse renameResponse = adminConnection.rename( "cn=test,ou=AAP,ou=system",
"cn=test1" );
+        assertEquals( ResultCodeEnum.SUCCESS, renameResponse.getLdapResult().getResultCode()
);
+        
+        // The SeqNumber should not have changed
+        assertEquals(acSeqNumber, getAcSeqNumber( "ou=AAP,ou=system" ) );
+        assertEquals(caSeqNumber, getCaSeqNumber( "ou=AAP,ou=system" ) );
+        
+        // The APCache should point to the new subentries
+        // First, AC
+        AdministrativePoint acAP = service.getAccessControlAPCache().getElement( aapDn );
+        
+        assertNotNull( acAP );
+        Set<Subentry> subentries = acAP.getSubentries();
+        
+        assertNotNull( subentries );
+        
+        for ( Subentry sub : subentries )
+        {
+            assertEquals( "test1", sub.getCn().getString() );
+        }
+        
+        // Then CA
+        AdministrativePoint caAP = service.getAccessControlAPCache().getElement( aapDn );
+        
+        assertNotNull( caAP );
+        subentries = caAP.getSubentries();
+        
+        assertNotNull( subentries );
+        
+        for ( Subentry sub : subentries )
+        {
+            assertEquals( "test1", sub.getCn().getString() );
+        }
+        
+        // Now ch"ck the UUID cache
+        Subentry[] subArray = service.getSubentryCache().getSubentries( oldSubentryDn );
+        
+        assertNull( subArray );
+        
+        subArray = service.getSubentryCache().getSubentries( newSubentryDn );
+        
+        assertNotNull( subArray );
+
+        for ( Subentry sub : subentries )
+        {
+            if ( sub != null )
+            {
+                assertEquals( "test1", sub.getCn().getString() );
+            }
+        }
     }
     
     



Mime
View raw message