directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1786543 - /directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
Date Sun, 12 Mar 2017 00:09:53 GMT
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



Mime
View raw message