diff --git a/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t b/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t index 3293c6806..760841348 100644 --- a/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t +++ b/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t @@ -13,7 +13,7 @@ BEGIN { } my ( $res, $user, $pwd ); -my $maintests = 17; +my $maintests = 19; my $mailSend = 0; my $mail2 = 0; @@ -54,7 +54,12 @@ SKIP: { dbiAuthPasswordHash => '', dbiDynamicHashEnabled => 0, dbiMailCol => 'mail', + portalDisplayPasswordPolicy => 1, + passwordPolicyActivation => 0, passwordResetAllowedRetries => 4, + passwordPolicyMinDigit => 2, + passwordPolicyMinSpeChar => 1, + passwordPolicySpecialChar => '__ALL__' } } ); @@ -141,8 +146,16 @@ SKIP: { # Post new password ( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' ); ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password #4' ); - - $query .= '&newpassword=zz&confirmpassword=zz'; + ok( + $res->[2]->[0] !~ /passwordPolicySpecialChar/, + ' Password special char list not found' + ); + ok( + $res->[2]->[0] =~ +/Minimal digit characters:<\/span> 2/, + ' Found password policy min digit == 2' + ); + $query .= '&newpassword=zz11#&confirmpassword=zz11#'; ok( $res = $client->_post( '/resetpwd', IO::String->new($query), @@ -157,8 +170,8 @@ SKIP: { ok( $res = $client->_post( '/', - IO::String->new('user=dwho&password=zz'), - length => 21 + IO::String->new('user=dwho&password=zz11#'), + length => 24 ), 'Auth query' ); diff --git a/lemonldap-ng-portal/t/43-MailPasswordReset-with-captcha.t b/lemonldap-ng-portal/t/43-MailPasswordReset-with-captcha.t index dbc765290..81e960e96 100644 --- a/lemonldap-ng-portal/t/43-MailPasswordReset-with-captcha.t +++ b/lemonldap-ng-portal/t/43-MailPasswordReset-with-captcha.t @@ -10,7 +10,7 @@ BEGIN { } my ( $res, $host, $url, $query ); -my $maintests = 16; +my $maintests = 18; my $mailSend = 0; my $mail2 = 0; @@ -33,6 +33,13 @@ SKIP: { requireToken => 1, portalDisplayResetPassword => 1, portalMainLogo => 'common/logos/logo_llng_old.png', + passwordPolicyActivation => 1, + passwordPolicyMinUpper => 1, + passwordPolicyMinLower => 1, + passwordPolicyMinDigit => 2, + passwordPolicyMinSpeChar => 1, + randomPasswordRegexp => '', + passwordPolicySpecialChar => '*#@' } } ); @@ -104,7 +111,7 @@ m#[2]->[0] =~ /newpassword/s, ' Ask for a new password' ); - $query .= '&newpassword=zz&confirmpassword=zz'; + $query .= '&reset=1'; # Post new password ok( @@ -115,7 +122,9 @@ m#Your new password is<\/span>/, 'New password sent' ); + ok( mail() =~ /(.+?)<\/b>/s, 'New generated password found' ); + ok( $1 =~ /[A-Z]{1}[a-z]{1}\d{2}[*#@]{1}/, 'New generated password matches' ); #print STDERR Dumper($query); } diff --git a/lemonldap-ng-portal/t/43-MailPasswordReset.t b/lemonldap-ng-portal/t/43-MailPasswordReset.t index bc456ca8a..7504c4226 100644 --- a/lemonldap-ng-portal/t/43-MailPasswordReset.t +++ b/lemonldap-ng-portal/t/43-MailPasswordReset.t @@ -10,7 +10,7 @@ BEGIN { } my ( $res, $user, $pwd ); -my $maintests = 12; +my $maintests = 18; SKIP: { eval @@ -21,15 +21,22 @@ SKIP: { my $client = LLNG::Manager::Test->new( { ini => { - logLevel => 'error', - useSafeJail => 1, - portalDisplayRegister => 1, - authentication => 'Demo', - userDB => 'Same', - passwordDB => 'Demo', - captcha_mail_enabled => 0, - portalDisplayResetPassword => 1, - portalMainLogo => 'common/logos/logo_llng_old.png', + logLevel => 'error', + useSafeJail => 1, + portalDisplayRegister => 1, + authentication => 'Demo', + userDB => 'Same', + passwordDB => 'Demo', + captcha_mail_enabled => 0, + portalDisplayResetPassword => 1, + portalMainLogo => 'common/logos/logo_llng_old.png', + portalDisplayPasswordPolicy => 1, + passwordPolicyActivation => 1, + passwordPolicyMinUpper => 1, + passwordPolicyMinLower => 1, + passwordPolicyMinDigit => 2, + passwordPolicyMinSpeChar => 1, + passwordPolicySpecialChar => '&%#' } } ); @@ -87,8 +94,34 @@ SKIP: { ); ( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' ); ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' ); - - $query .= '&newpassword=zz&confirmpassword=zz'; + ok( $res->[2]->[0] =~ //, + ' Found password policy' ); + ok( + $res->[2]->[0] =~ +/Minimal lower characters:<\/span> 1/, + ' Found password policy min lower == 1' + ); + ok( + $res->[2]->[0] =~ +/Minimal upper characters:<\/span> 1/, + ' Found password policy min upper == 1' + ); + ok( + $res->[2]->[0] =~ +/Minimal digit characters:<\/span> 2/, + ' Found password policy min digit == 2' + ); + ok( + $res->[2]->[0] =~ +/Minimal special characters:<\/span> 1/, + ' Found password policy min speChar == 1' + ); + ok( + $res->[2]->[0] =~ +/Allowed special characters:<\/span> &%#/, + ' Found password special char list' + ); + $query .= '&newpassword=zZ11#&confirmpassword=zZ11#'; # Post new password ok(