diff --git a/Makefile b/Makefile index 42e72ac44..f8a6c0509 100644 --- a/Makefile +++ b/Makefile @@ -374,13 +374,13 @@ manager: manager_conf handler test: all common_test handler_test portal_test manager_test common_test: common - @$(MAKE) -C ${SRCCOMMONDIR} test + @HARNESS_OPTIONS=j8:c $(MAKE) -C ${SRCCOMMONDIR} test handler_test: handler @$(MAKE) -C ${SRCHANDLERDIR} test portal_test: portal - @$(MAKE) -C ${SRCPORTALDIR} test + @HARNESS_OPTIONS=j8:c $(MAKE) -C ${SRCPORTALDIR} test manager_test: manager @$(MAKE) -C ${SRCMANAGERDIR} test diff --git a/lemonldap-ng-common/t/03-Common-Conf-CDBI.t b/lemonldap-ng-common/t/03-Common-Conf-CDBI.t index b72c034d9..3520284ac 100644 --- a/lemonldap-ng-common/t/03-Common-Conf-CDBI.t +++ b/lemonldap-ng-common/t/03-Common-Conf-CDBI.t @@ -19,7 +19,7 @@ BEGIN { my $h; @ARGV = ("help=groups"); -unlink 't/lmConf.sql'; +unlink 't/cdbiConf.sql'; SKIP: { eval { require DBI; }; @@ -29,7 +29,7 @@ SKIP: { ok( $h = new Lemonldap::NG::Common::Conf( { type => 'CDBI', - dbiChain => "DBI:SQLite:dbname=t/lmConf.sql", + dbiChain => "DBI:SQLite:dbname=t/cdbiConf.sql", dbiUser => '', dbiPassword => '', } @@ -69,6 +69,6 @@ SKIP: { ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" ); } - unlink 't/lmConf.sql'; + unlink 't/cdbiConf.sql'; } diff --git a/lemonldap-ng-common/t/03-Common-Conf-RDBI.t b/lemonldap-ng-common/t/03-Common-Conf-RDBI.t index f81ec64b6..c7158caf2 100644 --- a/lemonldap-ng-common/t/03-Common-Conf-RDBI.t +++ b/lemonldap-ng-common/t/03-Common-Conf-RDBI.t @@ -19,7 +19,7 @@ BEGIN { my $h; @ARGV = ("help=groups"); -unlink 't/lmConf.sql'; +unlink 't/rdbiConf.sql'; SKIP: { eval { require DBI; }; @@ -29,7 +29,7 @@ SKIP: { ok( $h = new Lemonldap::NG::Common::Conf( { type => 'RDBI', - dbiChain => "DBI:SQLite:dbname=t/lmConf.sql", + dbiChain => "DBI:SQLite:dbname=t/rdbiConf.sql", dbiUser => '', dbiPassword => '', } @@ -70,6 +70,6 @@ SKIP: { ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" ); } - unlink 't/lmConf.sql'; + unlink 't/rdbiConf.sql'; } diff --git a/lemonldap-ng-handler/t/test-psgi-lib.pm b/lemonldap-ng-handler/t/test-psgi-lib.pm index c69e34fbe..39af14f73 100644 --- a/lemonldap-ng-handler/t/test-psgi-lib.pm +++ b/lemonldap-ng-handler/t/test-psgi-lib.pm @@ -3,6 +3,7 @@ use strict; use 5.10.0; use POSIX 'strftime'; +use Data::Dumper; use_ok('Lemonldap::NG::Common::PSGI::Cli::Lib'); our $client; diff --git a/lemonldap-ng-portal/.proverc b/lemonldap-ng-portal/.proverc index c97cb726a..695d42cf0 100644 --- a/lemonldap-ng-portal/.proverc +++ b/lemonldap-ng-portal/.proverc @@ -2,3 +2,4 @@ -I ../lemonldap-ng-common/blib/lib -I ../lemonldap-ng-handler/blib/lib --blib +--jobs 8 diff --git a/lemonldap-ng-portal/t/20-Auth-DBI-utf8.t b/lemonldap-ng-portal/t/20-Auth-DBI-utf8.t index f7e7241be..e15608446 100644 --- a/lemonldap-ng-portal/t/20-Auth-DBI-utf8.t +++ b/lemonldap-ng-portal/t/20-Auth-DBI-utf8.t @@ -7,14 +7,14 @@ require 't/test-lib.pm'; my $res; my $maintests = 8; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,cn text)'); $dbh->do( "INSERT INTO users VALUES ('french','french','Frédéric Accents')"); @@ -25,7 +25,7 @@ SKIP: { useSafeJail => 1, authentication => 'DBI', userDB => 'Same', - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -83,6 +83,5 @@ SKIP: { clean_sessions(); } -eval { unlink 't/userdb.db' }; count($maintests); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/20-Auth-and-password-DBI-dynamic-hash.t b/lemonldap-ng-portal/t/20-Auth-and-password-DBI-dynamic-hash.t index 2c8942068..bb0802a86 100644 --- a/lemonldap-ng-portal/t/20-Auth-and-password-DBI-dynamic-hash.t +++ b/lemonldap-ng-portal/t/20-Auth-and-password-DBI-dynamic-hash.t @@ -9,7 +9,7 @@ require 't/test-lib.pm'; my $res; my $maintests = 6; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval @@ -90,7 +90,7 @@ SKIP: { } `; - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); @@ -112,7 +112,7 @@ SKIP: { useSafeJail => 1, authentication => 'DBI', userDB => 'Same', - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -200,6 +200,5 @@ SKIP: { clean_sessions(); } -eval { unlink 't/userdb.db' }; count($maintests); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/20-Auth-and-password-DBI.t b/lemonldap-ng-portal/t/20-Auth-and-password-DBI.t index 0d5e3528b..66f35f00d 100644 --- a/lemonldap-ng-portal/t/20-Auth-and-password-DBI.t +++ b/lemonldap-ng-portal/t/20-Auth-and-password-DBI.t @@ -7,14 +7,14 @@ require 't/test-lib.pm'; my $res; my $maintests = 3; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dwho','dwho','Doctor who')"); my $client = LLNG::Manager::Test->new( { @@ -23,7 +23,7 @@ SKIP: { useSafeJail => 1, authentication => 'DBI', userDB => 'Same', - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -78,6 +78,5 @@ SKIP: { $client->logout($id); clean_sessions(); } -eval { unlink 't/userdb.db' }; count($maintests); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/28-AuthChoice-and-password.t b/lemonldap-ng-portal/t/28-AuthChoice-and-password.t index 45f6c41e1..5da794408 100644 --- a/lemonldap-ng-portal/t/28-AuthChoice-and-password.t +++ b/lemonldap-ng-portal/t/28-AuthChoice-and-password.t @@ -7,7 +7,7 @@ require 't/test-lib.pm'; my $res; my $maintests = 10; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; @@ -16,7 +16,7 @@ SKIP: { } skip 'LLNGTESTLDAP is not set', $maintests unless ( $ENV{LLNGTESTLDAP} ); require 't/test-ldap.pm'; - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dwho','dwho','Doctor who')"); @@ -36,7 +36,7 @@ SKIP: { slave => 'Slave;LDAP;LDAP', }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -116,7 +116,6 @@ SKIP: { clean_sessions(); } count($maintests); -eval { unlink 't/userdb.db' }; stopLdapServer() if $ENV{LLNGTESTLDAP}; clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/28-AuthChoice-with-rules.t b/lemonldap-ng-portal/t/28-AuthChoice-with-rules.t index 697b71ff2..b609dfc9a 100644 --- a/lemonldap-ng-portal/t/28-AuthChoice-with-rules.t +++ b/lemonldap-ng-portal/t/28-AuthChoice-with-rules.t @@ -10,14 +10,14 @@ BEGIN { my $res; my $maintests = 21; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; require GSSAPI; }; if ($@) { skip 'Missing dependencies', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dwho','dwho','Doctor who')"); @@ -42,7 +42,7 @@ SKIP: { '7_Kerberos' => 'Kerberos;Null;Null', }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -144,6 +144,5 @@ m%
%, clean_sessions(); } count($maintests); -eval { unlink 't/userdb.db' }; clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/30-SAML-ReAuth-with-choice.t b/lemonldap-ng-portal/t/30-SAML-ReAuth-with-choice.t index 218f140b5..08fbdca6b 100644 --- a/lemonldap-ng-portal/t/30-SAML-ReAuth-with-choice.t +++ b/lemonldap-ng-portal/t/30-SAML-ReAuth-with-choice.t @@ -10,7 +10,7 @@ BEGIN { require 't/test-lib.pm'; require 't/saml-lib.pm'; } -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); my $maintests = 13; my $debug = 'error'; @@ -36,7 +36,7 @@ SKIP: { if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do( 'CREATE TABLE users (user text,password text,name text,uid text,cn text,mail text)' ); @@ -172,7 +172,6 @@ SKIP: { } count($maintests); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub switch { @@ -196,7 +195,7 @@ sub issuer { demo => 'Demo;Demo;Demo', sql => 'DBI;DBI;DBI', }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice-and-cancel.t b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice-and-cancel.t index 3b0464d0e..066d3af65 100644 --- a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice-and-cancel.t +++ b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice-and-cancel.t @@ -9,7 +9,7 @@ use MIME::Base64; BEGIN { require 't/test-lib.pm'; } -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); my $maintests = 14; my $debug = 'error'; @@ -67,7 +67,7 @@ SKIP: { } # Build SQL DB - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do( 'CREATE TABLE users (user text,password text,name text,uid text,cn text,mail text)' ); @@ -146,7 +146,6 @@ qr% '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice.t b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice.t index 998a3bd3b..e9bff2b76 100644 --- a/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice.t +++ b/lemonldap-ng-portal/t/31-Auth-and-issuer-CAS-with-choice.t @@ -9,7 +9,7 @@ use MIME::Base64; BEGIN { require 't/test-lib.pm'; } -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); my $maintests = 23; my $debug = 'error'; @@ -67,7 +67,7 @@ SKIP: { } # Build SQL DB - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do( 'CREATE TABLE users (user text,password text,name text,uid text,cn text,mail text)' ); @@ -301,7 +301,6 @@ SKIP: { } count($maintests); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub switch { @@ -325,7 +324,7 @@ sub issuer { demo => 'Demo;Demo;Demo', sql => 'DBI;DBI;DBI', }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/32-Auth-and-issuer-OIDC-authorization_code-with-authchoice.t b/lemonldap-ng-portal/t/32-Auth-and-issuer-OIDC-authorization_code-with-authchoice.t index 3635bd9f5..185cd20e2 100644 --- a/lemonldap-ng-portal/t/32-Auth-and-issuer-OIDC-authorization_code-with-authchoice.t +++ b/lemonldap-ng-portal/t/32-Auth-and-issuer-OIDC-authorization_code-with-authchoice.t @@ -14,7 +14,7 @@ my $debug = 'error'; my $maintests = 18; my ( $op, $rp, $res ); my %handlerOR = ( op => [], rp => [] ); -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); LWP::Protocol::PSGI->register( sub { @@ -72,7 +72,7 @@ SKIP: { if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dwho','dwho','Doctor who')"); @@ -241,7 +241,6 @@ SKIP: { #print STDERR Dumper($res); count($maintests); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub switch { @@ -266,7 +265,7 @@ sub op { demo => 'Demo;Demo;Demo', sql => 'DBI;DBI;DBI', }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/35-REST-sessions-with-AuthBasic-handler.t b/lemonldap-ng-portal/t/35-REST-sessions-with-AuthBasic-handler.t index b5c32bd3b..dc3371365 100644 --- a/lemonldap-ng-portal/t/35-REST-sessions-with-AuthBasic-handler.t +++ b/lemonldap-ng-portal/t/35-REST-sessions-with-AuthBasic-handler.t @@ -1,5 +1,6 @@ use lib 'inc'; use strict; +use File::Temp 'tempdir'; use IO::String; use JSON; use MIME::Base64; @@ -9,6 +10,8 @@ our $debug = 'error'; my ( $p, $res, $spId ); $| = 1; +$LLNG::TMPDIR = tempdir( 'tmpSessionXXXXX', DIR => 't/sessions', CLEANUP => 1 ); + require 't/separate-handler.pm'; require "t/test-lib.pm"; diff --git a/lemonldap-ng-portal/t/36-Combination-with-Choice.t b/lemonldap-ng-portal/t/36-Combination-with-Choice.t index ac279be17..432765677 100644 --- a/lemonldap-ng-portal/t/36-Combination-with-Choice.t +++ b/lemonldap-ng-portal/t/36-Combination-with-Choice.t @@ -8,14 +8,14 @@ my $res; my $maintests = 0; my $client; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dvador','dvador','Test user 1')"); $dbh->do("INSERT INTO users VALUES ('rtyler','rtyler','Test user 1')"); @@ -43,7 +43,6 @@ SKIP: { } count($maintests); clean_sessions(); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub try { @@ -86,7 +85,7 @@ sub iniCmb { }, }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/36-Combination-with-over.t b/lemonldap-ng-portal/t/36-Combination-with-over.t index 9d8e0c874..5fcb0eeee 100644 --- a/lemonldap-ng-portal/t/36-Combination-with-over.t +++ b/lemonldap-ng-portal/t/36-Combination-with-over.t @@ -8,14 +8,14 @@ my $res; my $maintests = 0; my $client; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dvador','dvador','Test user 1')"); $dbh->do("INSERT INTO users VALUES ('rtyler','rtyler','Test user 1')"); @@ -26,7 +26,6 @@ SKIP: { } count($maintests); clean_sessions(); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub try { @@ -62,7 +61,7 @@ sub iniCmb { for => 0, type => 'DBI', over => { - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/36-Combination-with-token.t b/lemonldap-ng-portal/t/36-Combination-with-token.t index 69f2462f1..d02e51cc1 100644 --- a/lemonldap-ng-portal/t/36-Combination-with-token.t +++ b/lemonldap-ng-portal/t/36-Combination-with-token.t @@ -8,14 +8,14 @@ my $res; my $maintests = 0; my $client; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dvador','dvador','Test user 1')"); $dbh->do("INSERT INTO users VALUES ('rtyler','rtyler','Test user 1')"); @@ -41,7 +41,6 @@ SKIP: { } count($maintests); clean_sessions(); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub try { @@ -89,7 +88,7 @@ sub iniCmb { }, }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/36-Combination.t b/lemonldap-ng-portal/t/36-Combination.t index dae307d7c..aeedfb5a9 100644 --- a/lemonldap-ng-portal/t/36-Combination.t +++ b/lemonldap-ng-portal/t/36-Combination.t @@ -8,14 +8,14 @@ my $res; my $maintests = 3; my $client; -eval { unlink 't/userdb.db' }; +my $userdb = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do('CREATE TABLE users (user text,password text,name text)'); $dbh->do("INSERT INTO users VALUES ('dvador','dvador','Test user 1')"); $dbh->do("INSERT INTO users VALUES ('rtyler','rtyler','Test user 1')"); @@ -49,7 +49,6 @@ SKIP: { } count($maintests); clean_sessions(); -eval { unlink 't/userdb.db' }; done_testing( count() ); sub try { @@ -92,7 +91,7 @@ sub iniCmb { }, }, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', diff --git a/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t b/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t index 5dc2e1ed8..f41961bda 100644 --- a/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t +++ b/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t @@ -3,10 +3,9 @@ use strict; use IO::String; my $res; -my $file = 't/notifications.db'; my $maintests = 6; -eval { unlink $file }; require 't/test-lib.pm'; +my $file = tempdb(); SKIP: { eval { require DBI; require DBD::SQLite; }; diff --git a/lemonldap-ng-portal/t/40-Notifications-JSON-File-with-token.t b/lemonldap-ng-portal/t/40-Notifications-JSON-File-with-token.t index 1898c1057..d926d28ad 100644 --- a/lemonldap-ng-portal/t/40-Notifications-JSON-File-with-token.t +++ b/lemonldap-ng-portal/t/40-Notifications-JSON-File-with-token.t @@ -5,7 +5,7 @@ use IO::String; require 't/test-lib.pm'; my $res; -my $file = 't/20160530_dwho_dGVzdHJlZg==.json'; +my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.json"; open F, "> $file" or die($!); print F '[ @@ -28,7 +28,7 @@ my $client = LLNG::Manager::Test->new( { notification => 1, notificationStorage => 'File', notificationStorageOptions => { - dirName => 't' + dirName => $main::tmpDir }, oldNotifFormat => 0, requireToken => 1, diff --git a/lemonldap-ng-portal/t/40-Notifications-JSON-File.t b/lemonldap-ng-portal/t/40-Notifications-JSON-File.t index f3b3eb21d..1c404755b 100644 --- a/lemonldap-ng-portal/t/40-Notifications-JSON-File.t +++ b/lemonldap-ng-portal/t/40-Notifications-JSON-File.t @@ -5,7 +5,7 @@ use IO::String; require 't/test-lib.pm'; my $res; -my $file = 't/20160530_dwho_dGVzdHJlZg==.json'; +my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.json"; open F, "> $file" or die($!); print F '[ @@ -27,7 +27,7 @@ my $client = LLNG::Manager::Test->new( { useSafeJail => 1, notification => 1, notificationStorage => 'File', - notificationStorageOptions => { dirName => 't' }, + notificationStorageOptions => { dirName => $main::tmpDir }, oldNotifFormat => 0, portalMainLogo => 'common/logos/logo_llng_old.png', } diff --git a/lemonldap-ng-portal/t/40-Notifications-JSON-Server.t b/lemonldap-ng-portal/t/40-Notifications-JSON-Server.t index b47995dae..e4229a335 100644 --- a/lemonldap-ng-portal/t/40-Notifications-JSON-Server.t +++ b/lemonldap-ng-portal/t/40-Notifications-JSON-Server.t @@ -6,8 +6,6 @@ BEGIN { require 't/test-lib.pm'; } -eval { unlink 't/20160530_dwho_dGVzdHJlZg==.json' }; - my $json = '{ "date": "2016-05-30", "reference": "testref", @@ -24,7 +22,7 @@ my $client = LLNG::Manager::Test->new( { notificationServer => 1, notificationStorage => 'File', notificationStorageOptions => { - dirName => 't' + dirName => $main::tmpDir }, } } @@ -58,7 +56,5 @@ expectOK($res); my $id = expectCookie($res); expectForm( $res, undef, '/notifback', 'reference1x1', 'url' ); -eval { unlink 't/20160530_dwho_dGVzdHJlZg==.json' }; - clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t b/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t index 8e7761256..49fcbea0b 100644 --- a/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t +++ b/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t @@ -3,10 +3,9 @@ use strict; use IO::String; my $res; -my $file = 't/notifications.db'; my $maintests = 6; -eval { unlink $file }; require 't/test-lib.pm'; +my $file = tempdb(); SKIP: { eval { @@ -114,9 +113,6 @@ qq{INSERT INTO notifications VALUES ('dwho','testref','2016-05-30 00:00:00',' 1, notification => 1, notificationStorage => 'File', - notificationStorageOptions => { dirName => 't' }, + notificationStorageOptions => { dirName => $main::tmpDir }, oldNotifFormat => 1, portalMainLogo => 'common/logos/logo_llng_old.png', } diff --git a/lemonldap-ng-portal/t/40-Notifications-XML-Server.t b/lemonldap-ng-portal/t/40-Notifications-XML-Server.t index be4319acf..bc382e084 100644 --- a/lemonldap-ng-portal/t/40-Notifications-XML-Server.t +++ b/lemonldap-ng-portal/t/40-Notifications-XML-Server.t @@ -43,8 +43,6 @@ LWP::Protocol::PSGI->register( } ); -eval { unlink 't/20160530_dwho_dGVzdHJlZg==.xml' }; - my $xml = ' Test title @@ -66,7 +64,7 @@ SKIP: { notificationServer => 1, notificationStorage => 'File', notificationStorageOptions => { - dirName => 't' + dirName => $main::tmpDir }, oldNotifFormat => 1, } @@ -102,8 +100,6 @@ SKIP: { } -eval { unlink 't/20160530_dwho_dGVzdHJlZg==.xml' }; - count($maintests); clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/43-MailPasswordReset-Choice.t b/lemonldap-ng-portal/t/43-MailPasswordReset-Choice.t index 3e670d872..75d4a940a 100644 --- a/lemonldap-ng-portal/t/43-MailPasswordReset-Choice.t +++ b/lemonldap-ng-portal/t/43-MailPasswordReset-Choice.t @@ -14,7 +14,7 @@ my $maintests = 17; my $mailSend = 0; my $mail2 = 0; -unlink 't/userdb.db'; +my $userdb = tempdb(); SKIP: { eval @@ -26,7 +26,7 @@ SKIP: { if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do( 'CREATE TABLE users (user text,password text,name text, mail text)'); $dbh->do( @@ -47,7 +47,7 @@ SKIP: { passwordDB => 'Choice', captcha_mail_enabled => 0, portalDisplayResetPassword => 1, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -146,7 +146,6 @@ SKIP: { } -eval { unlink 't/userdb.db' }; count($maintests); clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t b/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t index 0474e460c..a91d46153 100644 --- a/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t +++ b/lemonldap-ng-portal/t/43-MailPasswordReset-DBI.t @@ -2,11 +2,12 @@ use Test::More; use strict; use IO::String; +my $userdb; BEGIN { eval { - unlink 't/userdb.db'; require 't/test-lib.pm'; require 't/smtp.pm'; + $userdb = tempdb(); }; } @@ -26,7 +27,7 @@ SKIP: { if ($@) { skip 'DBD::SQLite not found', $maintests; } - my $dbh = DBI->connect("dbi:SQLite:dbname=t/userdb.db"); + my $dbh = DBI->connect("dbi:SQLite:dbname=$userdb"); $dbh->do( 'CREATE TABLE users (user text,password text,name text, mail text)'); $dbh->do( @@ -43,7 +44,7 @@ SKIP: { passwordDB => 'DBI', captcha_mail_enabled => 0, portalDisplayResetPassword => 1, - dbiAuthChain => 'dbi:SQLite:dbname=t/userdb.db', + dbiAuthChain => "dbi:SQLite:dbname=$userdb", dbiAuthUser => '', dbiAuthPassword => '', dbiAuthTable => 'users', @@ -168,7 +169,6 @@ SKIP: { #print STDERR Dumper($query); } -eval { unlink 't/userdb.db' }; count($maintests); clean_sessions(); done_testing( count() ); diff --git a/lemonldap-ng-portal/t/lib/Lemonldap/NG/Handler/Test.pm b/lemonldap-ng-portal/t/lib/Lemonldap/NG/Handler/Test.pm index e8f3110bd..8bb495e9e 100644 --- a/lemonldap-ng-portal/t/lib/Lemonldap/NG/Handler/Test.pm +++ b/lemonldap-ng-portal/t/lib/Lemonldap/NG/Handler/Test.pm @@ -31,6 +31,12 @@ sub init { type => 'File', dirName => 't', }, + globalStorageOptions => { + Directory => $LLNG::TMPDIR, + LockDirectory => "$LLNG::TMPDIR/lock", + generateModule => + 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256', + }, localSessionStorage => 'Cache::FileCache', localSessionStorageOptions => { namespace => 'lemonldap-ng-session', diff --git a/lemonldap-ng-portal/t/test-lib.pm b/lemonldap-ng-portal/t/test-lib.pm index 222c8dfc6..24dc26cc6 100644 --- a/lemonldap-ng-portal/t/test-lib.pm +++ b/lemonldap-ng-portal/t/test-lib.pm @@ -73,6 +73,12 @@ $Data::Dumper::Sortkeys = 1; $Data::Dumper::Useperl = 1; my $ini; +use File::Temp 'tempfile', 'tempdir'; +our $tmpDir = $LLNG::TMPDIR || tempdir( 'tmpSessionXXXXX', DIR => 't/sessions', CLEANUP => 1 ); +mkdir "$tmpDir/lock"; +mkdir "$tmpDir/saml"; +mkdir "$tmpDir/saml/lock"; + =head4 count($inc) Returns number of tests done. Increment test number if an argument is given @@ -107,10 +113,6 @@ Clean sessions created during tests =cut sub clean_sessions { - opendir D, 't/sessions' or die $!; - foreach ( grep { /^[^\.]/ } readdir(D) ) { - unlink "t/sessions/$_", "t/sessions/lock/Apache-Session-$_.lock"; - } foreach my $dir (qw(t/sessions/lock t/sessions/saml/lock t/sessions/saml)) { if ( -d $dir ) { opendir D, $dir or die $!; @@ -119,13 +121,11 @@ sub clean_sessions { } } } - my $cache = getCache(); - $cache->clear; } sub count_sessions { my $dir = shift; - $dir ||= 't/sessions'; + $dir ||= $tmpDir; my $nbr = 0; opendir D, $dir or die $!; @@ -139,7 +139,7 @@ sub getCache { require Cache::FileCache; return Cache::FileCache->new( { namespace => 'lemonldap-ng-session', - cache_root => 't/', + cache_root => $tmpDir, cache_depth => 0, } ); @@ -465,6 +465,16 @@ sub getUser { return getHeader( $resp, 'Lm-Remote-User' ); } +=head4 tempdb + +Return a temporary file named XXXX.db + +=cut + +sub tempdb { + return "$tmpDir/userdb.db"; +} + =head2 LLNG::Manager::Test Class =cut @@ -484,16 +494,40 @@ our $defaultIni = { localSessionStorage => 'Cache::FileCache', localSessionStorageOptions => { namespace => 'lemonldap-ng-session', - cache_root => 't/', + cache_root => $tmpDir, cache_depth => 0, }, - logLevel => 'error', - cookieName => 'lemonldap', - domain => 'example.com', - templateDir => 'site/templates', - staticPrefix => '/static', - securedCookie => 0, - https => 0, + logLevel => 'error', + cookieName => 'lemonldap', + domain => 'example.com', + templateDir => 'site/templates', + staticPrefix => '/static', + securedCookie => 0, + https => 0, + globalStorageOptions => { + Directory => $tmpDir, + LockDirectory => "$tmpDir/lock", + generateModule => + 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256', + }, + casStorageOptions => { + Directory => "$tmpDir/saml", + LockDirectory => "$tmpDir/saml/lock", + generateModule => + 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256', + }, + samlStorageOptions => { + Directory => "$tmpDir/saml", + LockDirectory => "$tmpDir/saml/lock", + generateModule => + 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256', + }, + oidcStorageOptions => { + Directory => "$tmpDir/saml", + LockDirectory => "$tmpDir/saml/lock", + generateModule => + 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256', + }, }; =head3 Accessors