lemonldap-ng/lemonldap-ng-portal/t/50-IssuerGet.t

62 lines
1.2 KiB
Perl
Raw Normal View History

2016-06-12 21:26:14 +02:00
use Test::More;
use strict;
use IO::String;
require 't/test-lib.pm';
my $res;
2016-11-14 13:34:46 +01:00
my $client = LLNG::Manager::Test->new(
2016-06-12 21:26:14 +02:00
{
2016-11-14 13:34:46 +01:00
ini => {
logLevel => 'error',
useSafeJail => 1,
issuerDBGetActivation => 1,
issuerDBGetPath => '^/test/',
issuerDBGetParameters =>
{ 'test1.example.com' => { ID => '_session_id' } }
}
2016-06-12 21:26:14 +02:00
}
);
# Try yo authenticate
# -------------------
ok(
2016-11-14 13:34:46 +01:00
$res = $client->_post(
2016-06-12 21:26:14 +02:00
'/',
IO::String->new('user=dwho&password=dwho'),
length => 23
),
'Auth query'
);
2016-12-23 11:02:21 +01:00
count(1);
expectOK($res);
my $id = expectCookie($res);
2016-06-12 21:26:14 +02:00
2016-06-12 21:38:02 +02:00
# Test GET login
2016-06-12 21:26:14 +02:00
ok(
2016-11-14 13:34:46 +01:00
$res = $client->_get(
2016-06-12 21:26:14 +02:00
'/test',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
accept => 'text/html'
),
2016-06-12 21:38:02 +02:00
'GET request with good url'
2016-06-12 21:26:14 +02:00
);
2016-12-23 11:02:21 +01:00
count(1);
2016-12-26 10:23:35 +01:00
expectRedirection( $res, "http://test1.example.com/?ID=$id" );
2016-06-12 21:26:14 +02:00
2016-06-12 21:38:02 +02:00
# Test not logged access
ok(
2016-11-14 13:34:46 +01:00
$res = $client->_get(
'/test', query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
2016-06-12 21:38:02 +02:00
),
'Not logged access'
);
2016-12-23 11:02:21 +01:00
count(1);
expectReject($res);
2016-06-12 21:38:02 +02:00
2016-06-12 21:26:14 +02:00
clean_sessions();
done_testing( count() );