2016-03-17 23:19:44 +01:00
|
|
|
package main;
|
2014-03-31 18:25:09 +02:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2016-03-17 23:19:44 +01:00
|
|
|
require 't/test.pm';
|
2014-03-31 18:25:09 +02:00
|
|
|
|
2017-03-28 23:07:49 +02:00
|
|
|
use Test::More tests => 4;
|
2016-03-17 23:19:44 +01:00
|
|
|
BEGIN { use_ok('Lemonldap::NG::Handler::Main') }
|
2014-03-31 18:25:09 +02:00
|
|
|
|
|
|
|
# get a standard basic configuration in $args hashref
|
|
|
|
use Cwd 'abs_path';
|
|
|
|
use File::Basename;
|
|
|
|
use lib dirname( abs_path $0 );
|
|
|
|
|
|
|
|
#########################
|
|
|
|
|
2018-10-26 20:55:31 +02:00
|
|
|
# Insert your test code below, the Test::More module is used here so read
|
2014-03-31 18:25:09 +02:00
|
|
|
# its man page ( perldoc Test::More ) for help writing this test script.
|
|
|
|
my $h;
|
2016-03-17 23:19:44 +01:00
|
|
|
$h = 'Lemonldap::NG::Handler::Test';
|
2014-06-09 19:42:02 +02:00
|
|
|
$ENV{SERVER_NAME} = "test1.example.com";
|
2014-03-31 18:25:09 +02:00
|
|
|
|
2016-03-17 23:19:44 +01:00
|
|
|
#open STDERR, '>/dev/null';
|
2014-03-31 18:25:09 +02:00
|
|
|
|
2014-06-30 20:34:23 +02:00
|
|
|
my $conf = {
|
2017-03-28 23:07:49 +02:00
|
|
|
cfgNum => 1,
|
|
|
|
logLevel => 'error',
|
|
|
|
portal => 'http://auth.example.com/',
|
|
|
|
globalStorage => 'Apache::Session::File',
|
|
|
|
post => {},
|
|
|
|
key => 1,
|
|
|
|
locationRules => {
|
2014-06-08 12:04:50 +02:00
|
|
|
'test1.example.com' => {
|
|
|
|
|
2014-03-31 18:25:09 +02:00
|
|
|
# Basic rules
|
|
|
|
'default' => 'accept',
|
|
|
|
'^/no' => 'deny',
|
|
|
|
'test' => '$groups =~ /\badmin\b/',
|
|
|
|
|
|
|
|
# Bad ordered rules
|
|
|
|
'^/a/a' => 'deny',
|
|
|
|
'^/a' => 'accept',
|
|
|
|
|
|
|
|
# Good ordered rules
|
|
|
|
'(?#1 first)^/b/a' => 'deny',
|
|
|
|
'(?#2 second)^/b' => 'accept',
|
2014-06-08 12:04:50 +02:00
|
|
|
},
|
|
|
|
},
|
2014-03-31 18:25:09 +02:00
|
|
|
};
|
|
|
|
|
2017-02-12 21:26:36 +01:00
|
|
|
eval { $h->localConfig($conf); $h->logLevelInit() };
|
|
|
|
ok( !$@, 'init' );
|
2016-03-17 23:19:44 +01:00
|
|
|
ok( $h->configReload($conf), 'Load conf' );
|
2014-03-31 18:25:09 +02:00
|
|
|
|
2016-03-17 23:19:44 +01:00
|
|
|
ok( $h->tsv->{portal}->() eq 'http://auth.example.com/', 'portal' );
|