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 2017/03/12 00:09:53 UTC
svn commit: r1786543 -
/directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
Author: elecharny
Date: Sun Mar 12 00:09:53 2017
New Revision: 1786543
URL: http://svn.apache.org/viewvc?rev=1786543&view=rev
Log:
Added a server test for bcrypt hash
Modified:
directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
Modified: directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java?rev=1786543&r1=1786542&r2=1786543&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java (original)
+++ directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Sun Mar 12 00:09:53 2017
@@ -528,6 +528,54 @@ public class SimpleAuthenticationIT exte
assertNotNull( entry );
assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );
}
+
+
+ @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