3 # check if SIP terminal can Auth based on the xml config
9 use Test::More tests => 15;
12 use_ok('Sip::Constants', qw(:all));
13 use_ok('SIPtest', qw(:basic :user1 :auth));
14 use_ok('C4::Auth', qw(&check_api_auth));
15 use_ok('C4::Context');
17 use_ok('Data::Dumper');
20 my ($status, $cookie, $sessionID, $uenv);
21 my $query = CGI->new();
22 ok($username, sprintf "\$username exported by SIPtest (%s)", ($username||''));
23 ok($password, sprintf "\$password exported by SIPtest (%s)", ($password||''));
25 ok($ENV{REMOTE_USER} = $username, "set ENV{REMOTE_USER}"); # from SIPtest
26 ok($query->param(userid => $username), "set \$query->param('userid')");
27 ok($query->param(password => $password), "set \$query->param('password')");
30 $uenv = C4::Context->userenv;
31 ok($status, sprintf "api_auth returned status (%s)", ($status ||''));
32 ok($uenv, "After api_auth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));
34 ($status, $cookie, $sessionID) = check_api_auth($query, {circulate=>1}, "intranet");
36 ok($status, sprintf "checkauth returned status (%s)", ($status ||''));
37 # ok($cookie, sprintf "checkauth returned cookie (%s)", ($cookie ||''));
38 # ok($sessionID, sprintf "checkauth returned sessionID (%s)", ($sessionID||''));
40 diag "note: checkauth " . ($cookie ? "returned cookie ($cookie)\n" : "did NOT return cookie\n" );
41 diag "note: checkauth " . ($sessionID ? "returned sessionID ($sessionID)\n" : "did NOT return sessionID\n");
43 $uenv = C4::Context->userenv;
44 ok($uenv, "After checkauth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));