directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1053794 - in /directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree: AbstractSubentryUnitTest.java SubentryAddOperationIT.java SubentryDeleteOperationIT.java SubentryLookupOperationIT.java
Date Thu, 30 Dec 2010 03:58:36 GMT
Author: elecharny
Date: Thu Dec 30 03:58:36 2010
New Revision: 1053794

URL: http://svn.apache.org/viewvc?rev=1053794&view=rev
Log:
o Added some helper methods
o Added tests for the lookup operation

Modified:
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java?rev=1053794&r1=1053793&r2=1053794&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/AbstractSubentryUnitTest.java
Thu Dec 30 03:58:36 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.subtree;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
@@ -28,6 +29,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.message.AddResponse;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.junit.After;
 import org.junit.Before;
 
@@ -49,7 +53,7 @@ public class AbstractSubentryUnitTest ex
     public void init() throws Exception
     {
         adminConnection = IntegrationUtils.getAdminConnection( service );
-        userConnection = IntegrationUtils.getConnectionAs( service, "cn=test,ou=system",
"test" );
+        userConnection = IntegrationUtils.getConnectionAs( service, "cn=testUser,ou=system",
"test" );
     }
 
 
@@ -74,6 +78,9 @@ public class AbstractSubentryUnitTest ex
     }
     
     
+    /**
+     * Gets the AccessControl seqNumber of a given AP
+     */
     protected long getACSeqNumber( String apDn ) throws LdapException
     {
         Entry entry = adminConnection.lookup( apDn, "AccessControlSeqNumber" );
@@ -88,7 +95,10 @@ public class AbstractSubentryUnitTest ex
         return Long.parseLong( attribute.getString() );
     }
 
-    
+
+    /**
+     * Gets the CollectiveAttribute seqNumber of a given AP
+     */
     protected long getCASeqNumber( String apDn ) throws LdapException
     {
         Entry entry = adminConnection.lookup( apDn, "CollectiveAttributeSeqNumber" );
@@ -104,6 +114,9 @@ public class AbstractSubentryUnitTest ex
     }
     
 
+    /**
+     * Checks that an entry is absent from the DIT
+     */
     protected boolean checkIsAbsent( String dn ) throws LdapException
     {
         Entry entry = adminConnection.lookup( dn );
@@ -112,10 +125,51 @@ public class AbstractSubentryUnitTest ex
     }
 
     
+    /**
+     * Checks that an entry is present in the DIT
+     */
     protected boolean checkIsPresent( String dn ) throws LdapException
     {
         Entry entry = adminConnection.lookup( dn );
         
         return entry != null;
     }
+    
+    
+    /**
+     * Creates an AAP 
+     */
+    protected void createAAP( String dn ) throws LdapException
+    {
+        Entry autonomousArea = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "administrativeRole: accessControlSpecificArea",
+            "administrativeRole: autonomousArea"
+            );
+
+        // It should succeed
+        AddResponse response = adminConnection.add( autonomousArea );
+
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+    
+    
+    /**
+     * Creates a CollectiveAttribute subentry
+     */
+    protected void createCASubentry( String dn ) throws LdapException
+    {
+        Entry subentry = LdifUtils.createEntry( 
+            dn, 
+            "ObjectClass: top",
+            "ObjectClass: subentry", 
+            "ObjectClass: collectiveAttributeSubentry",
+            "subtreeSpecification: {}", 
+            "c-o: Test Org" );
+
+        AddResponse response = adminConnection.add( subentry );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
 }

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java?rev=1053794&r1=1053793&r2=1053794&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryAddOperationIT.java
Thu Dec 30 03:58:36 2010
@@ -49,12 +49,12 @@ import org.junit.runner.RunWith;
 @CreateDS(name = "AdministrativePointServiceIT")
 @ApplyLdifs(
     {
-        // A test branch
-        "dn: cn=test,ou=system",
+        // An entry used to create a User session
+        "dn: cn=testUser,ou=system",
         "objectClass: top",
         "objectClass: person",
-        "cn: test",
-        "sn: test",
+        "cn: testUser",
+        "sn: test User",
         "userpassword: test"
     })
 public class SubentryAddOperationIT extends AbstractSubentryUnitTest

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java?rev=1053794&r1=1053793&r2=1053794&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryDeleteOperationIT.java
Thu Dec 30 03:58:36 2010
@@ -45,12 +45,12 @@ import org.junit.runner.RunWith;
 @CreateDS(name = "AdministrativePointServiceIT")
 @ApplyLdifs(
     {
-        // A test branch
-        "dn: cn=test,ou=system",
+        // An entry used to create a User session
+        "dn: cn=testUser,ou=system",
         "objectClass: top",
         "objectClass: person",
-        "cn: test",
-        "sn: test",
+        "cn: testUser",
+        "sn: test User",
         "userpassword: test"
     })
 public class SubentryDeleteOperationIT extends AbstractSubentryUnitTest

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java?rev=1053794&r1=1053793&r2=1053794&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryLookupOperationIT.java
Thu Dec 30 03:58:36 2010
@@ -19,8 +19,15 @@
  */
 package org.apache.directory.server.core.subtree;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+
+import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -31,7 +38,17 @@ import org.junit.runner.RunWith;
  */
 @RunWith(FrameworkRunner.class)
 @CreateDS(name = "AdministrativePointServiceIT")
-public class SubentryLookupOperationIT
+@ApplyLdifs(
+    {
+        // An entry used to create a User session
+        "dn: cn=testUser,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: testUser",
+        "sn: test User",
+        "userpassword: test"
+    })
+public class SubentryLookupOperationIT extends AbstractSubentryUnitTest
 {
     // ===================================================================
     // Test the Lookup operation on APs
@@ -42,7 +59,33 @@ public class SubentryLookupOperationIT
     @Test
     public void testLookupAP() throws Exception
     {
-        // TODO
+        createAAP( "ou=AAP, ou=system" );
+        
+        Entry aap = adminConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        assertEquals ( "-1", aap.get( "AccessControlSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "CollectiveAttributeSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "SubSchemaSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "TriggerExecutionSeqNumber" ).getString() );
+    }
+
+    
+    /**
+     * Test the lookup of an AP. All APs are searcheable by default
+     */
+    @Test
+    public void testLookupAPNotAdmin() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        
+        Entry aap = userConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        assertEquals ( "-1", aap.get( "AccessControlSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "CollectiveAttributeSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "SubSchemaSeqNumber" ).getString() );
+        assertEquals ( "-1", aap.get( "TriggerExecutionSeqNumber" ).getString() );
     }
 
     
@@ -56,7 +99,60 @@ public class SubentryLookupOperationIT
     @Test
     public void testLookupSubentry() throws Exception
     {
-        // TODO
+        createAAP( "ou=AAP, ou=system" );
+        createCASubentry( "cn=test, ou=AAP, ou=system" );
+        
+        Entry aap = adminConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        long acSN = Long.parseLong( aap.get( "AccessControlSeqNumber" ).getString() );
+        long caSN = Long.parseLong( aap.get( "CollectiveAttributeSeqNumber" ).getString()
);
+        long ssSN = Long.parseLong( aap.get( "SubSchemaSeqNumber" ).getString() );
+        long teSN = Long.parseLong( aap.get( "TriggerExecutionSeqNumber" ).getString() );
+        
+        assertEquals( -1L, acSN );
+        assertNotSame( -1L, caSN );
+        assertEquals( -1L, ssSN );
+        assertEquals( -1L, teSN );
+        
+        Entry subentry = adminConnection.lookup( "cn=test, ou=AAP, ou=system", "+" );
+        assertNotNull( subentry );
+        assertNull( subentry.get( "AccessControlSeqNumber" ) );
+        assertNull( subentry.get( "CollectiveAttributeSeqNumber" ) );
+        assertNull( subentry.get( "SubSchemaSeqNumber" ) );
+        assertNull( subentry.get( "TriggerExecutionSeqNumber" ) );
+    }
+
+
+    /**
+     * Test the lookup of a subentry. Subentries can be read directly as it's 
+     * a OBJECT search. We don't use the admin in this test
+     */
+    @Test
+    public void testLookupSubentryNotAdmin() throws Exception
+    {
+        createAAP( "ou=AAP, ou=system" );
+        createCASubentry( "cn=test, ou=AAP, ou=system" );
+        
+        Entry aap = userConnection.lookup( "ou=AAP, ou=system", "+" );
+        
+        assertNotNull( aap );
+        long acSN = Long.parseLong( aap.get( "AccessControlSeqNumber" ).getString() );
+        long caSN = Long.parseLong( aap.get( "CollectiveAttributeSeqNumber" ).getString()
);
+        long ssSN = Long.parseLong( aap.get( "SubSchemaSeqNumber" ).getString() );
+        long teSN = Long.parseLong( aap.get( "TriggerExecutionSeqNumber" ).getString() );
+        
+        assertEquals( -1L, acSN );
+        assertNotSame( -1L, caSN );
+        assertEquals( -1L, ssSN );
+        assertEquals( -1L, teSN );
+        
+        Entry subentry = userConnection.lookup( "cn=test, ou=AAP, ou=system", "+" );
+        assertNotNull( subentry );
+        assertNull( subentry.get( "AccessControlSeqNumber" ) );
+        assertNull( subentry.get( "CollectiveAttributeSeqNumber" ) );
+        assertNull( subentry.get( "SubSchemaSeqNumber" ) );
+        assertNull( subentry.get( "TriggerExecutionSeqNumber" ) );
     }
 
 



Mime
View raw message