directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1468016 - /directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
Date Mon, 15 Apr 2013 13:02:41 GMT
Author: elecharny
Date: Mon Apr 15 13:02:41 2013
New Revision: 1468016

URL: http://svn.apache.org/r1468016
Log:
Added a test to demonstrate the pwdAllowUserChange parameter

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java?rev=1468016&r1=1468015&r2=1468016&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
Mon Apr 15 13:02:41 2013
@@ -1162,4 +1162,50 @@ public class PasswordPolicyIT extends Ab
         userConnection.close();
         adminConnection.close();
     }
+
+
+    /**
+     * Check the pwdAllowUserChange
+     */
+    @Test
+    public void testPwdAllowUserChange() throws Exception
+    {
+        policyConfig.setPwdAllowUserChange( false );
+
+        Dn userDn = new Dn( "cn=userAllowUserChange,ou=system" );
+        LdapConnection adminConnection = getAdminNetworkConnection( getLdapServer() );
+
+        addUser( adminConnection, "userAllowUserChange", "12345" );
+
+        LdapConnection userConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort()
);
+        userConnection.setTimeOut( 0L );
+
+        // We should be able to bind
+        checkBindSuccess( userDn, "12345" );
+
+        // Now, try to change the password
+        ModifyRequest modReq = new ModifyRequestImpl();
+        modReq.setName( userDn );
+        modReq.addControl( PP_REQ_CTRL );
+        modReq.replace( "userPassword", "67890" );
+
+        userConnection = getNetworkConnectionAs( getLdapServer(), userDn.getName(), "12345"
);
+        userConnection.setTimeOut( 0L );
+
+        ModifyResponse modifyResponse = userConnection.modify( modReq );
+
+        assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, modifyResponse.getLdapResult().getResultCode()
);
+
+        // Now, allow the user to change his password
+        policyConfig.setPwdAllowUserChange( true );
+
+        modifyResponse = userConnection.modify( modReq );
+
+        assertEquals( ResultCodeEnum.SUCCESS, modifyResponse.getLdapResult().getResultCode()
);
+
+        userConnection.close();
+
+        checkBindSuccess( userDn, "67890" );
+        adminConnection.close();
+    }
 }



Mime
View raw message