Commit dd4bf53e authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Improve unit test (#1508)

parent 642e98e1
......@@ -11,14 +11,14 @@ BEGIN {
}
my ( $res, $user, $pwd );
my $maintests = 8;
my $maintests = 17;
my $mailSend = 0;
my $mail2 = 0;
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,12 +30,11 @@ SKIP: {
$dbh->do(
'CREATE TABLE users (user text,password text,name text, mail text)');
$dbh->do(
"INSERT INTO users VALUES ('dwho','dwho','Doctor who','dwho\@badwolf.org')"
"INSERT INTO users VALUES ('dwho','dwho','Doctor who','dwho\@badwolf.org')"
);
my $client = LLNG::Manager::Test->new(
{
ini => {
{ ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
......@@ -53,6 +52,7 @@ SKIP: {
dbiAuthPasswordHash => '',
dbiDynamicHashEnabled => 0,
dbiMailCol => 'mail',
passwordResetAllowedRetries => 4,
}
}
);
......@@ -66,8 +66,7 @@ SKIP: {
$query = 'mail=dwho%40badwolf.org';
# Post email
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
......@@ -79,19 +78,65 @@ SKIP: {
'Found link in mail' );
$query = $1;
ok(
$res =
$client->_get( '/resetpwd', query => $query, accept => 'text/html' ),
ok( $res = $client->_get(
'/resetpwd',
query => $query,
accept => 'text/html'
),
'Post mail token received by mail'
);
# Post mismatched passwords
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password #1' );
$query .= '&newpassword=zz&confirmpassword=zz';
$query .= '&newpassword=zz&confirmpassword=z';
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post mismatched passwords'
);
ok( $res->[2]->[0] =~ m%<span trmsg="34"></span>%, 'PE_34 found' )
or print STDERR Dumper( $res->[2]->[0] );
# Post empty password 1
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password #2' );
$query .= '&newpassword=&confirmpassword=zz';
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post empty newpassword'
);
ok( $res->[2]->[0] =~ m%<span trmsg="67"></span>%, 'PE_67 found' )
or print STDERR Dumper( $res->[2]->[0] );
# Post empty password 2
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
ok( $res->[2]->[0] =~ /newpassword/s, ' Ask for a new password #3' );
$query .= '&newpassword=zz&confirmpassword=';
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
),
'Post empty confirmpassword'
);
ok( $res->[2]->[0] =~ m%<span trmsg="67"></span>%, 'PE_67 found' )
or print STDERR Dumper( $res->[2]->[0] );
# Post new password
ok(
$res = $client->_post(
( $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 = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
......@@ -101,8 +146,7 @@ SKIP: {
ok( mail() =~ /Your password was changed/, 'Password was changed' );
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/',
IO::String->new('user=dwho&password=zz'),
length => 21
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment