Commit f0e230d8 authored by Christophe Maudoux's avatar Christophe Maudoux

Improve notification unit tests to avoid issue (#1522)

parent c031e63f
......@@ -85,8 +85,26 @@ ok(
),
"Don't accept notification"
);
ok( $res->[0] == 200, "Don't receive redirection" )
or explain( [ $res->[0], $res->[1] ], 200 );
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
# Try to validate notification without accepting it
$str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok(
$res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
accept => 'text/html',
length => length($str),
),
"Don't accept notification"
);
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
# Try to validate notification
......
......@@ -22,28 +22,25 @@ print F '[
close F;
my $client = LLNG::Manager::Test->new(
{
ini => {
{ ini => {
logLevel => 'error',
useSafeJail => 1,
notification => 1,
templatesDir => 'site/templates/',
notificationStorage => 'File',
notificationStorageOptions => {
dirName => 't'
},
oldNotifFormat => 0,
notificationStorageOptions => { dirName => 't' },
oldNotifFormat => 0,
}
}
);
# Try yo authenticate
# -------------------
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/',
IO::String->new(
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='),
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='
),
accept => 'text/html',
length => 64,
),
......@@ -55,8 +52,7 @@ my $id = expectCookie($res);
expectForm( $res, undef, '/notifback', 'reference1x1', 'url' );
# Verify that cookie is ciphered (session unvalid)
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
......@@ -68,8 +64,7 @@ expectReject($res);
# Try to validate notification without accepting it
my $str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
......@@ -78,15 +73,47 @@ ok(
),
"Don't accept notification"
);
ok( $res->[0] == 200, "Don't receive redirection" )
or explain( [ $res->[0], $res->[1] ], 200 );
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
# Try to validate notification without accepting it
$str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
accept => 'text/html',
length => length($str),
),
"Don't accept notification"
);
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
# Try to validate notification without accepting it
$str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
accept => 'text/html',
length => length($str),
),
"Don't accept notification"
);
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
count(2);
# Try to validate notification
$str =
'reference1x1=testref&check1x1x1=accepted&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok(
$res = $client->_post(
$str
= 'reference1x1=testref&check1x1x1=accepted&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
......@@ -102,8 +129,7 @@ count(2);
$id = expectCookie($res);
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/',
cookie => "lemonldap=$id",
length => 64,
......
......@@ -6,7 +6,7 @@ require 't/test-lib.pm';
my $res;
my $file = 't/20160530_dwho_dGVzdHJlZg==.xml';
my $maintests = 8;
my $maintests = 12;
SKIP: {
eval { require XML::LibXML; require XML::LibXSLT; };
......@@ -25,28 +25,24 @@ SKIP: {
close F;
my $client = LLNG::Manager::Test->new(
{
ini => {
{ ini => {
logLevel => 'error',
useSafeJail => 1,
notification => 1,
templatesDir => 'site/templates/',
notificationStorage => 'File',
notificationStorageOptions => {
dirName => 't'
},
oldNotifFormat => 1,
notificationStorageOptions => { dirName => 't' },
oldNotifFormat => 1,
}
}
);
# Try yo authenticate
# -------------------
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/',
IO::String->new(
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='
),
accept => 'text/html',
length => 64,
......@@ -58,8 +54,7 @@ SKIP: {
expectForm( $res, undef, '/notifback', 'reference1x1', 'url' );
# Verify that cookie is ciphered (session unvalid)
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
......@@ -70,8 +65,7 @@ SKIP: {
# Try to validate notification without accepting it
my $str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok(
$res = $client->_post(
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
......@@ -80,14 +74,44 @@ SKIP: {
),
"Don't accept notification"
);
ok( $res->[0] == 200, "Don't receive redirection" )
or explain( [ $res->[0], $res->[1] ], 200 );
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
# Try to validate notification without accepting it
$str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
accept => 'text/html',
length => length($str),
),
"Don't accept notification"
);
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
# Try to validate notification without accepting it
$str = 'reference1x1=testref&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
accept => 'text/html',
length => length($str),
),
"Don't accept notification"
);
ok( $res->[2]->[0] =~ qr%<h2 class="notifText">Test title</h2>%,
'Notification displayed' )
or print STDERR Dumper( $res->[2]->[0] );
# Try to validate notification
$str =
'reference1x1=testref&check1x1x1=accepted&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok(
$res = $client->_post(
$str
= 'reference1x1=testref&check1x1x1=accepted&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==';
ok( $res = $client->_post(
'/notifback',
IO::String->new($str),
cookie => "lemonldap=$id",
......@@ -102,8 +126,7 @@ SKIP: {
$id = expectCookie($res);
ok(
$res = $client->_get(
ok( $res = $client->_get(
'/',
cookie => "lemonldap=$id",
length => 64,
......
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