directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
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 GMT
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() );



Mime
View raw message