directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1059926 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/
Date Mon, 17 Jan 2011 13:52:29 GMT
Author: kayyagari
Date: Mon Jan 17 13:52:29 2011
New Revision: 1059926

URL: http://svn.apache.org/viewvc?rev=1059926&view=rev
Log:
o fix for DIRSERVER-1600
o added a test case

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java?rev=1059926&r1=1059925&r2=1059926&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
Mon Jan 17 13:52:29 2011
@@ -20,6 +20,9 @@
 package org.apache.directory.server.core.interceptor.context;
 
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 
 import javax.naming.directory.SearchControls;
@@ -75,7 +78,19 @@ public class SearchOperationContext exte
         this.sizeLimit = searchRequest.getSizeLimit();
         this.timeLimit = searchRequest.getTimeLimit();
         this.typesOnly = searchRequest.getTypesOnly();
-        setReturningAttributes( searchRequest.getAttributes() );
+        
+        List<String> ats = searchRequest.getAttributes();
+        
+        // section 4.5.1.8 of RFC 4511
+        //1. An empty list with no attributes requests the return of all user attributes.
+        if ( ats.isEmpty() )
+        {
+            ats = new ArrayList<String>();
+            ats.add( SchemaConstants.ALL_USER_ATTRIBUTES );
+            ats = Collections.unmodifiableList( ats ); 
+        }
+        
+        setReturningAttributes( ats );
         
         if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
         {

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=1059926&r1=1059925&r2=1059926&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
Mon Jan 17 13:52:29 2011
@@ -23,6 +23,7 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -33,10 +34,13 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.AfterClass;
@@ -511,4 +515,33 @@ public class SearchRequestReturningAttri
         assertTrue( entry.containsAttribute( "entryUUID" ) );
         assertTrue( entry.containsAttribute( "entryCSN" ) );
     }
+    
+    
+    /**
+     *  DIRSERVER-1600
+     */
+    @Test
+    public void testSearchTypesOnly() throws Exception
+    {
+        SearchRequest sr = new SearchRequestImpl();
+        sr.setBase( new DN( "uid=admin,ou=system" ) );
+        sr.setFilter( "(uid=admin)" );
+        sr.setScope( SearchScope.OBJECT );
+        sr.setTypesOnly( true );
+        
+        Cursor<Response> cursor = connection.search( sr );
+        int count = 0;
+        Entry response = null;
+
+        while ( cursor.next() )
+        {
+            response = ( ( SearchResultEntry ) cursor.get() ).getEntry();
+            assertNotNull( response );
+            count++;
+        }
+        cursor.close();
+
+        assertEquals( 1, count );
+        assertNull( response.get( SchemaConstants.UID_AT ).get() );
+    }    
 }



Mime
View raw message