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 2013/04/15 16:07:14 UTC
svn commit: r1468082 -
/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
Author: elecharny
Date: Mon Apr 15 14:07:13 2013
New Revision: 1468082
URL: http://svn.apache.org/r1468082
Log:
Added a test for the pwdExpireWarning
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=1468082&r1=1468081&r2=1468082&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 14:07:13 2013
@@ -1197,4 +1197,61 @@ public class PasswordPolicyIT extends Ab
checkBindSuccess( userDn, "67890" );
adminConnection.close();
}
+
+
+ /**
+ * Check the pwdExpireWarning
+ */
+ @Test
+ public void testPwdExpireWarning() throws Exception
+ {
+ // The password will expire in 5 seconds
+ policyConfig.setPwdMaxAge( 5 );
+ policyConfig.setPwdGraceAuthNLimit( 0 );
+ // Send a warning 3 seconds before the expiration
+ policyConfig.setPwdExpireWarning( 3 );
+
+ Dn userDn = new Dn( "cn=userExpireWarning,ou=system" );
+ LdapConnection adminConnection = getAdminNetworkConnection( getLdapServer() );
+
+ addUser( adminConnection, "userExpireWarning", "12345" );
+
+ LdapConnection userConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+ userConnection.setTimeOut( 0L );
+
+ BindRequest bindReq = new BindRequestImpl();
+ bindReq.setDn( userDn );
+ bindReq.setCredentials( "12345" );
+ bindReq.addControl( PP_REQ_CTRL );
+
+ for ( int i = 0; i < 5; i++ )
+ {
+ BindResponse bindResponse = userConnection.bind( bindReq );
+ assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+
+ PasswordPolicy respCtrl = getPwdRespCtrl( bindResponse );
+ assertNotNull( respCtrl );
+
+ if ( i < 2 )
+ {
+ assertNull( respCtrl.getResponse() );
+ }
+ else
+ {
+ assertEquals( 5 - i, respCtrl.getResponse().getTimeBeforeExpiration() );
+ }
+
+ // Added an one second wait
+ Thread.sleep( 1000 );
+ }
+
+ // Added an one second wait
+ Thread.sleep( 1000 );
+
+ // We should not be able to login
+ checkBindFailure( userDn, "12345" );
+
+ userConnection.close();
+ adminConnection.close();
+ }
}