|
|
|
@ -4,21 +4,21 @@ use IO::String; |
|
|
|
|
|
|
|
|
|
BEGIN { |
|
|
|
|
eval { |
|
|
|
|
unlink 't/userdb.db'; |
|
|
|
|
require 't/test-lib.pm'; |
|
|
|
|
require 't/smtp.pm'; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
my ( $res, $user, $pwd ); |
|
|
|
|
my $maintests = 16; |
|
|
|
|
my $maintests = 17; |
|
|
|
|
my $mailSend = 0; |
|
|
|
|
|
|
|
|
|
my $mail2 = 0; |
|
|
|
|
unlink 't/userdb.db'; |
|
|
|
|
|
|
|
|
|
SKIP: { |
|
|
|
|
eval |
|
|
|
|
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;'; |
|
|
|
|
'require Email::Sender::Simple;use GD::SecurityImage;use Image::Magick;'; |
|
|
|
|
if ($@) { |
|
|
|
|
skip 'Missing dependencies', $maintests; |
|
|
|
|
} |
|
|
|
@ -30,11 +30,11 @@ SKIP: { |
|
|
|
|
$dbh->do( |
|
|
|
|
'CREATE TABLE users (user text,password text,name text, mail text)'); |
|
|
|
|
$dbh->do( |
|
|
|
|
"INSERT INTO users VALUES ('yadd','yadd','Yadd','yadd\@badwolf.org')" |
|
|
|
|
); |
|
|
|
|
"INSERT INTO users VALUES ('yadd','yadd','Yadd','yadd\@badwolf.org')"); |
|
|
|
|
|
|
|
|
|
my $client = LLNG::Manager::Test->new( |
|
|
|
|
{ ini => { |
|
|
|
|
{ |
|
|
|
|
ini => { |
|
|
|
|
logLevel => 'error', |
|
|
|
|
useSafeJail => 1, |
|
|
|
|
portalDisplayRegister => 1, |
|
|
|
@ -61,9 +61,9 @@ SKIP: { |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
ok( $res = $client->_post( |
|
|
|
|
'/', |
|
|
|
|
IO::String->new('user=yadd&password=yadd&test=sql'), |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/', IO::String->new('user=yadd&password=yadd&test=sql'), |
|
|
|
|
length => 32 |
|
|
|
|
), |
|
|
|
|
'Auth query' |
|
|
|
@ -84,7 +84,8 @@ SKIP: { |
|
|
|
|
$query = 'mail=yadd%40badwolf.org'; |
|
|
|
|
|
|
|
|
|
# Post email |
|
|
|
|
ok( $res = $client->_post( |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/resetpwd', IO::String->new($query), |
|
|
|
|
query => 'test=sql', |
|
|
|
|
length => length($query), |
|
|
|
@ -92,21 +93,21 @@ SKIP: { |
|
|
|
|
), |
|
|
|
|
'Post mail' |
|
|
|
|
); |
|
|
|
|
my $pdata |
|
|
|
|
= 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' ); |
|
|
|
|
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' ); |
|
|
|
|
|
|
|
|
|
ok( mail() =~ m#a href="http://auth.example.com/resetpwd\?(.*?)"#, |
|
|
|
|
'Found link in mail' ); |
|
|
|
|
$query = $1; |
|
|
|
|
|
|
|
|
|
ok( $res = $client->_get( |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_get( |
|
|
|
|
'/resetpwd', |
|
|
|
|
query => $query, |
|
|
|
|
accept => 'text/html', |
|
|
|
|
( $sameBrowser ? ( cookie => $pdata ) : () ), |
|
|
|
|
), |
|
|
|
|
'Post mail token received by mail with ' |
|
|
|
|
. ( $sameBrowser ? 'the same browser' : 'another browser' ) |
|
|
|
|
. ( $sameBrowser ? 'the same browser' : 'another browser' ) |
|
|
|
|
); |
|
|
|
|
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' ); |
|
|
|
|
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' ); |
|
|
|
@ -115,7 +116,8 @@ SKIP: { |
|
|
|
|
$pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' ); |
|
|
|
|
|
|
|
|
|
# Post new password |
|
|
|
|
ok( $res = $client->_post( |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/resetpwd', IO::String->new($query), |
|
|
|
|
length => length($query), |
|
|
|
|
accept => 'text/html', |
|
|
|
@ -127,20 +129,21 @@ SKIP: { |
|
|
|
|
ok( mail() =~ /Your password was changed/, 'Password was changed' ); |
|
|
|
|
|
|
|
|
|
#print STDERR Dumper($query); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sleep 2; |
|
|
|
|
|
|
|
|
|
ok( $res = $client->_post( |
|
|
|
|
'/', IO::String->new('user=yadd&password=zz&test=sql'), |
|
|
|
|
length => 30 |
|
|
|
|
), |
|
|
|
|
'Auth query' |
|
|
|
|
); |
|
|
|
|
expectOK($res); |
|
|
|
|
$id = expectCookie($res); |
|
|
|
|
ok( |
|
|
|
|
$res = $client->_post( |
|
|
|
|
'/', |
|
|
|
|
IO::String->new('user=yadd&password=zz&test=sql'), |
|
|
|
|
length => 30 |
|
|
|
|
), |
|
|
|
|
'Auth query' |
|
|
|
|
); |
|
|
|
|
expectOK($res); |
|
|
|
|
$id = expectCookie($res); |
|
|
|
|
|
|
|
|
|
$client->logout($id); |
|
|
|
|
$client->logout($id); |
|
|
|
|
$dbh->do("UPDATE users SET password='dwho' WHERE user='yadd'"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|