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/28 17:28:13 UTC
svn commit: r437726 -
/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
Author: elecharny
Date: Mon Aug 28 08:28:09 2006
New Revision: 437726
URL: http://svn.apache.org/viewvc?rev=437726&view=rev
Log:
- Reformated the PDUs
- Added two tests to check throwed Exceptions
Modified:
directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java?rev=437726&r1=437725&r2=437726&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java Mon Aug 28 08:28:09 2006
@@ -36,7 +36,11 @@
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.modify.ModifyRequest;
+import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.util.StringTools;
import junit.framework.TestCase;
@@ -60,39 +64,38 @@
stream.put( new byte[]
{
-
- 0x30, 0x52, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x66, 0x4d, // CHOICE { ..., modifyRequest ModifyRequest, ...
- // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
- // object LDAPDN,
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x29, // modification
- // SEQUENCE
- // OF
- // SEQUENCE
- // {
- 0x30, 0x11, 0x0A, 0x01, 0x02, // operation ENUMERATED {
- // add (0),
- // delete (1),
- // replace (2) },
- // modification AttributeTypeAndValues } }
- 0x30, 0x0c, // AttributeTypeAndValues ::= SEQUENCE {
- 0x04, 0x01, 'l', // type AttributeDescription,
- 0x31, 0x07, // vals SET OF AttributeValue }
- 0x04, 0x05, 'P', 'a', 'r', 'i', 's',
-
- 0x30, 0x14, // modification SEQUENCE OF *SEQUENCE* {
- 0x0A, 0x01, 0x00, // operation ENUMERATED {
- // add (0),
- // delete (1),
- // replace (2) },
- // modification AttributeTypeAndValues } }
- 0x30, 0x0f, // AttributeTypeAndValues ::= SEQUENCE {
- 0x04, 0x05, 'a', 't', 't', 'r', 's', // type
- // AttributeDescription,
- 0x31, 0x06, // vals SET OF AttributeValue }
- 0x04, 0x04, 't', 'e', 's', 't' } );
+ 0x30, 0x52, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x66, 0x4d, // CHOICE { ..., modifyRequest ModifyRequest, ...
+ // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ // object LDAPDN,
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x29,
+ // modification SEQUENCE OF SEQUENCE {
+ 0x30, 0x11,
+ 0x0A, 0x01, 0x02, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x0c, // AttributeTypeAndValues ::= SEQUENCE {
+ 0x04, 0x01, 'l', // type AttributeDescription,
+ 0x31, 0x07, // vals SET OF AttributeValue }
+ 0x04, 0x05, 'P', 'a', 'r', 'i', 's',
+
+ 0x30, 0x14, // modification SEQUENCE OF *SEQUENCE* {
+ 0x0A, 0x01, 0x00, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x0f, // AttributeTypeAndValues ::= SEQUENCE {
+ // type AttributeDescription,
+ 0x04, 0x05, 'a', 't', 't', 'r', 's',
+ 0x31, 0x06, // vals SET OF AttributeValue }
+ 0x04, 0x04, 't', 'e', 's', 't'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -157,6 +160,76 @@
}
}
+ /**
+ * Test the decoding of a ModifyRequest
+ */
+ public void testDecodeModifyRequestBadDN() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x54 );
+
+ stream.put( new byte[]
+ {
+ 0x30, 0x52, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x66, 0x4d, // CHOICE { ..., modifyRequest ModifyRequest, ...
+ // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ // object LDAPDN,
+ 0x04, 0x20,
+ 'c', 'n', ':', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x29,
+ // modification SEQUENCE OF SEQUENCE {
+ 0x30, 0x11,
+ 0x0A, 0x01, 0x02, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x0c, // AttributeTypeAndValues ::= SEQUENCE {
+ 0x04, 0x01, 'l', // type AttributeDescription,
+ 0x31, 0x07, // vals SET OF AttributeValue }
+ 0x04, 0x05, 'P', 'a', 'r', 'i', 's',
+
+ 0x30, 0x14, // modification SEQUENCE OF *SEQUENCE* {
+ 0x0A, 0x01, 0x00, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x0f, // AttributeTypeAndValues ::= SEQUENCE {
+ // type AttributeDescription,
+ 0x04, 0x05, 'a', 't', 't', 'r', 's',
+ 0x31, 0x06, // vals SET OF AttributeValue }
+ 0x04, 0x04, 't', 'e', 's', 't'
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ // Decode a ModifyRequest PDU
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( de instanceof ResponseCarryingException );
+ Message response = ((ResponseCarryingException)de).getResponse();
+ assertTrue( response instanceof ModifyResponseImpl );
+ assertEquals( ResultCodeEnum.INVALIDDNSYNTAX, ((ModifyResponseImpl)response).getLdapResult().getResultCode() );
+ return;
+ }
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace();
+ fail( ne.getMessage() );
+ }
+
+ fail( "We should not reach this point" );
+ }
/**
* Test the decoding of a ModifyRequest, with different operations
@@ -168,27 +241,35 @@
ByteBuffer stream = ByteBuffer.allocate( 0x18C );
stream.put( new byte[]
- { 0x30, ( byte ) 0x81, ( byte ) 0x89, 0x02, 0x01, 0x15, 0x66, 0x67, // ModifyRequest
- 0x04, 0x2B, // object : cn=Tori
- // Amos,ou=playground,dc=apache,dc=org
- 0x63, 0x6E, 0x3D, 0x54, 0x6F, 0x72, 0x69, 0x20, 0x41, 0x6D, 0x6F, 0x73, 0x2C, 0x6F, 0x75, 0x3D, 0x70,
- 0x6C, 0x61, 0x79, 0x67, 0x72, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x64, 0x63, 0x3D, 0x61, 0x70, 0x61, 0x63,
- 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72, 0x67, 0x30, 0x38, // Modifications
- 0x30, 0x24, // Modification
- 0x0A, 0x01, 0x00, // Operation = ADD
- 0x30, 0x1F, // type : telephoneNumber
- 0x04, 0x0F, 0x74, 0x65, 0x6C, 0x65, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72,
- 0x31, 0x0C, // vals : 1234567890
- 0x04, 0x0A, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, // 1234567890
- 0x39, 0x30, 0x30, 0x10, // Modification
- 0x0A, 0x01, 0x02, // Operation = REPLACE
- 0x30, 0x0B, // type : cn
- 0x04, 0x02, 0x63, 0x6E, 0x31, 0x05, // vals : XXX
- 0x04, 0x03, 0x58, 0x58, 0x58, ( byte ) 0xA0, 0x1B, // Controls
- // :
- // 2.16.840.1.113730.3.4.2
- 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, ( byte ) 0x81, ( byte ) 0x89,
+ 0x02, 0x01, 0x15,
+ 0x66, 0x67,
+ 0x04, 0x2B, // ModifyRequest object : cn=Tori Amos,ou=playground,dc=apache,dc=org
+ 'c', 'n', '=', 'T', 'o', 'r', 'i', ' ', 'A', 'm', 'o', 's', ',', 'o', 'u',
+ '=', 'p', 'l', 'a', 'y', 'g', 'r', 'o', 'u', 'n', 'd', ',', 'd', 'c', '=',
+ 'a', 'p', 'a', 'c', 'h', 'e', ',', 'd', 'c', '=', 'o', 'r', 'g',
+ 0x30, 0x38, // Modifications
+ 0x30, 0x24, // Modification
+ 0x0A, 0x01, 0x00, // Operation = ADD
+ 0x30, 0x1F, // type : telephoneNumber
+ 0x04, 0x0F,
+ 't', 'e', 'l', 'e', 'p', 'h', 'o', 'n', 'e', 'N', 'u', 'm', 'b', 'e', 'r',
+ 0x31, 0x0C, // vals : 1234567890
+ 0x04, 0x0A,
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ 0x30, 0x10, // Modification
+ 0x0A, 0x01, 0x02, // Operation = REPLACE
+ 0x30, 0x0B, // type : cn
+ 0x04, 0x02, 'c', 'n',
+ 0x31, 0x05, // vals : XXX
+ 0x04, 0x03, 'X', 'X', 'X',
+ ( byte ) 0xA0, 0x1B, // Control : 2.16.840.1.113730.3.4.2
+ 0x30, 0x19,
+ 0x04, 0x17,
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.',
+ '1', '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2'
+ } );
stream.flip();
@@ -277,35 +358,41 @@
ByteBuffer stream = ByteBuffer.allocate( 0x18C );
stream.put( new byte[]
- { 0x30, ( byte ) 0x81, ( byte ) 0xB6, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, ( byte ) 0x81, ( byte ) 0x93, // ModifyRequest
- 0x04, 0x2B, // object : cn=Tori
- // Amos,ou=playground,dc=apache,dc=org
- 0x63, 0x6E, 0x3D, 0x54, 0x6F, 0x72, 0x69, 0x20, 0x41, 0x6D, 0x6F, 0x73, 0x2C, 0x6F, 0x75, 0x3D, 0x70,
- 0x6C, 0x61, 0x79, 0x67, 0x72, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x64, 0x63, 0x3D, 0x61, 0x70, 0x61, 0x63,
- 0x68, 0x65, 0x2C, 0x64, 0x63, 0x3D, 0x6F, 0x72, 0x67, 0x30, 0x64, // Modifications
- 0x30, 0x14, // Modification
- 0x0A, 0x01, 0x01, // Operation : Delete
- 0x30, 0x0F, // type : description
- 0x04, 0x0B, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x00, // Vals
- // =
- // null
- 0x30, 0x25, // Modification
- 0x0A, 0x01, 0x00, // Operation : Add
- 0x30, 0x20, // type : telephoneNumber
- 0x04, 0x0F, 0x74, 0x65, 0x6C, 0x65, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72,
- 0x31, 0x0D, // Vals : 01234567890
- 0x04, 0x0B, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x30, 0x25, // Modification
- 0x0A, 0x01, 0x00, // Operation : Add
- 0x30, 0x20, // type : telephoneNumber
- 0x04, 0x0F, 0x74, 0x65, 0x6C, 0x65, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72,
- 0x31, 0x0D, // Vals : 01234567890
- 0x04, 0x0B, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, ( byte ) 0xA0, 0x1B, // Controls
- // :
- // 2.16.840.1.113730.3.4.2
- 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, ( byte ) 0x81, ( byte ) 0xB6, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, ( byte ) 0x81, ( byte ) 0x93, // ModifyRequest
+ 0x04, 0x2B, // object : cn=Tori Amos,ou=playground,dc=apache,dc=org
+ 'c', 'n', '=', 'T', 'o', 'r', 'i', ' ', 'A', 'm', 'o', 's', ',', 'o', 'u',
+ '=', 'p', 'l', 'a', 'y', 'g', 'r', 'o', 'u', 'n', 'd', ',', 'd', 'c', '=',
+ 'a', 'p', 'a', 'c', 'h', 'e', ',', 'd', 'c', '=', 'o', 'r', 'g',
+ 0x30, 0x64, // Modifications
+ 0x30, 0x14, // Modification
+ 0x0A, 0x01, 0x01, // Operation : Delete
+ 0x30, 0x0F, // type : description
+ 0x04, 0x0B,
+ 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E,
+ 0x31, 0x00, // Vals = null
+ 0x30, 0x25, // Modification
+ 0x0A, 0x01, 0x00, // Operation : Add
+ 0x30, 0x20, // type : telephoneNumber
+ 0x04, 0x0F,
+ 't', 'e', 'l', 'e', 'p', 'h', 'o', 'n', 'e', 'N', 'u', 'm', 'b', 'e', 'r',
+ 0x31, 0x0D, // Vals : 01234567890
+ 0x04, 0x0B, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ 0x30, 0x25, // Modification
+ 0x0A, 0x01, 0x00, // Operation : Add
+ 0x30, 0x20, // type : telephoneNumber
+ 0x04, 0x0F,
+ 't', 'e', 'l', 'e', 'p', 'h', 'o', 'n', 'e', 'N', 'u', 'm', 'b', 'e', 'r',
+ 0x31, 0x0D, // Vals : 01234567890
+ 0x04, 0x0B, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+ ( byte ) 0xA0, 0x1B, // Controls : 2.16.840.1.113730.3.4.2
+ 0x30, 0x19,
+ 0x04, 0x17,
+ '2', '.', '1', '6', '.', '8', '4', '0', '.', '1', '.',
+ '1', '1', '3', '7', '3', '0', '.', '3', '.', '4', '.', '2'
+ } );
stream.flip();
@@ -404,41 +491,38 @@
stream.put( new byte[]
{
-
- 0x30, 0x5A, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- 0x66, 0x55, // CHOICE { ..., modifyRequest ModifyRequest, ...
- // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
- // object LDAPDN,
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x31, // modification
- // SEQUENCE
- // OF
- // SEQUENCE
- // {
- 0x30, 0x19, 0x0A, 0x01, 0x02, // operation ENUMERATED {
- // add (0),
- // delete (1),
- // replace (2) },
- // modification AttributeTypeAndValues } }
- 0x30, 0x14, // AttributeTypeAndValues ::= SEQUENCE {
- 0x04, 0x01, 'l', // type AttributeDescription,
- 0x31, 0x0F, // vals SET OF AttributeValue }
- 0x04, 0x05, 'P', 'a', 'r', 'i', 's', 0x04, 0x06, 'L', 'o', 'n', 'd', 'o', 'n', 0x30, 0x14, // modification
- // SEQUENCE
- // OF
- // *SEQUENCE*
- // {
- 0x0A, 0x01, 0x00, // operation ENUMERATED {
- // add (0),
- // delete (1),
- // replace (2) },
- // modification AttributeTypeAndValues } }
- 0x30, 0x0f, // AttributeTypeAndValues ::= SEQUENCE {
- 0x04, 0x05, 'a', 't', 't', 'r', 's', // type
- // AttributeDescription,
- 0x31, 0x06, // vals SET OF AttributeValue }
- 0x04, 0x04, 't', 'e', 's', 't' } );
+ 0x30, 0x5A, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x66, 0x55, // CHOICE { ..., modifyRequest ModifyRequest, ...
+ // ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ // object LDAPDN,
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x31, // modification SEQUENCE OF SEQUENCE {
+ 0x30, 0x19,
+ 0x0A, 0x01, 0x02, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x14, // AttributeTypeAndValues ::= SEQUENCE {
+ 0x04, 0x01, 'l', // type AttributeDescription,
+ 0x31, 0x0F, // vals SET OF AttributeValue }
+ 0x04, 0x05, 'P', 'a', 'r', 'i', 's',
+ 0x04, 0x06, 'L', 'o', 'n', 'd', 'o', 'n',
+ 0x30, 0x14, // modification SEQUENCE OF *SEQUENCE* {
+ 0x0A, 0x01, 0x00, // operation ENUMERATED {
+ // add (0),
+ // delete (1),
+ // replace (2) },
+ // modification AttributeTypeAndValues } }
+ 0x30, 0x0f, // AttributeTypeAndValues ::= SEQUENCE {
+ // type AttributeDescription,
+ 0x04, 0x05, 'a', 't', 't', 'r', 's',
+ 0x31, 0x06, // vals SET OF AttributeValue }
+ 0x04, 0x04, 't', 'e', 's', 't'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -519,9 +603,10 @@
ByteBuffer stream = ByteBuffer.allocate( 0x07 );
stream.put( new byte[]
- { 0x30, 0x05, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x00 // ModifyRequest
+ {
+ 0x30, 0x05, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x00 // ModifyRequest
} );
stream.flip();
@@ -552,10 +637,12 @@
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
stream.put( new byte[]
- { 0x30, 0x07, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x02, // ModifyRequest
- 0x04, 0x00 } );
+ {
+ 0x30, 0x07, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x02, // ModifyRequest
+ 0x04, 0x00
+ } );
stream.flip();
@@ -585,11 +672,14 @@
ByteBuffer stream = ByteBuffer.allocate( 0x29 );
stream.put( new byte[]
- { 0x30, 0x27, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x22, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
+ {
+ 0x30, 0x27, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x22, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm'
+ } );
stream.flip();
@@ -619,11 +709,15 @@
ByteBuffer stream = ByteBuffer.allocate( 0x2B );
stream.put( new byte[]
- { 0x30, 0x29, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x24, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x00 } );
+ {
+ 0x30, 0x29, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x24, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x00
+ } );
stream.flip();
@@ -653,11 +747,16 @@
ByteBuffer stream = ByteBuffer.allocate( 0x2D );
stream.put( new byte[]
- { 0x30, 0x2B, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x26, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x02, 0x30, 0x00 } );
+ {
+ 0x30, 0x2B, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x26, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x02,
+ 0x30, 0x00
+ } );
stream.flip();
@@ -687,12 +786,17 @@
ByteBuffer stream = ByteBuffer.allocate( 0x2F );
stream.put( new byte[]
- { 0x30, 0x2D, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x28, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x04, 0x30, 0x02, 0x0A,
- 0x00 } );
+ {
+ 0x30, 0x2D, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x28, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x04,
+ 0x30, 0x02,
+ 0x0A, 0x00
+ } );
stream.flip();
@@ -722,12 +826,17 @@
ByteBuffer stream = ByteBuffer.allocate( 0x30 );
stream.put( new byte[]
- { 0x30, 0x2E, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x29, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x05, 0x30, 0x03, 0x0A,
- 0x01, 0x04 } );
+ {
+ 0x30, 0x2E, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x29, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x05,
+ 0x30, 0x03,
+ 0x0A, 0x01, 0x04
+ } );
stream.flip();
@@ -758,12 +867,17 @@
ByteBuffer stream = ByteBuffer.allocate( 0x30 );
stream.put( new byte[]
- { 0x30, 0x2E, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x29, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x05, 0x30, 0x03, 0x0A,
- 0x01, 0x00 } );
+ {
+ 0x30, 0x2E, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x29, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x05,
+ 0x30, 0x03,
+ 0x0A, 0x01, 0x00
+ } );
stream.flip();
@@ -794,12 +908,18 @@
ByteBuffer stream = ByteBuffer.allocate( 0x32 );
stream.put( new byte[]
- { 0x30, 0x30, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x2B, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x07, 0x30, 0x05, 0x0A,
- 0x01, 0x00, 0x30, 0x00 } );
+ {
+ 0x30, 0x30, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x2B, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x07,
+ 0x30, 0x05,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x00
+ } );
stream.flip();
@@ -830,12 +950,19 @@
ByteBuffer stream = ByteBuffer.allocate( 0x34 );
stream.put( new byte[]
- { 0x30, 0x32, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x2D, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x09, 0x30, 0x07, 0x0A,
- 0x01, 0x00, 0x30, 0x02, 0x04, 0x00 } );
+ {
+ 0x30, 0x32, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x2D, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x09,
+ 0x30, 0x07,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x02,
+ 0x04, 0x00
+ } );
stream.flip();
@@ -850,7 +977,16 @@
}
catch ( DecoderException de )
{
- assertTrue( true );
+ assertTrue( de instanceof ResponseCarryingException );
+ Message response = ((ResponseCarryingException)de).getResponse();
+ assertTrue( response instanceof ModifyResponseImpl );
+ assertEquals( ResultCodeEnum.INVALIDATTRIBUTESYNTAX, ((ModifyResponseImpl)response).getLdapResult().getResultCode() );
+ return;
+ }
+ catch ( NamingException ne )
+ {
+ ne.printStackTrace();
+ fail( ne.getMessage() );
}
}
@@ -866,12 +1002,19 @@
ByteBuffer stream = ByteBuffer.allocate( 0x35 );
stream.put( new byte[]
- { 0x30, 0x33, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x2E, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x0A, 0x30, 0x08, 0x0A,
- 0x01, 0x00, 0x30, 0x03, 0x04, 0x01, 'l', } );
+ {
+ 0x30, 0x33, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x2E, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x0A,
+ 0x30, 0x08,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x03,
+ 0x04, 0x01, 'l'
+ } );
stream.flip();
@@ -902,12 +1045,20 @@
ByteBuffer stream = ByteBuffer.allocate( 0x37 );
stream.put( new byte[]
- { 0x30, 0x35, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x30, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x0C, 0x30, 0x0A, 0x0A,
- 0x01, 0x00, 0x30, 0x05, 0x04, 0x01, 'l', 0x31, 0x00 } );
+ {
+ 0x30, 0x35, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x30, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x0C,
+ 0x30, 0x0A,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x05,
+ 0x04, 0x01, 'l',
+ 0x31, 0x00
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -974,15 +1125,23 @@
ByteBuffer stream = ByteBuffer.allocate( 0x54 );
stream.put( new byte[]
- { 0x30, 0x52, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x30, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x0C, 0x30, 0x0A, 0x0A,
- 0x01, 0x00, 0x30, 0x05, 0x04, 0x01, 'l', 0x31, 0x00, ( byte ) 0xA0, 0x1B, // A
- // control
+ {
+ 0x30, 0x52, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x30, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x0C,
+ 0x30, 0x0A,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x05,
+ 0x04, 0x01, 'l',
+ 0x31, 0x00,
+ ( 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 } );
+ 0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -1058,12 +1217,22 @@
ByteBuffer stream = ByteBuffer.allocate( 0x3D );
stream.put( new byte[]
- { 0x30, 0x3B, // LdapMessage
- 0x02, 0x01, 0x31, // Message ID : 49
- 0x66, 0x36, // ModifyRequest
- 0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
- 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x30, 0x12, 0x30, 0x10, 0x0A,
- 0x01, 0x00, 0x30, 0x0B, 0x04, 0x01, 'l', 0x31, 0x06, 0x04, 0x01, 'a', 0x04, 0x01, 'b' } );
+ {
+ 0x30, 0x3B, // LdapMessage
+ 0x02, 0x01, 0x31, // Message ID : 49
+ 0x66, 0x36, // ModifyRequest
+ 0x04, 0x20,
+ 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+ 's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+ 0x30, 0x12,
+ 0x30, 0x10,
+ 0x0A, 0x01, 0x00,
+ 0x30, 0x0B,
+ 0x04, 0x01, 'l',
+ 0x31, 0x06,
+ 0x04, 0x01, 'a',
+ 0x04, 0x01, 'b'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();