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/01/16 15:20:53 UTC
svn commit: r369481 -
/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java
Author: elecharny
Date: Mon Jan 16 06:20:49 2006
New Revision: 369481
URL: http://svn.apache.org/viewcvs?rev=369481&view=rev
Log:
Added tests for special and unexpected PDUs
Modified:
directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java
Modified: directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java?rev=369481&r1=369480&r2=369481&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java (original)
+++ directory/trunks/common/ldap/src/test/java/org/apache/ldap/common/codec/LdapMessageTest.java Mon Jan 16 06:20:49 2006
@@ -176,4 +176,87 @@
Assert.fail( "We should not reach this point !" );
}
+
+
+ /**
+ * Test the decoding of null length messageId
+ */
+ public void testDecodeWrongProtocolOpMaxInt()
+ {
+
+ byte[] buffer = new byte[]
+ {
+ 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID = 1
+ 0x42, 0x00 // ProtocolOp
+ };
+
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x07 );
+
+ for ( int i = 0; i < 256; i++ )
+ {
+ buffer[5] = (byte)i;
+ stream.put( buffer );
+ stream.flip();
+
+ // Allocate a LdapMessage Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ // Decode a BindRequest PDU
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ switch (i)
+ {
+ case 0x42 :
+ case 0x4A :
+ case 0x50 : // AbandonRequest
+ case 0x60 :
+ case 0x61 :
+ case 0x63 :
+ case 0x64 :
+ case 0x65 :
+ case 0x66 :
+ case 0x67 :
+ case 0x68 :
+ case 0x69 :
+ case 0x6B :
+ case 0x6C :
+ case 0x6D :
+ case 0x6E :
+ case 0x6F :
+ case 0x73 :
+ case 0x77 :
+ case 0x78 :
+ assertTrue( true );
+ break;
+
+ default :
+ String res = de.getMessage();
+
+ if ( res.equals( "Bad transition !" ) ||
+ res.startsWith( "Universal tag " ) )
+ {
+ assertTrue( true );
+ }
+ else
+ {
+ fail( "Bad exception : " + res);
+ return;
+ }
+
+ break;
+ }
+ }
+
+ stream.clear();
+ }
+
+ Assert.fail( "We should not reach this point !" );
+ }
}