Koha/C4/SIP/t/000_sc_config_auth.t
Jonathan Druart f1f9c6dc74 Bug 26384: Fix executable flags
.pm must not have -x
.t must have -x
.pl must have -x

Test plan:
Apply only the first patch, run the tests and confirm that the failures
make sense
Apply this patch and confirm that the test now returns green

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-11 09:56:56 +02:00

48 lines
1.7 KiB
Perl
Executable file

#!/usr/bin/perl
#
# check if SIP terminal can Auth based on the xml config
#
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin";
use Test::More tests => 15;
BEGIN {
use_ok('C4::SIP::Sip::Constants', qw(:all));
use_ok('SIPtest', qw(:basic :user1 :auth));
use_ok('C4::Auth', qw(&check_api_auth));
use_ok('C4::Context');
use_ok('CGI');
use_ok('Data::Dumper');
}
my ($status, $cookie, $sessionID, $uenv);
my $query = CGI->new();
ok($username, sprintf "\$username exported by SIPtest (%s)", ($username||''));
ok($password, sprintf "\$password exported by SIPtest (%s)", ($password||''));
ok($ENV{REMOTE_USER} = $username, "set ENV{REMOTE_USER}"); # from SIPtest
ok($query->param(userid => $username), "set \$query->param('userid')");
ok($query->param(password => $password), "set \$query->param('password')");
$status = api_auth();
$uenv = C4::Context->userenv;
ok($status, sprintf "api_auth returned status (%s)", ($status ||''));
ok($uenv, "After api_auth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));
($status, $cookie, $sessionID) = check_api_auth($query, {circulate=>1}, "intranet");
ok($status, sprintf "checkauth returned status (%s)", ($status ||''));
# ok($cookie, sprintf "checkauth returned cookie (%s)", ($cookie ||''));
# ok($sessionID, sprintf "checkauth returned sessionID (%s)", ($sessionID||''));
diag "note: checkauth " . ($cookie ? "returned cookie ($cookie)\n" : "did NOT return cookie\n" );
diag "note: checkauth " . ($sessionID ? "returned sessionID ($sessionID)\n" : "did NOT return sessionID\n");
$uenv = C4::Context->userenv;
ok($uenv, "After checkauth, Got C4::Context->userenv :" . ($uenv ? Dumper($uenv) : ''));
diag "Done.";