Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3D70F200C43 for ; Sun, 12 Mar 2017 01:09:38 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3BFA8160B88; Sun, 12 Mar 2017 00:09:38 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 86241160B7B for ; Sun, 12 Mar 2017 01:09:37 +0100 (CET) Received: (qmail 63542 invoked by uid 500); 12 Mar 2017 00:09:36 -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 63533 invoked by uid 99); 12 Mar 2017 00:09:36 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Mar 2017 00:09:36 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 30AF13A086E for ; Sun, 12 Mar 2017 00:09:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1786542 - /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Date: Sun, 12 Mar 2017 00:09:35 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170312000936.30AF13A086E@svn01-us-west.apache.org> archived-at: Sun, 12 Mar 2017 00:09:38 -0000 Author: elecharny Date: Sun Mar 12 00:09:35 2017 New Revision: 1786542 URL: http://svn.apache.org/viewvc?rev=1786542&view=rev Log: Added a server test for bcrypt hash Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java?rev=1786542&r1=1786541&r2=1786542&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Sun Mar 12 00:09:35 2017 @@ -531,6 +531,54 @@ public class SimpleAuthenticationIT exte @Test + public void testBCRYPT() throws Exception + { + apply( getService(), getUserAddLdif() ); + String userDn = "uid=akarasulu,ou=users,ou=system"; + LdapConnection connection = getConnectionAs( getService(), userDn, "test" ); + + // Check that we can get the attributes + Entry entry = connection.lookup( userDn ); + assertNotNull( entry ); + assertTrue( entry.get( "uid" ).contains( "akarasulu" ) ); + + // now modify the password for akarasulu : 'secret', encrypted using CRYPT + ModifyRequest modReq = new ModifyRequestImpl(); + modReq.setName( new Dn( userDn ) ); + + // The hash is for 'secret' + modReq.replace( "userPassword", "{crypt}$2a$06$LH2xIb/TZmajuLJGDNuegeeY.SCwkg6YAVLNXTh8n4Xfb1uwmLXg6" ); + connection.modify( modReq ); + + // close and try with old password (should fail) + connection.close(); + + try + { + connection.bind( userDn, "test" ); + fail(); + } + catch ( LdapAuthenticationException lae ) + { + assertTrue( true ); + } + + // try again now with new password (should be successful) + connection.bind( userDn, "secret" ); + entry = connection.lookup( userDn ); + assertNotNull( entry ); + assertTrue( entry.get( "uid" ).contains( "akarasulu" ) ); + + // try again now with new password, to check that the + // cache is updated (should be successfull) + connection.bind( userDn, "secret" ); + entry = connection.lookup( userDn ); + assertNotNull( entry ); + assertTrue( entry.get( "uid" ).contains( "akarasulu" ) ); + } + + + @Test public void testInvalidateCredentialCacheForUpdatingAnotherUsersPassword() throws Exception { apply( getService(), getUserAddLdif() );