directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r492180 - /directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
Date Wed, 03 Jan 2007 15:31:24 GMT
Author: elecharny
Date: Wed Jan  3 07:31:23 2007
New Revision: 492180

URL: http://svn.apache.org/viewvc?view=rev&rev=492180
Log:
Added a test case to check that PDU using long length form is correctly handled by the decoder

Modified:
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java?view=diff&rev=492180&r1=492179&r2=492180
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestTest.java
Wed Jan  3 07:31:23 2007
@@ -4287,4 +4287,101 @@
         Attributes attributes = sr.getAttributes();
         assertEquals( 0, attributes.size() );
     }
+    
+    /**
+     * Test the decoding of a SearchRequest with special length (long form)
+     * for rootDSE
+     */
+    public void testDecodeSearchRequestDIRSERVER_810()
+    {
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x6B );
+        stream.put( new byte[]
+            { 
+                0x30, (byte)0x84, 0x00, 0x00, 0x00, 0x65,
+                  0x02, 0x01, 0x03,
+                  0x63, (byte)0x84, 0x00, 0x00, 0x00, 0x5c,
+                    0x04, 0x12,
+                      0x6f, 0x75, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2c, 
+                      0x6f, 0x75, 0x3d, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, // 'ou=users,ou=system'
+                    0x0a, 0x01, 0x01,
+                    0x0a, 0x01, 0x00,
+                    0x02, 0x01, 0x00,
+                    0x02, 0x01, 0x1e,
+                    0x01, 0x01, (byte)0xff,
+                    (byte)0xa0, (byte)0x84, 0x00, 0x00, 0x00, 0x2d,
+                      (byte)0xa3, (byte)0x84, 0x00, 0x00, 0x00, 0x0e,
+                        0x04, 0x03,
+                          0x75, 0x69, 0x64,
+                        0x04, 0x07,
+                          0x62, 0x75, 0x73, 0x74, 0x65, 0x72, 0x20, // 'buster ' (with a
space at the end)
+                      (byte)0xa3, (byte)0x84, 0x00, 0x00, 0x00, 0x13,
+                        0x04, 0x0b,
+                          0x73, 0x62, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65,
// sbAttribute
+                        0x04, 0x04,
+                          0x42, 0x75, 0x79, 0x20, // 'Buy ' (with a space at the end)
+                    0x30, (byte)0x84, 0x00, 0x00, 0x00, 0x00
+            } );
+        
+        stream.flip();
+
+        // Allocate a BindRequest Container
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+        try
+        {
+            ldapDecoder.decode( stream, ldapMessageContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            fail( de.getMessage() );
+        }
+        catch ( NamingException ne )
+        {
+            ne.printStackTrace();
+            fail( ne.getMessage() );
+        }
+
+        LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+        SearchRequest sr = message.getSearchRequest();
+
+        assertEquals( 3, message.getMessageId() );
+        assertEquals( "ou=users,ou=system", sr.getBaseObject().toString() );
+        assertEquals( ScopeEnum.SINGLE_LEVEL, sr.getScope() );
+        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, sr.getDerefAliases() );
+        assertEquals( 0, sr.getSizeLimit() );
+        assertEquals( 30, sr.getTimeLimit() );
+        assertEquals( true, sr.isTypesOnly() );
+        
+        AndFilter andFilter = ( AndFilter ) sr.getFilter();
+        assertNotNull( andFilter );
+        
+        List<Filter> andFilters = andFilter.getAndFilter();
+        assertEquals( 2, andFilters.size() );
+        
+        // (&(uid=buster)...
+        AttributeValueAssertionFilter equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get(
0 );
+        assertNotNull( equalityMatch );
+
+        AttributeValueAssertion assertion = equalityMatch.getAssertion();
+        assertNotNull( assertion );
+
+        assertEquals( "uid", assertion.getAttributeDesc().toString() );
+        assertEquals( "buster ", assertion.getAssertionValue().toString() );
+
+        // (&(uid=buster)(sbAttribute=Buy))
+        equalityMatch = ( AttributeValueAssertionFilter ) andFilters.get( 1 );
+        assertNotNull( equalityMatch );
+
+        assertion = equalityMatch.getAssertion();
+        assertNotNull( assertion );
+
+        assertEquals( "sbAttribute", assertion.getAttributeDesc().toString() );
+        assertEquals( "Buy ", assertion.getAssertionValue().toString() );
+
+        Attributes attributes = sr.getAttributes();
+        assertEquals( 0, attributes.size() );
+    }
 }



Mime
View raw message