You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/08/31 12:33:48 UTC
svn commit: r438859 [4/4] - in /directory/trunks/shared/ldap: ./
src/main/java/org/apache/directory/shared/ldap/codec/
src/main/java/org/apache/directory/shared/ldap/codec/abandon/
src/main/java/org/apache/directory/shared/ldap/codec/add/ src/main/java...
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestSubstringTest.java Thu Aug 31 03:33:43 2006
@@ -1305,16 +1305,22 @@
public void testDecodeSearchRequestEmptySubstringFilter()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x3B, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x36, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x00, 0x30, 0x02, // AttributeDescriptionList
- // ::=
- // SEQUENCE
- // OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x3B,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x36,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1352,16 +1358,23 @@
public void testDecodeSearchRequestSubstringFilterEmptyType()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x3D, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x38, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x02, 0x04, 0x00, 0x30, 0x02, // AttributeDescriptionList
- // ::=
- // SEQUENCE
- // OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x3D,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x38,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x02,
+ 0x04, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1399,14 +1412,23 @@
public void testDecodeSearchRequestSubstringFilterNoSubstrings()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x41, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x3D, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x06, 0x04, 0x04, 't', 'e', 's', 't',
- 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x41,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x3D,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x06, 0x04,
+ 0x04, 't', 'e', 's', 't',
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1444,14 +1466,24 @@
public void testDecodeSearchRequestSubstringFilterEmptySubstrings()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x43, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x3E, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x08, 0x04, 0x04, 't', 'e', 's', 't',
- 0x30, 0x00, 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE
- // OF AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x43,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x3E,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x08,
+ 0x04, 0x04, 't', 'e', 's', 't',
+ 0x30, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1489,16 +1521,25 @@
public void testDecodeSearchRequestSubstringFilterEmptyInitial()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x45, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x40, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x0A, 0x04, 0x04, 't', 'e', 's', 't',
- 0x30, 0x02, ( byte ) 0x80, 0x00, 0x30, 0x02, // AttributeDescriptionList
- // ::= SEQUENCE
- // OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x45,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x40,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x0A,
+ 0x04, 0x04, 't', 'e', 's', 't',
+ 0x30, 0x02,
+ ( byte ) 0x80, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1536,16 +1577,25 @@
public void testDecodeSearchRequestSubstringFilterEmptyAny()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x45, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x40, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x0A, 0x04, 0x04, 't', 'e', 's', 't',
- 0x30, 0x02, ( byte ) 0x81, 0x00, 0x30, 0x02, // AttributeDescriptionList
- // ::= SEQUENCE
- // OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x45,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x40,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x0A,
+ 0x04, 0x04, 't', 'e', 's', 't',
+ 0x30, 0x02,
+ ( byte ) 0x81, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1583,16 +1633,25 @@
public void testDecodeSearchRequestSubstringFilterEmptyFinal()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x45, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x40, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, 0x0A, 0x01, 0x03, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA4, 0x0A, 0x04, 0x04, 't', 'e', 's', 't',
- 0x30, 0x02, ( byte ) 0x82, 0x00, 0x30, 0x02, // AttributeDescriptionList
- // ::= SEQUENCE
- // OF
- // AttributeDescription
- 0x04, 0x00 };
+ {
+ 0x30, 0x45,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x40,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01,
+ 0x0A, 0x01, 0x03,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA4, 0x0A,
+ 0x04, 0x04, 't', 'e', 's', 't',
+ 0x30, 0x02,
+ ( byte ) 0x82, 0x00,
+ 0x30, 0x02, // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
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?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- 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 Thu Aug 31 03:33:43 2006
@@ -38,6 +38,7 @@
import org.apache.directory.shared.ldap.codec.LdapDecoder;
import org.apache.directory.shared.ldap.codec.LdapMessage;
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
import org.apache.directory.shared.ldap.codec.search.AndFilter;
import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
import org.apache.directory.shared.ldap.codec.search.NotFilter;
@@ -45,6 +46,9 @@
import org.apache.directory.shared.ldap.codec.search.PresentFilter;
import org.apache.directory.shared.ldap.codec.search.SearchRequest;
import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControl;
+import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
import org.apache.directory.shared.ldap.schema.OidNormalizer;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -86,69 +90,56 @@
ByteBuffer stream = ByteBuffer.allocate( 0x90 );
stream.put( new byte[]
- { 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
- // searchRequest
- // SearchRequest, ...
- // SearchRequest ::= APPLICATION[3] SEQUENCE {
- 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x01, // scope
- // ENUMERATED
- // {
- // baseObject (0),
- // singleLevel (1),
- // wholeSubtree (2) },
- 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
- // neverDerefAliases (0),
- // derefInSearching (1),
- // derefFindingBaseObj (2),
- // derefAlways (3) },
- // sizeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8,
- // timeLimit INTEGER (0 .. maxInt), (1000)
- 0x02, 0x02, 0x03, ( byte ) 0xE8, 0x01, 0x01, ( byte ) 0xFF, // typesOnly
- // BOOLEAN,
- // (TRUE)
- // filter Filter,
- ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
- // and [0] SET OF Filter,
- ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
- ( byte ) 0xA3, 0x12, // equalityMatch [3]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- // attributeDesc AttributeDescription (LDAPString),
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
- // assertionValue AssertionValue (OCTET STRING) }
+ // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x03, 't', 'o', 'p',
- ( byte ) 0xA3, 0x0E, // equalityMatch
- // [3]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription
- // (LDAPString),
- // assertionValue AssertionValue (OCTET STRING) }
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
- ( byte ) 0xA2, 0x14, // not
- // [2]
- // Filter,
- ( byte ) 0xA3, 0x12, // equalityMatch [3]
- // AttributeValueAssertion,
- // AttributeValueAssertion ::= SEQUENCE {
- // attributeDesc AttributeDescription (LDAPString),
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
- // assertionValue AssertionValue (OCTET STRING) }
+ // assertionValue AssertionValue (OCTET STRING) }
0x04, 0x03, 't', 't', 't',
- // attributes AttributeDescriptionList }
- 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
- // AttributeDescription
- 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription
- // ::= LDAPString
- 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::=
- // LDAPString
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
} );
String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -1255,13 +1246,17 @@
/**
- * Test the decoding of a SearchRequest with an empty baseDN
+ * Test the decoding of a SearchRequest with an empty baseDN and nothing more
*/
- public void testDecodeSearchRequestEmptyBaseDn()
+ public void testDecodeSearchRequestBaseDnOnly()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x07, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x02, 0x04, 0x00 };
+ {
+ 0x30, 0x07,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x02,
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1291,17 +1286,267 @@
fail( "We should not reach this point" );
}
+ /**
+ * Test the decoding of a SearchRequest with no controls. The search filter
+ * is : (&(|(objectclass=top)(ou=contacts))(!(objectclass=ttt)))
+ */
+ public void testDecodeSearchRequestEmptyBaseDnNoControls()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x6F );
+ stream.put( new byte[]
+ {
+ 0x30, 0x6D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, 0x68, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x00, // baseObject LDAPDN,
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ String decodedPdu = StringTools.dumpBytes( stream.array() );
+ 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( 1, message.getMessageId() );
+ assertEquals( "", sr.getBaseObject().toString() );
+ assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, sr.getScope() );
+ assertEquals( LdapConstants.DEREF_ALWAYS, sr.getDerefAliases() );
+ assertEquals( 1000, sr.getSizeLimit() );
+ assertEquals( 1000, sr.getTimeLimit() );
+ assertEquals( true, sr.isTypesOnly() );
+
+ // (& (...
+ AndFilter andFilter = ( AndFilter ) sr.getFilter();
+ assertNotNull( andFilter );
+
+ ArrayList andFilters = andFilter.getAndFilter();
+
+ // (& (| (...
+ assertEquals( 2, andFilters.size() );
+ OrFilter orFilter = ( OrFilter ) andFilters.get( 0 );
+ assertNotNull( orFilter );
+
+ // (& (| (obectclass=top) (...
+ ArrayList orFilters = orFilter.getOrFilter();
+ assertEquals( 2, orFilters.size() );
+ AttributeValueAssertionFilter equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 0 );
+ assertNotNull( equalityMatch );
+
+ AttributeValueAssertion assertion = equalityMatch.getAssertion();
+ assertNotNull( assertion );
+
+ assertEquals( "objectclass", assertion.getAttributeDesc().toString() );
+ assertEquals( "top", assertion.getAssertionValue().toString() );
+
+ // (& (| (objectclass=top) (ou=contacts) ) (...
+ equalityMatch = ( AttributeValueAssertionFilter ) orFilters.get( 1 );
+ assertNotNull( equalityMatch );
+
+ assertion = equalityMatch.getAssertion();
+ assertNotNull( assertion );
+
+ assertEquals( "ou", assertion.getAttributeDesc().toString() );
+ assertEquals( "contacts", assertion.getAssertionValue().toString() );
+
+ // (& (| (objectclass=top) (ou=contacts) ) (! ...
+ NotFilter notFilter = ( NotFilter ) andFilters.get( 1 );
+ assertNotNull( notFilter );
+
+ // (& (| (objectclass=top) (ou=contacts) ) (! (objectclass=ttt) ) )
+ equalityMatch = ( AttributeValueAssertionFilter ) notFilter.getNotFilter();
+ assertNotNull( equalityMatch );
+
+ assertion = equalityMatch.getAssertion();
+ assertNotNull( assertion );
+
+ assertEquals( "objectclass", assertion.getAttributeDesc().toString() );
+ assertEquals( "ttt", assertion.getAssertionValue().toString() );
+
+ Attributes attributes = sr.getAttributes();
+
+ for ( int i = 0; i < attributes.size(); i++ )
+ {
+ assertNotNull( attributes.get( "attr" + i ) );
+ }
+
+ // Check the encoding
+ // We won't check the whole PDU, as it may differs because
+ // attributes may have been reordered
+ try
+ {
+ ByteBuffer bb = message.encode( null );
+
+ String encodedPdu = StringTools.dumpBytes( bb.array() );
+
+ assertEquals( encodedPdu.substring( 0, 0x6F ), decodedPdu.substring( 0, 0x6F ) );
+ }
+ catch ( EncoderException ee )
+ {
+ ee.printStackTrace();
+ fail( ee.getMessage() );
+ }
+ }
+
+ /**
+ * Test the decoding of a SearchRequest with a bad objectBase
+ */
+ public void testDecodeSearchRequestGlobalBadObjectBase() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x90 );
+ stream.put( new byte[]
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', ':', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( de instanceof ResponseCarryingException );
+ Message response = ((ResponseCarryingException)de).getResponse();
+ assertTrue( response instanceof SearchResponseDoneImpl );
+ assertEquals( ResultCodeEnum.INVALIDDNSYNTAX, ((SearchResponseDoneImpl)response).getLdapResult().getResultCode() );
+ return;
+ }
+
+ fail( "We should not reach this point" );
+ }
+
/**
* Test the decoding of a SearchRequest with an empty scope
*/
public void testDecodeSearchRequestEmptyScope()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x28, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x23, 0x04, 0x1F, // baseObject LDAPDN,
- 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x00 };
+ {
+ 0x30, 0x28,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x23,
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1331,7 +1576,85 @@
fail( "We should not reach this point" );
}
+ /**
+ * Test the decoding of a SearchRequest with a bad scope
+ */
+ public void testDecodeSearchRequestGlobalBadScope() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+ ByteBuffer stream = ByteBuffer.allocate( 0x90 );
+ stream.put( new byte[]
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', ':', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x03, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
+ }
+
/**
* Test the decoding of a SearchRequest with an empty derefAlias
*/
@@ -1371,6 +1694,85 @@
fail( "We should not reach this point" );
}
+ /**
+ * Test the decoding of a SearchRequest with a bad derefAlias
+ */
+ public void testDecodeSearchRequestGlobalBadDerefAlias() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x90 );
+ stream.put( new byte[]
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8D, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x87, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', ':', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x04, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
+ }
+
/**
* Test the decoding of a SearchRequest with an empty size limit
@@ -1411,7 +1813,85 @@
fail( "We should not reach this point" );
}
+ /**
+ * Test the decoding of a SearchRequest with a bad sizeLimit
+ */
+ public void testDecodeSearchRequestGlobalBadSizeLimit() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x8F );
+ stream.put( new byte[]
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8C, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x86, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', ':', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x01, ( byte ) 0xFF, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ stream.flip();
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
+ }
+
/**
* Test the decoding of a SearchRequest with an empty time limit
*/
@@ -1452,18 +1932,103 @@
fail( "We should not reach this point" );
}
+ /**
+ * Test the decoding of a SearchRequest with a bad timeLimit
+ */
+ public void testDecodeSearchRequestGlobalBadTimeLimit() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+ ByteBuffer stream = ByteBuffer.allocate( 0x8F );
+ stream.put( new byte[]
+ {
+ 0x30, ( byte ) 0x81, ( byte ) 0x8C, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x63, ( byte ) 0x81, ( byte ) 0x86, // CHOICE { ...,
+ // searchRequest SearchRequest, ...
+ // SearchRequest ::= APPLICATION[3] SEQUENCE {
+ 0x04, 0x1F, // baseObject LDAPDN,
+ 'u', 'i', 'd', ':', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x01, // scope ENUMERATED {
+ // baseObject (0),
+ // singleLevel (1),
+ // wholeSubtree (2) },
+ 0x0A, 0x01, 0x03, // derefAliases ENUMERATED {
+ // neverDerefAliases (0),
+ // derefInSearching (1),
+ // derefFindingBaseObj (2),
+ // derefAlways (3) },
+ 0x02, 0x02, 0x03, ( byte ) 0xE8, // sizeLimit INTEGER (0 .. maxInt), (1000)
+ 0x02, 0x01, ( byte ) 0xFF, // timeLimit INTEGER (0 .. maxInt), (1000)
+ 0x01, 0x01, ( byte ) 0xFF, // typesOnly BOOLEAN, (TRUE)
+ // filter Filter,
+ ( byte ) 0xA0, 0x3C, // Filter ::= CHOICE {
+ // and [0] SET OF Filter,
+ ( byte ) 0xA1, 0x24, // or [1] SET of Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3]
+ // AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 'o', 'p',
+ ( byte ) 0xA3, 0x0E, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ 0x04, 0x02, 'o', 'u', // attributeDesc AttributeDescription (LDAPString),
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x08, 'c', 'o', 'n', 't', 'a', 'c', 't', 's',
+ ( byte ) 0xA2, 0x14, // not [2] Filter,
+ ( byte ) 0xA3, 0x12, // equalityMatch [3] AttributeValueAssertion,
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription (LDAPString),
+ 0x04, 0x0B, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's',
+ // assertionValue AssertionValue (OCTET STRING) }
+ 0x04, 0x03, 't', 't', 't',
+ // attributes AttributeDescriptionList }
+ 0x30, 0x15, // AttributeDescriptionList ::= SEQUENCE OF
+ // AttributeDescription
+ 0x04, 0x05, 'a', 't', 't', 'r', '0', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '1', // AttributeDescription ::= LDAPString
+ 0x04, 0x05, 'a', 't', 't', 'r', '2' // AttributeDescription ::= LDAPString
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ return;
+ }
+
+ fail( "We should not reach this point" );
+ }
+
/**
* Test the decoding of a SearchRequest with an empty filter
*/
public void testDecodeSearchRequestEmptyTypeOnly()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x34, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x2F, 0x04, 0x1F, // baseObject LDAPDN,
+ {
+ 0x30, 0x34,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x2F, 0x04, 0x1F, // baseObject LDAPDN,
'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x00, 0x0A, 0x01, 0x00, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x00 };
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x00,
+ 0x0A, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -1757,11 +2322,20 @@
public void testDecodeSearchRequestEmptyGreaterOrEqualEmptyAttrDesc()
{
byte[] asn1BER = new byte[]
- { 0x30, 0x39, 0x02, 0x01, 0x04, // messageID
- 0x63, 0x34, 0x04, 0x1F, // baseObject LDAPDN,
+ {
+ 0x30, 0x39,
+ 0x02, 0x01, 0x04, // messageID
+ 0x63, 0x34, 0x04, 0x1F, // baseObject LDAPDN,
'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a',
- 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x0A, 0x01, 0x00, 0x0A, 0x01, 0x00, 0x02, 0x01,
- 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, ( byte ) 0xFF, ( byte ) 0xA5, 0x02, 0x04, 0x00 };
+ 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm',
+ 0x0A, 0x01, 0x00,
+ 0x0A, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x02, 0x01, 0x00,
+ 0x01, 0x01, ( byte ) 0xFF,
+ ( byte ) 0xA5, 0x02,
+ 0x04, 0x00
+ };
Asn1Decoder ldapDecoder = new LdapDecoder();
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java?rev=438859&r1=438858&r2=438859&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/unbind/UnBindRequestTest.java Thu Aug 31 03:33:43 2006
@@ -52,10 +52,11 @@
ByteBuffer stream = ByteBuffer.allocate( 0x07 );
stream.put( new byte[]
- { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
- // UnbindRequest ::= [APPLICATION 2] NULL
+ {
+ 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
+ // UnbindRequest ::= [APPLICATION 2] NULL
} );
String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -111,13 +112,17 @@
ByteBuffer stream = ByteBuffer.allocate( 0x24 );
stream.put( new byte[]
- { 0x30, 0x22, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
- // UnbindRequest ::= [APPLICATION 2] NULL
- ( byte ) 0xA0, 0x1B, // A control
- 0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31,
- 0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
+ {
+ 0x30, 0x22, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x42, 0x00, // CHOICE { ..., unbindRequest UnbindRequest,...
+ // UnbindRequest ::= [APPLICATION 2] NULL
+ ( byte ) 0xA0, 0x1B, // A control
+ 0x30, 0x19,
+ 0x04, 0x17,
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.', '1', '1', '3', '7',
+ '3', '0', '.', '3', '.', '4', '.', '2'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -181,10 +186,11 @@
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
stream.put( new byte[]
- { 0x30, 0x07, // LDAPMessage ::=SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x42, 0x02, // CHOICE { ..., unbindRequest UnbindRequest,...
- 0x04, 0x00 // UnbindRequest ::= [APPLICATION 2] NULL
+ {
+ 0x30, 0x07, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x42, 0x02, // CHOICE { ..., unbindRequest UnbindRequest,...
+ 0x04, 0x00 // UnbindRequest ::= [APPLICATION 2] NULL
} );