Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 86095 invoked from network); 4 Sep 2005 12:46:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Sep 2005 12:46:52 -0000 Received: (qmail 10301 invoked by uid 500); 4 Sep 2005 12:46:52 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 10248 invoked by uid 500); 4 Sep 2005 12:46:51 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 10235 invoked by uid 99); 4 Sep 2005 12:46:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Sep 2005 05:46:51 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 04 Sep 2005 05:47:05 -0700 Received: (qmail 86039 invoked by uid 65534); 4 Sep 2005 12:46:50 -0000 Message-ID: <20050904124650.86038.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r278586 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java Date: Sun, 04 Sep 2005 12:46:50 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Sun Sep 4 05:46:45 2005 New Revision: 278586 URL: http://svn.apache.org/viewcvs?rev=278586&view=rev Log: Added a test : a BindRequest with a null name (anonymous authentication) Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java?rev=278586&r1=278585&r2=278586&view=diff ============================================================================== --- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java (original) +++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/BindRequestTest.java Sun Sep 4 05:46:45 2005 @@ -107,10 +107,11 @@ } /** - * Test the decoding of a BindRequest with Simple authentication + * Test the decoding of a BindRequest with Simple authentication, + * no name * and no controls */ - public void testDecodeBindRequestNoName() + public void testDecodeBindRequestSimpleNoName() { Asn1Decoder ldapDecoder = new LdapDecoder(); @@ -145,6 +146,77 @@ } Assert.fail("Should never reach this point."); + } + + /** + * Test the decoding of a BindRequest with Simple authentication, + * empty name (an anonymous bind) + * and no controls + */ + public void testDecodeBindRequestSimpleEmptyName() + { + Asn1Decoder ldapDecoder = new LdapDecoder(); + + ByteBuffer stream = ByteBuffer.allocate( 0x16 ); + stream.put( + new byte[] + { + 0x30, 0x14, // LDAPMessage ::=SEQUENCE { + 0x02, 0x01, 0x01, // messageID MessageID + 0x60, 0x0F, // CHOICE { ..., bindRequest BindRequest, ... + // BindRequest ::= APPLICATION[0] SEQUENCE { + 0x02, 0x01, 0x03, // version INTEGER (1..127), + 0x04, 0x00, // name LDAPDN, + ( byte ) 0x80, 0x08, // authentication AuthenticationChoice + // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, ... + 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' + } ); + + String decodedPdu = StringUtils.dumpBytes( stream.array() ); + + stream.flip(); + + // Allocate a LdapMessage Container + IAsn1Container ldapMessageContainer = new LdapMessageContainer(); + + // Decode the BindRequest PDU + try + { + ldapDecoder.decode( stream, ldapMessageContainer ); + } + catch ( DecoderException de ) + { + de.printStackTrace(); + Assert.fail( de.getMessage() ); + } + + // Check the decoded BindRequest + LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage(); + BindRequest br = message.getBindRequest(); + + Assert.assertEquals( 1, message.getMessageId() ); + Assert.assertEquals( 3, br.getVersion() ); + Assert.assertEquals( "", br.getName() ); + Assert.assertEquals( true, ( br.getAuthentication() instanceof SimpleAuthentication ) ); + Assert.assertEquals( "password", ( ( (SimpleAuthentication)br.getAuthentication() ).getSimple().toString() ) ); + + // Check the length + Assert.assertEquals(0x16, message.computeLength()); + + // Check the encoding + try + { + ByteBuffer bb = message.encode( null ); + + String encodedPdu = StringUtils.dumpBytes( bb.array() ); + + Assert.assertEquals(encodedPdu, decodedPdu ); + } + catch ( EncoderException ee ) + { + ee.printStackTrace(); + Assert.fail( ee.getMessage() ); + } } /**