2017-02-17 08:40:15 +01:00
|
|
|
use Test::More;
|
|
|
|
use strict;
|
|
|
|
use IO::String;
|
2018-10-02 20:29:43 +02:00
|
|
|
use Data::Dumper;
|
2017-02-17 08:40:15 +01:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
require 't/test-lib.pm';
|
|
|
|
}
|
|
|
|
|
|
|
|
my $res;
|
|
|
|
|
2019-02-07 09:27:56 +01:00
|
|
|
my $client = LLNG::Manager::Test->new( {
|
2018-11-26 14:40:21 +01:00
|
|
|
ini => {
|
2018-10-07 11:40:26 +02:00
|
|
|
logLevel => 'error',
|
|
|
|
authentication => 'Demo',
|
|
|
|
userdb => 'Same',
|
2018-10-21 22:12:56 +02:00
|
|
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
2018-10-07 11:40:26 +02:00
|
|
|
grantSessionRules => {
|
2018-10-07 15:38:02 +02:00
|
|
|
'$uid . " not allowed"##rule1' => '$uid ne "dwho"',
|
2018-10-07 15:40:45 +02:00
|
|
|
'Rtyler_Allowed##rule3' => '$uid eq "rtyler"',
|
2019-02-04 17:40:18 +01:00
|
|
|
'##rule2' => '$uid ne "msmith"',
|
|
|
|
'##rule4' => '$uid ne "jdoe"',
|
2017-02-17 08:40:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2017-02-17 08:40:15 +01:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho'),
|
2018-10-02 20:29:43 +02:00
|
|
|
accept => 'text/html',
|
2017-02-17 08:40:15 +01:00
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
2018-10-07 15:38:02 +02:00
|
|
|
ok( $res->[2]->[0] =~ /<h3 trspan="dwho not allowed">dwho not allowed<\/h3>/,
|
2018-11-26 14:40:21 +01:00
|
|
|
'dwho rejected with custom message and session data' )
|
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-02 20:29:43 +02:00
|
|
|
count(1);
|
2019-02-04 17:40:18 +01:00
|
|
|
|
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=ohwd'),
|
|
|
|
accept => 'text/html',
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
2019-02-05 23:12:17 +01:00
|
|
|
ok( $res->[2]->[0] =~ /<span trmsg="5"><\/span><\/div>/,
|
|
|
|
'dwho rejected with PE_BADCREDENTIALS' )
|
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2019-02-04 17:40:18 +01:00
|
|
|
count(1);
|
2019-03-18 11:53:30 +01:00
|
|
|
ok( $res->[2]->[0] =~ m%<span trspan="connect">Connect</span>%,
|
|
|
|
'Found connect button' )
|
2019-02-05 23:12:17 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2019-02-04 19:20:28 +01:00
|
|
|
count(1);
|
|
|
|
|
2019-02-04 17:40:18 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho'),
|
|
|
|
accept => 'text/html',
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
ok( $res->[2]->[0] =~ /<h3 trspan="dwho not allowed">dwho not allowed<\/h3>/,
|
|
|
|
'dwho rejected with custom message and session data' )
|
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
|
|
|
count(1);
|
|
|
|
|
2018-10-07 11:40:26 +02:00
|
|
|
ok( $res->[2]->[0] =~ qr%src="/static/common/js/info.(?:min\.)?js"></script>%,
|
2018-11-26 14:40:21 +01:00
|
|
|
'Found INFO js' )
|
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-02 20:40:55 +02:00
|
|
|
count(1);
|
2018-10-21 22:12:56 +02:00
|
|
|
ok( $res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,
|
2018-10-13 22:26:09 +02:00
|
|
|
'Found custom Main Logo' )
|
2018-11-26 14:40:21 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-13 22:26:09 +02:00
|
|
|
count(1);
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2018-10-02 20:29:43 +02:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=rtyler&password=rtyler'),
|
|
|
|
length => 27
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
expectCookie($res);
|
|
|
|
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2018-10-02 20:29:43 +02:00
|
|
|
'/',
|
2019-02-04 17:40:18 +01:00
|
|
|
IO::String->new('user=msmith&password=msmith'),
|
2018-10-02 20:29:43 +02:00
|
|
|
accept => 'text/html',
|
2019-02-04 17:40:18 +01:00
|
|
|
length => 27
|
2018-10-02 20:29:43 +02:00
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
2019-02-04 17:40:18 +01:00
|
|
|
$res->[2]->[0] =~ /<span trmsg="41"><\/span><\/div>/,
|
2018-10-07 11:40:26 +02:00
|
|
|
'rtyler rejected with PE_SESSIONNOTGRANTED'
|
|
|
|
) or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-02 20:29:43 +02:00
|
|
|
count(1);
|
2019-02-04 17:40:18 +01:00
|
|
|
|
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
|
|
|
'/',
|
|
|
|
IO::String->new('user=jdoe&password=jdoe'),
|
|
|
|
accept => 'text/html',
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'Auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
ok(
|
|
|
|
$res->[2]->[0] =~ /<span trmsg="5"><\/span><\/div>/,
|
|
|
|
'rtyler rejected with PE_BADCREDENTIALS'
|
|
|
|
) or print STDERR Dumper( $res->[2]->[0] );
|
|
|
|
count(1);
|
2019-03-18 11:53:30 +01:00
|
|
|
ok( $res->[2]->[0] =~ m%<span trspan="connect">Connect</span>%,
|
|
|
|
'Found connect button' )
|
2019-02-05 23:12:17 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2019-02-04 19:20:28 +01:00
|
|
|
count(1);
|
2019-02-04 17:40:18 +01:00
|
|
|
|
2018-10-21 22:12:56 +02:00
|
|
|
ok( $res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,
|
2018-10-13 22:26:09 +02:00
|
|
|
'Found custom Main Logo' )
|
2018-11-26 14:40:21 +01:00
|
|
|
or print STDERR Dumper( $res->[2]->[0] );
|
2018-10-13 22:26:09 +02:00
|
|
|
count(1);
|
2017-02-17 08:40:15 +01:00
|
|
|
|
2018-09-05 09:19:01 +02:00
|
|
|
my $c = getCookies($res);
|
|
|
|
ok( not(%$c), 'No cookie' );
|
|
|
|
count(1);
|
|
|
|
|
2018-06-05 23:13:18 +02:00
|
|
|
&Lemonldap::NG::Handler::Main::cfgNum( 0, 0 );
|
2019-02-07 09:27:56 +01:00
|
|
|
$client = LLNG::Manager::Test->new( {
|
2018-11-26 14:40:21 +01:00
|
|
|
ini => {
|
2018-10-01 15:20:41 +02:00
|
|
|
authentication => 'Demo',
|
|
|
|
userdb => 'Same',
|
2018-10-07 11:40:26 +02:00
|
|
|
grantSessionRules => { '' => '$uid eq "dwho"', }
|
2017-02-17 08:40:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2018-11-26 14:40:21 +01:00
|
|
|
ok(
|
|
|
|
$res = $client->_post(
|
2017-02-17 08:40:15 +01:00
|
|
|
'/',
|
|
|
|
IO::String->new('user=dwho&password=dwho'),
|
|
|
|
length => 23
|
|
|
|
),
|
|
|
|
'auth query'
|
|
|
|
);
|
|
|
|
count(1);
|
|
|
|
expectOK($res);
|
|
|
|
expectCookie($res);
|
|
|
|
|
|
|
|
clean_sessions();
|
|
|
|
|
|
|
|
done_testing( count() );
|