Improve unit tests (#1605)

This commit is contained in:
Christophe Maudoux 2019-02-02 22:23:56 +01:00
parent 9987d28ac3
commit a084ba3c84
4 changed files with 48 additions and 33 deletions

View File

@ -9,7 +9,7 @@ BEGIN {
};
}
my $maintests = 24;
my $maintests = 26;
my ( $res, $user, $pwd, $host, $url, $query );
my $mailSend = 0;
@ -79,6 +79,12 @@ SKIP: {
# Test normal first access
# ------------------------
ok( $res = $client->_get( '/', accept => 'text/html' ),
'Get Menu', );
ok( $res->[2]->[0]
=~ m%<a class="btn btn-secondary" href="http://auth.example.com/register\?skin=bootstrap">%,
'Found Register link & submit button'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',
);
@ -103,7 +109,6 @@ SKIP: {
=~ m%<img src="/static/common/logos/logo_llng_old.png"%,
'Found custom Main Logo'
) or print STDERR Dumper( $res->[2]->[0] );
$query .= "&captcha=$captcha";
ok( $res = $client->_post(

View File

@ -9,7 +9,7 @@ BEGIN {
};
}
my $maintests = 10;
my $maintests = 12;
my ( $res, $user, $pwd );
SKIP: {
@ -33,6 +33,12 @@ SKIP: {
# Test normal first access
# ------------------------
ok( $res = $client->_get( '/', accept => 'text/html' ),
'Get Menu', );
ok( $res->[2]->[0]
=~ m%<a class="btn btn-secondary" href="http://auth.example.com/register\?skin=bootstrap">%,
'Found Register link & submit button'
) or print STDERR Dumper( $res->[2]->[0] );
ok(
$res = $client->_get( '/register', accept => 'text/html' ),
'Unauth request',

View File

@ -10,7 +10,7 @@ BEGIN {
}
my ( $res, $host, $url, $query );
my $maintests = 12;
my $maintests = 14;
my $mailSend = 0;
my $mail2 = 0;
@ -22,8 +22,7 @@ SKIP: {
}
my $client = LLNG::Manager::Test->new(
{
ini => {
{ ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
@ -40,6 +39,12 @@ SKIP: {
# Test form
# ------------------------
ok( $res = $client->_get( '/', accept => 'text/html' ),
'Get Menu', );
ok( $res->[2]->[0]
=~ m%<a class="btn btn-secondary" href="http://auth.example.com/resetpwd\?skin=bootstrap">%,
'Found ResetPassword link & submit button'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ),
'Reset form', );
( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail', 'token' );
@ -58,16 +63,15 @@ SKIP: {
ok( $ts = getCache()->get($token), ' Found token session' );
$ts = eval { JSON::from_json($ts) };
ok( $captcha = $ts->{captcha}, ' Found captcha value' );
ok(
$res->[2]->[0] =~ m%<img src="/static/common/logos/logo_llng_old.png"%,
ok( $res->[2]->[0]
=~ m%<img src="/static/common/logos/logo_llng_old.png"%,
'Found custom Main Logo'
) or print STDERR Dumper( $res->[2]->[0] );
$query .= "&captcha=$captcha";
# Post email
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'
@ -82,8 +86,7 @@ SKIP: {
'Found link in mail' );
$query = $1;
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/resetpwd',
query => $query,
accept => 'text/html'
@ -96,8 +99,7 @@ SKIP: {
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'

View File

@ -10,7 +10,7 @@ BEGIN {
}
my ( $res, $user, $pwd );
my $maintests = 9;
my $maintests = 11;
my $mailSend = 0;
my $mail2 = 0;
@ -23,8 +23,7 @@ SKIP: {
}
my $client = LLNG::Manager::Test->new(
{
ini => {
{ ini => {
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
@ -41,25 +40,30 @@ SKIP: {
# Test form
# ------------------------
ok( $res = $client->_get( '/', accept => 'text/html' ),
'Get Menu', );
ok( $res->[2]->[0]
=~ m%<a class="btn btn-secondary" href="http://auth.example.com/resetpwd\?skin=bootstrap">%,
'Found ResetPassword link & submit button'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res = $client->_get( '/resetpwd', accept => 'text/html' ),
'Reset form', );
my ( $host, $url, $query ) =
expectForm( $res, '#', undef, 'mail', 'token' );
my ( $host, $url, $query )
= expectForm( $res, '#', undef, 'mail', 'token' );
$query =~ s/mail=&//;
$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'
),
'Post mail'
);
ok(
$res->[2]->[0] =~ m%<img src="/static/common/logos/logo_llng_old.png"%,
ok( $res->[2]->[0]
=~ m%<img src="/static/common/logos/logo_llng_old.png"%,
'Found custom Main Logo'
) or print STDERR Dumper( $res->[2]->[0] );
ok( mail() =~ m%Content-Type: image/png; name="logo_llng_old.png"%,
@ -69,8 +73,7 @@ SKIP: {
'Found link in mail' );
$query = $1;
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/resetpwd',
query => $query,
accept => 'text/html'
@ -83,8 +86,7 @@ SKIP: {
$query .= '&newpassword=zz&confirmpassword=zz';
# Post new password
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/resetpwd', IO::String->new($query),
length => length($query),
accept => 'text/html'