3 # check if SIP terminal can Auth based on the xml config
11 use Test::More tests => 15;
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');
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')");
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) : ''));