directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1060893 - /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
Date Wed, 19 Jan 2011 18:27:03 GMT
Author: elecharny
Date: Wed Jan 19 18:27:03 2011
New Revision: 1060893

URL: http://svn.apache.org/viewvc?rev=1060893&view=rev
Log:
Added a test : search on subentries with Subentries control sent

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java?rev=1060893&r1=1060892&r2=1060893&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
Wed Jan 19 18:27:03 2011
@@ -1270,6 +1270,72 @@ public class SubentryServiceIT extends A
 
 
     @Test
+    public void testSubtreeScopeSearchSubentryVisibilityWithoutTheControl() throws Exception
+    {
+        LdapContext sysRoot = getSystemContext( service );
+        addAdministrativeRole( "collectiveAttributeSpecificArea" );
+        sysRoot.createSubcontext( "cn=testsubentry", getTestSubentryWithExclusion() );
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        Map<String, SearchResult> entries = new HashMap<String, SearchResult>();
+        NamingEnumeration<SearchResult> list = sysRoot.search( "cn=testsubentry", "(objectClass=subentry)",
+            searchControls );
+
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            entries.put( result.getName(), result );
+        }
+
+        assertEquals( 0, entries.size() );
+    }
+
+
+    @Test
+    public void testSubtreeScopeSearchSubentryVisibilityWithTheSubentriesControl() throws
Exception
+    {
+        class SubentriesControl implements javax.naming.ldap.Control
+        {
+
+            public boolean isCritical()
+            {
+                return false;
+            }
+
+            public byte[] getEncodedValue()
+            {
+                return new byte[]{0x01, 0x01, (byte)0xFF};
+            }
+
+            public String getID()
+            {
+                return "1.3.6.1.4.1.4203.1.10.1";
+            }
+        }
+        
+        LdapContext sysRoot = getSystemContext( service );
+        addAdministrativeRole( "collectiveAttributeSpecificArea" );
+        sysRoot.createSubcontext( "cn=testsubentry", getTestSubentryWithExclusion() );
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        sysRoot.setRequestControls( new javax.naming.ldap.Control[]{ new SubentriesControl()
} );
+        Map<String, SearchResult> entries = new HashMap<String, SearchResult>();
+        NamingEnumeration<SearchResult> list = sysRoot.search( "cn=testsubentry", "(objectClass=subentry)",
+            searchControls );
+
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            entries.put( result.getName(), result );
+        }
+
+        assertEquals( 1, entries.size() );
+        assertNotNull( entries.get( "cn=testsubentry,ou=system" ) );
+    }
+
+
+    @Test
     public void testUserInjectAccessControlSubentries() throws Exception
     {
         userConnection = IntegrationUtils.getConnectionAs( service, "cn=testUser,ou=system",
"test" );



Mime
View raw message