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

91 lines
1.9 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;
2019-02-07 09:27:56 +01:00
my $client = LLNG::Manager::Test->new( {
2016-11-14 13:34:46 +01:00
ini => {
2019-02-07 17:21:56 +01:00
logLevel => 'error',
2016-11-14 13:34:46 +01:00
useSafeJail => 1,
issuerDBGetActivation => 1,
issuerDBGetRule => '$uid eq "dwho"',
2016-11-14 13:34:46 +01:00
issuerDBGetPath => '^/test/',
issuerDBGetParameters =>
{ 'test1.example.com' => { ID => '_session_id' } }
}
2016-06-12 21:26:14 +02:00
}
);
2019-02-10 22:29:50 +01:00
# Try to authenticate with an unauthorized user
# ---------------------------------------------
ok(
$res = $client->_post(
'/',
IO::String->new('user=rtyler&password=rtyler'),
length => 27
),
'Auth query'
);
count(1);
expectOK($res);
my $id = expectCookie($res);
# Test GET login
ok(
$res = $client->_get(
'/test',
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
cookie => "lemonldap=$id",
accept => 'text/html'
),
'GET request with good url'
);
count(1);
ok( $res->[2]->[0] =~ /trmsg="92"/, 'Reject reason is 92' )
2019-03-07 18:22:16 +01:00
or print STDERR Dumper( $res->[2]->[0] );
2019-02-10 22:29:50 +01:00
count(1);
# Try to authenticate with an authorized user
# -------------------------------------------
2016-06-12 21:26:14 +02:00
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);
2019-02-10 22:29:50 +01:00
$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() );