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 2011/10/15 12:15:15 UTC

svn commit: r1183615 - /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java

Author: elecharny
Date: Sat Oct 15 10:15:15 2011
New Revision: 1183615

URL: http://svn.apache.org/viewvc?rev=1183615&view=rev
Log:
Fixed compilation errors

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

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java?rev=1183615&r1=1183614&r2=1183615&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java Sat Oct 15 10:15:15 2011
@@ -25,6 +25,8 @@ import static org.apache.directory.serve
 import static org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum.INSUFFICIENT_PASSWORD_QUALITY;
 import static org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum.PASSWORD_TOO_SHORT;
 import static org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum.PASSWORD_EXPIRED;
+import static org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum.PASSWORD_TOO_YOUNG;
+import static org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyErrorEnum.PASSWORD_IN_HISTORY;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -317,122 +319,6 @@ public class PasswordPolicyTest extends 
 
     
     @Test
-    public void testPwdLength() throws Exception
-    {
-    	policyConfig.setPwdMinLength( 5 );
-    	policyConfig.setPwdMaxLength( 7 );
-    	policyConfig.setPwdCheckQuality( 2 );
-    	
-        LdapConnection connection = getAdminNetworkConnection( getLdapServer() );
-
-        Dn userDn = new Dn( "cn=userLen,ou=system" );
-        Entry userEntry = new DefaultEntry(
-            userDn.toString(), 
-            "ObjectClass: top", 
-            "ObjectClass: person", 
-            "cn: userLen",
-            "sn: userLen_sn", 
-            "userPassword: 1234");
-
-        AddRequest addRequest = new AddRequestImpl();
-        addRequest.setEntry( userEntry );
-        addRequest.addControl( PP_REQ_CTRL );
-
-        AddResponse addResp = connection.add( addRequest );
-        assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );
-
-        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
-        assertNotNull( respCtrl );
-        assertEquals( PasswordPolicyErrorEnum.PASSWORD_TOO_SHORT, respCtrl.getResponse().getPasswordPolicyError() );
-        
-        Attribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
-        pwdAt.clear();
-        pwdAt.add( "12345678" );
-        
-        addResp = connection.add( addRequest );
-        assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );
-        
-        respCtrl = getPwdRespCtrl( addResp );
-        assertNotNull( respCtrl );
-        assertEquals( PasswordPolicyErrorEnum.INSUFFICIENT_PASSWORD_QUALITY, respCtrl.getResponse().getPasswordPolicyError() );
-        
-        pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
-        pwdAt.clear();
-        pwdAt.add( "123456" );
-        
-        addResp = connection.add( addRequest );
-        assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
-    }
-
-
-    @Test
-    public void testPwdMaxAgeAndGraceAuth() throws Exception
-    {
-        policyConfig.setPwdMaxAge( 5 );
-        policyConfig.setPwdExpireWarning( 4 );
-        policyConfig.setPwdGraceAuthNLimit( 2 );
-        
-        LdapConnection connection = getAdminNetworkConnection( getLdapServer() );
-
-        Dn userDn = new Dn( "cn=userMaxAge,ou=system" );
-        String password = "12345";
-        Entry userEntry = new DefaultEntry(
-            userDn.toString(), 
-            "ObjectClass: top", 
-            "ObjectClass: person", 
-            "cn: userMaxAge",
-            "sn: userMaxAge_sn", 
-            "userPassword: " + password );
-
-        AddRequest addRequest = new AddRequestImpl();
-        addRequest.setEntry( userEntry );
-        addRequest.addControl( PP_REQ_CTRL );
-
-        connection.add( addRequest );
-
-        BindRequest bindReq = new BindRequestImpl();
-        bindReq.setName( userDn );
-        bindReq.setCredentials( password.getBytes() );
-        bindReq.addControl( PP_REQ_CTRL );
-        
-        LdapConnection userCon= new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        userCon.setTimeOut(0);
-
-        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent
-        
-        BindResponse bindResp = userCon.bind( bindReq );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
-        
-        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
-        assertNotNull( respCtrl );
-        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );
-        
-        Thread.sleep( 4000 ); // sleep for four seconds so that the password expires
-        
-        // bind for two more times, should succeed
-        bindResp = userCon.bind( bindReq );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
-        respCtrl = getPwdRespCtrl( bindResp );
-        assertNotNull( respCtrl );
-        assertEquals( 1, respCtrl.getResponse().getGraceAuthNsRemaining() );
-        
-        // this extra second sleep is necessary to modify pwdGraceUseTime attribute with a different timestamp
-        Thread.sleep( 1000 );
-        bindResp = userCon.bind( bindReq );
-        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
-        respCtrl = getPwdRespCtrl( bindResp );
-        assertEquals( 0, respCtrl.getResponse().getGraceAuthNsRemaining() );
-        
-        // this time it should fail
-        bindResp = userCon.bind( bindReq );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
-
-        respCtrl = getPwdRespCtrl( bindResp );
-        assertEquals( PASSWORD_EXPIRED, respCtrl.getResponse().getPasswordPolicyError() );
-    }
-
-    
-    @Test
     public void testPwdHistory() throws Exception
     {
         policyConfig.setPwdInHistory( 2 );