lemonldap-ng/lemonldap-ng-handler/t/10-Lemonldap-NG-Handler-SharedConf.t

70 lines
1.8 KiB
Perl
Raw Normal View History

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Handler-SharedConf.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
2017-02-08 23:18:52 +01:00
use Test::More tests => 6;
use Cwd 'abs_path';
use File::Basename;
use File::Temp;
require 't/test.pm';
my $ini = File::Temp->new();
my $dir = dirname( abs_path($0) );
2014-06-27 16:12:54 +02:00
my $tmp = File::Temp::tempdir();
print $ini "[all]
2017-02-21 12:11:23 +01:00
logger = Lemonldap::NG::Common::Logger::Std
logLevel = error
[configuration]
type=File
dirName=$dir
localStorage=Cache::FileCache
localStorageOptions={ \\
'namespace' => 'lemonldap-ng-config',\\
'default_expires_in' => 600, \\
'directory_umask' => '007', \\
'cache_root' => '$tmp', \\
'cache_depth' => 0, \\
}
";
$ini->flush();
use Env qw(LLNG_DEFAULTCONFFILE);
$LLNG_DEFAULTCONFFILE = $ini->filename;
#open STDERR, '>/dev/null';
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
use_ok('Lemonldap::NG::Handler::Main');
2016-02-16 17:01:45 +01:00
my $ret;
our $apacheRequest;
my $h = 'Lemonldap::NG::Handler::Test';
2016-02-16 17:01:45 +01:00
2016-02-17 11:07:08 +01:00
ok( $h->init(), 'Initialize handler' );
2017-02-15 07:41:50 +01:00
ok( $h->checkType($apacheRequest) eq 'Main', 'Get Main type' );
2017-02-08 23:18:52 +01:00
ok( $ret = $h->run($apacheRequest),
2016-02-16 17:01:45 +01:00
'run Handler with basic configuration and no cookie' );
ok( $ret = 302, 'Return code is 302' );
2016-02-16 17:01:45 +01:00
ok(
$Lemonldap::NG::Handler::Test::header eq
2016-02-17 11:12:19 +01:00
'Location:http://auth.example.com/?url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
2016-02-16 17:01:45 +01:00
'testing redirection URL from previous run'
) or print STDERR "Got: $Lemonldap::NG::Handler::Test::header\n";