Pwd reset in progress (#595)
parent
2582fc21f1
commit
7a3725db9d
File diff suppressed because one or more lines are too long
@ -0,0 +1,95 @@ |
||||
use Test::More; |
||||
use strict; |
||||
use IO::String; |
||||
|
||||
BEGIN { |
||||
require MIME::Lite; |
||||
require 't/test-lib.pm'; |
||||
} |
||||
|
||||
my ( $res, $user, $pwd ); |
||||
my $mailSend = 0; |
||||
|
||||
my $mail2 = 0; |
||||
|
||||
my $client = LLNG::Manager::Test->new( |
||||
{ |
||||
ini => { |
||||
logLevel => 'debug', |
||||
useSafeJail => 1, |
||||
portalDisplayRegister => 1, |
||||
authentication => 'Demo', |
||||
userDB => 'Demo', |
||||
passwordDB => 'Demo', |
||||
captcha_mail_enabled => 0, |
||||
portalDisplayResetPassword => 1, |
||||
} |
||||
} |
||||
); |
||||
|
||||
# Test form |
||||
# ------------------------ |
||||
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ), 'Reset form', ); |
||||
count(1); |
||||
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail' ); |
||||
|
||||
$query = 'mail=dwho%40badwolf.org'; |
||||
|
||||
# Post email |
||||
ok( |
||||
$res = $client->_post( |
||||
'/resetpwd', IO::String->new($query), |
||||
length => length($query), |
||||
accept => 'text/html' |
||||
), |
||||
'Post email' |
||||
); |
||||
count(1); |
||||
|
||||
# $query has been set by MIME::Lite::send |
||||
ok( |
||||
$res = $client->_get( '/resetpwd', query => $query, accept => 'text/html' ), |
||||
'Post mail token' |
||||
); |
||||
count(1); |
||||
( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail_token' ); |
||||
ok($res->[2]->[0]=~/newpassword/s,' Ask for a new password'); |
||||
count(1); |
||||
|
||||
#print STDERR Dumper($query); |
||||
|
||||
clean_sessions(); |
||||
|
||||
done_testing( count() ); |
||||
|
||||
no warnings 'redefine'; |
||||
|
||||
sub MIME::Lite::send { |
||||
my ($mail) = @_; |
||||
pass('----- Mail given to MIME::Lite -----'); |
||||
ok( $mail->header_as_string =~ /dwho\@badwolf.org/s, 'Found dest' ) |
||||
or explain( $mail->header_as_string, 'To: dwho@badwolf.org' ); |
||||
count(2); |
||||
unless ($mail2) { |
||||
$mailSend = 1; |
||||
ok( |
||||
$mail->body_as_string =~ |
||||
m#a href="http://auth.example.com/resetpwd\?(.*?)"#, |
||||
'Found link' |
||||
); |
||||
count(1); |
||||
$query = $1; |
||||
$mail2++; |
||||
} |
||||
else { |
||||
$mailSend = 2; |
||||
ok( |
||||
$mail->body_as_string =~ |
||||
m#yourLoginIs.+?<b>(\w+)</b>.*?pwdIs.+?<b>(.*?)</b>#s, |
||||
'Get login/pwd' |
||||
); |
||||
( $user, $pwd ) = ( $1, $2 ); |
||||
count(1); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue