directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r429141 - /directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Date Sun, 06 Aug 2006 15:58:46 GMT
Author: akarasulu
Date: Sun Aug  6 08:58:45 2006
New Revision: 429141

URL: http://svn.apache.org/viewvc?rev=429141&view=rev
Log:
fix for DIRSERVER-638: escaped hex and BER encoded hex in DN values

Modified:
    directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java

Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java?rev=429141&r1=429140&r2=429141&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
(original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/SearchTest.java
Sun Aug  6 08:58:45 2006
@@ -162,7 +162,81 @@
         assertTrue( "contains cn=Tori Amos", results.contains( "cn=Tori Amos" ) );
     }
 
+    
+    /**
+     * Search operation with a base DN which contains a BER encoded value.
+     */
+    public void testSearchBEREncodedBase() throws NamingException
+    {
+        // create additional entry
+        Attributes attributes = this.getPersonAttributes( "Ferry", "Bryan Ferry" );
+        ctx.createSubcontext( "sn=Ferry", attributes );
 
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        String filter = "(cn=Bryan Ferry)";
+
+        // sn=Ferry with BEROctetString values
+        String base = "sn=#4665727279";
+
+        try
+        {
+            // Check entry
+            NamingEnumeration enm = ctx.search( base, filter, sctls );
+            assertTrue( enm.hasMore() );
+            while ( enm.hasMore() )
+            {
+                SearchResult sr = ( SearchResult ) enm.next();
+                Attributes attrs = sr.getAttributes();
+                Attribute sn = attrs.get( "sn" );
+                assertNotNull( sn );
+                assertTrue( sn.contains( "Ferry" ) );
+            }
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+    }
+
+    
+    /**
+     * Search operation with a base DN which contains a BER encoded value.
+     */
+    public void testSearchWithBackslashEscapedBase() throws NamingException
+    {
+        // create additional entry
+        Attributes attributes = this.getPersonAttributes( "Ferry", "Bryan Ferry" );
+        ctx.createSubcontext( "sn=Ferry", attributes );
+
+        SearchControls sctls = new SearchControls();
+        sctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        String filter = "(cn=Bryan Ferry)";
+
+        // sn=Ferry with BEROctetString values
+        String base = "sn=\\46\\65\\72\\72\\79";
+
+        try
+        {
+            // Check entry
+            NamingEnumeration enm = ctx.search( base, filter, sctls );
+            assertTrue( enm.hasMore() );
+            while ( enm.hasMore() )
+            {
+                SearchResult sr = ( SearchResult ) enm.next();
+                Attributes attrs = sr.getAttributes();
+                Attribute sn = attrs.get( "sn" );
+                assertNotNull( sn );
+                assertTrue( sn.contains( "Ferry" ) );
+            }
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+    }
+
+    
     /**
      * Add a new attribute to a person entry.
      * 



Mime
View raw message