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/30 01:32:58 UTC
svn commit: r438291 -
/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java
Author: elecharny
Date: Tue Aug 29 16:32:58 2006
New Revision: 438291
URL: http://svn.apache.org/viewvc?rev=438291&view=rev
Log:
- Formated the PDUs comments
- Added a test for a bad OID
Modified:
directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java
Modified: directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java?rev=438291&r1=438290&r2=438291&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequestTest.java Tue Aug 29 16:32:58 2006
@@ -56,14 +56,16 @@
ByteBuffer stream = ByteBuffer.allocate( 0x1D );
stream.put( new byte[]
- { 0x30, 0x1B, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x16, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- // requestName [0] LDAPOID,
- ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
- // requestValue [1] OCTET STRING OPTIONAL }
- ( byte ) 0x81, 0x05, 'v', 'a', 'l', 'u', 'e' } );
+ {
+ 0x30, 0x1B, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x16, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
+ ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ // requestValue [1] OCTET STRING OPTIONAL }
+ ( byte ) 0x81, 0x05, 'v', 'a', 'l', 'u', 'e'
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -120,17 +122,21 @@
ByteBuffer stream = ByteBuffer.allocate( 0x3A );
stream.put( new byte[]
- { 0x30, 0x38, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x16, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- // requestName [0] LDAPOID,
+ {
+ 0x30, 0x38, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x16, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
- // requestValue [1] OCTET STRING OPTIONAL }
- ( byte ) 0x81, 0x05, 'v', 'a', 'l', 'u', 'e', ( 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 } );
+ // requestValue [1] OCTET STRING OPTIONAL }
+ ( byte ) 0x81, 0x05, 'v', 'a', 'l', 'u', 'e',
+ ( 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();
@@ -197,16 +203,21 @@
ByteBuffer stream = ByteBuffer.allocate( 0x33 );
stream.put( new byte[]
- { 0x30, 0x31, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x0F, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- // requestName [0] LDAPOID,
- ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
- // requestValue [1] OCTET STRING OPTIONAL }
- ( 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, 0x31, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x0F, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
+ ( byte ) 0x80, 0x0D,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ // requestValue [1] OCTET STRING OPTIONAL }
+ ( 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();
@@ -272,10 +283,11 @@
ByteBuffer stream = ByteBuffer.allocate( 0x07 );
stream.put( new byte[]
- { 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x00, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ {
+ 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x00, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
} );
stream.flip();
@@ -306,11 +318,13 @@
ByteBuffer stream = ByteBuffer.allocate( 0x09 );
stream.put( new byte[]
- { 0x30, 0x07, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x02, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- ( byte ) 0x80, 0x00 } );
+ {
+ 0x30, 0x07, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x02, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ ( byte ) 0x80, 0x00
+ } );
stream.flip();
@@ -329,6 +343,42 @@
}
}
+ /**
+ * Test the decoding of a bad name
+ */
+ public void testDecodeExtendedBadRequestName() throws NamingException
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x16 );
+
+ stream.put( new byte[]
+ {
+ 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x0F, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
+ ( byte ) 0x80, 0x0D,
+ '1', '-', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ } );
+
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ // Decode a ExtendedRequest PDU
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ fail( "We should never reach this point !!!" );
+ }
+ catch ( DecoderException de )
+ {
+ assertTrue( true );
+ }
+ }
/**
* Test the decoding of a name only ExtendedRequest
@@ -340,12 +390,15 @@
ByteBuffer stream = ByteBuffer.allocate( 0x16 );
stream.put( new byte[]
- { 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x0F, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- // requestName [0] LDAPOID,
- ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', } );
+ {
+ 0x30, 0x14, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x0F, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
+ ( byte ) 0x80, 0x0D,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();
@@ -401,13 +454,16 @@
ByteBuffer stream = ByteBuffer.allocate( 0x18 );
stream.put( new byte[]
- { 0x30, 0x16, // LDAPMessage ::= SEQUENCE {
- 0x02, 0x01, 0x01, // messageID MessageID
- // CHOICE { ..., extendedReq ExtendedRequest, ...
- 0x77, 0x11, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- // requestName [0] LDAPOID,
- ( byte ) 0x80, 0x0D, '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2', ( byte ) 0x81,
- 0x00 } );
+ {
+ 0x30, 0x16, // LDAPMessage ::= SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ // CHOICE { ..., extendedReq ExtendedRequest, ...
+ 0x77, 0x11, // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID,
+ ( byte ) 0x80, 0x0D,
+ '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+ ( byte ) 0x81, 0x00
+ } );
String decodedPdu = StringTools.dumpBytes( stream.array() );
stream.flip();