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 2005/05/31 00:23:14 UTC
svn commit: r179165 -
/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java
Author: elecharny
Date: Mon May 30 15:23:13 2005
New Revision: 179165
URL: http://svn.apache.org/viewcvs?rev=179165&view=rev
Log:
Added the test case that broke the decoder ! As the mechanism has been fixed, this is now ok.
Basically, I just added a sasl credential just after the ldapresult. Boooooommmmm.
Modified:
directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java?rev=179165&r1=179164&r2=179165&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/BindResponseTest.java Mon May 30 15:23:13 2005
@@ -93,4 +93,58 @@
Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", br.getLdapResult().getMatchedDN() );
Assert.assertEquals( "", br.getLdapResult().getErrorMessage() );
}
+
+ /**
+ * Test the decoding of a BindResponse
+ */
+ public void testDecodeBindResponseServerSASL()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x31 );
+
+ stream.put(
+ new byte[]
+ {
+ 0x30, 0x2F, // LDAPMessage ::=SEQUENCE {
+ 0x02, 0x01, 0x01, // messageID MessageID
+ 0x61, 0x2A, // CHOICE { ..., bindResponse BindResponse, ...
+ // BindResponse ::= APPLICATION[1] SEQUENCE {
+ // COMPONENTS OF LDAPResult,
+ 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
+ // resultCode ENUMERATED {
+ // success (0), ...
+ // },
+ 0x04, 0x1F, // matchedDN 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',
+ 0x04, 0x00, // errorMessage LDAPString,
+ // referral [3] Referral OPTIONAL }
+ (byte)0x87, 0x02, 'A', 'B' // serverSaslCreds [7] OCTET STRING OPTIONAL }
+ } );
+
+ stream.flip();
+
+ // Allocate a BindRequest Container
+ IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+
+ try
+ {
+ ldapDecoder.decode( stream, ldapMessageContainer );
+ }
+ catch ( DecoderException de )
+ {
+ de.printStackTrace();
+ Assert.fail( de.getMessage() );
+ }
+
+ LdapMessagePOJO message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+ BindResponsePOJO br = ( BindResponsePOJO ) ( message.getProtocolOp() );
+
+ Assert.assertEquals( 1, message.getMessageId() );
+ Assert.assertEquals( 0, br.getLdapResult().getResultCode() );
+ Assert.assertEquals( "uid=akarasulu,dc=example,dc=com", br.getLdapResult().getMatchedDN() );
+ Assert.assertEquals( "", br.getLdapResult().getErrorMessage() );
+ Assert.assertEquals( "AB", new String(br.getServerSaslCreds()));
+ }
}