Commit 109e5840 authored by Xavier Guimard's avatar Xavier Guimard

Add StayConnected test (#1131)

parent ef444dab
......@@ -345,6 +345,7 @@ t/60-Status.t
t/61-GrantSession.t
t/62-SingleSession.t
t/63-History.t
t/64-StayConnected.t
t/90-Translations.t
t/99-pod.t
t/lmConf-1.js
......
......@@ -5,7 +5,7 @@
</head>
<body>
<p>Please wait...</p>
<form id="form" method="post" action="<TMPL_VAR NAME="ACTION">">
<form id="form" action="<TMPL_VAR NAME="ACTION">" method="post">
<input type="hidden" name="token" value="<TMPL_VAR NAME="TOKEN">" />
<input type="hidden" name="url" value="<TMPL_VAR NAME="URL">" />
<input type="hidden" name="fg" id="fg" value="" />
......
use Test::More;
use strict;
use IO::String;
require 't/test-lib.pm';
my $res;
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'error',
useSafeJail => 1,
stayConnected => 1,
accept => 'text/html',
}
}
);
# Try to authenticate
# -------------------
ok(
$res = $client->_post(
'/',
IO::String->new('user=dwho&password=dwho&stayconnected=1'),
length => 39
),
'Auth query'
);
count(1);
my $id = expectCookie($res);
my ( $host, $url, $query ) =
expectForm( $res, undef, '/registerbrowser', 'fg', 'token' );
# Push fingerprint
$query =~ s/fg=/fg=aaa/;
ok(
$res = $client->_post(
'/registerbrowser',
IO::String->new($query),
length => length($query),
cookie => "lemonldap=$id",
accept => 'text/html',
),
'Post fingerprint'
);
count(1);
expectRedirection( $res, 'http://auth.example.com/' );
my $cid = expectCookie( $res, 'llngconnexion' );
$client->logout($id);
# Try to connect with persistent connection cookie
ok(
$res = $client->_get(
'/',
cookie => "llngconnexion=$cid",
accept => 'text/html',
),
'Try to auth with persistent cookie'
);
count(1);
expectOK($res);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'fg', 'token' );
# Push fingerprint
$query =~ s/fg=/fg=aaa/;
ok(
$res = $client->_post(
'/',
IO::String->new($query),
cookie => "llngconnexion=$cid",
length => length($query),
accept => 'text/html',
),
'Post fingerprint'
);
count(1);
expectRedirection( $res, 'http://auth.example.com/' );
$id = expectCookie($res);
$client->logout($id);
# Try to connect with persistent connection cookie but bad fingerprint
ok(
$res = $client->_get(
'/',
cookie => "llngconnexion=$cid",
accept => 'text/html',
),
'Try to auth with persistent cookie'
);
count(1);
expectOK($res);
( $host, $url, $query ) = expectForm( $res, '#', undef, 'fg', 'token' );
# Push fingerprint
$query =~ s/fg=/fg=aaaa/;
ok(
$res = $client->_post(
'/',
IO::String->new($query),
cookie => "llngconnexion=$cid",
length => length($query),
accept => 'text/html',
),
'Post bad fingerprint'
);
count(1);
( $host, $url, $query ) = expectForm($res);
ok( $query =~ /user/, ' Get login form' );
count(1);
clean_sessions();
done_testing( count() );
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