Bug 18578: Use subdirectory in /tmp for session storage during installation
[koha.git] / C4 / SIP / t / 000_sc_config_auth.t
blob749a676de8e1cb528f641d307127d8f5643ec8df
1 #!/usr/bin/perl
2 #
3 # check if SIP terminal can Auth based on the xml config
6 use strict;
7 use warnings;
8 use FindBin qw($Bin);
9 use lib "$Bin";
11 use Test::More tests => 15;
13 BEGIN {
14 use_ok('C4::SIP::Sip::Constants', qw(:all));
15 use_ok('SIPtest', qw(:basic :user1 :auth));
16 use_ok('C4::Auth', qw(&check_api_auth));
17 use_ok('C4::Context');
18 use_ok('CGI');
19 use_ok('Data::Dumper');
22 my ($status, $cookie, $sessionID, $uenv);
23 my $query = CGI->new();
24 ok($username, sprintf "\$username exported by SIPtest (%s)", ($username||''));
25 ok($password, sprintf "\$password exported by SIPtest (%s)", ($password||''));
27 ok($ENV{REMOTE_USER} = $username, "set ENV{REMOTE_USER}"); # from SIPtest
28 ok($query->param(userid => $username), "set \$query->param('userid')");
29 ok($query->param(password => $password), "set \$query->param('password')");
31 $status = api_auth();
32 $uenv = C4::Context->userenv;
33 ok($status, sprintf "api_auth returned status (%s)", ($status ||''));
34 ok($uenv, "After api_auth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));
36 ($status, $cookie, $sessionID) = check_api_auth($query, {circulate=>1}, "intranet");
38 ok($status, sprintf "checkauth returned status (%s)", ($status ||''));
39 # ok($cookie, sprintf "checkauth returned cookie (%s)", ($cookie ||''));
40 # ok($sessionID, sprintf "checkauth returned sessionID (%s)", ($sessionID||''));
42 diag "note: checkauth " . ($cookie ? "returned cookie ($cookie)\n" : "did NOT return cookie\n" );
43 diag "note: checkauth " . ($sessionID ? "returned sessionID ($sessionID)\n" : "did NOT return sessionID\n");
45 $uenv = C4::Context->userenv;
46 ok($uenv, "After checkauth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));
48 diag "Done.";