Lines 7-13
use CGI qw ( -utf8 );
Link Here
|
7 |
use Test::MockObject; |
7 |
use Test::MockObject; |
8 |
use Test::MockModule; |
8 |
use Test::MockModule; |
9 |
use List::MoreUtils qw/all any none/; |
9 |
use List::MoreUtils qw/all any none/; |
10 |
use Test::More tests => 18; |
10 |
use Test::More tests => 19; |
11 |
use Test::Warn; |
11 |
use Test::Warn; |
12 |
use t::lib::Mocks; |
12 |
use t::lib::Mocks; |
13 |
use t::lib::TestBuilder; |
13 |
use t::lib::TestBuilder; |
Lines 1024-1029
subtest 'get_cataloguing_page_permissions() tests' => sub {
Link Here
|
1024 |
$schema->storage->txn_rollback; |
1024 |
$schema->storage->txn_rollback; |
1025 |
}; |
1025 |
}; |
1026 |
|
1026 |
|
|
|
1027 |
subtest 'AutoLocation' => sub { |
1028 |
|
1029 |
plan tests => 6; |
1030 |
|
1031 |
$schema->storage->txn_begin; |
1032 |
|
1033 |
t::lib::Mocks::mock_preference( 'AutoLocation', 0 ); |
1034 |
|
1035 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); |
1036 |
my $password = 'password'; |
1037 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
1038 |
$patron->set_password( { password => $password } ); |
1039 |
|
1040 |
my $cgi_mock = Test::MockModule->new('CGI'); |
1041 |
$cgi_mock->mock( 'request_method', sub { return 'POST' } ); |
1042 |
my $cgi = CGI->new; |
1043 |
my $auth = Test::MockModule->new('C4::Auth'); |
1044 |
|
1045 |
# Simulating the login form submission |
1046 |
$cgi->param( 'userid', $patron->userid ); |
1047 |
$cgi->param( 'password', $password ); |
1048 |
|
1049 |
$ENV{REMOTE_ADDR} = '127.0.0.1'; |
1050 |
my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); |
1051 |
is( $userid, $patron->userid ); |
1052 |
|
1053 |
my $template; |
1054 |
t::lib::Mocks::mock_preference( 'AutoLocation', 1 ); |
1055 |
|
1056 |
# AutoLocation: "Require staff to log in from a computer in the IP address range specified by their library (if any)" |
1057 |
$patron->library->branchip('')->store; # There is none, allow access from anywhere |
1058 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
1059 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); |
1060 |
is( $userid, $patron->userid ); |
1061 |
is( $template, undef ); |
1062 |
|
1063 |
$patron->library->branchip('1.2.3.4')->store; |
1064 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
1065 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); |
1066 |
is( $template->{VARS}->{wrongip}, 1 ); |
1067 |
|
1068 |
$patron->library->branchip('127.0.0.1')->store; |
1069 |
( $userid, $cookie, $sessionID, $flags, $template ) = |
1070 |
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); |
1071 |
is( $userid, $patron->userid ); |
1072 |
is( $template, undef ); |
1073 |
|
1074 |
$schema->storage->txn_rollback; |
1075 |
|
1076 |
}; |
1077 |
|
1027 |
sub set_weak_password { |
1078 |
sub set_weak_password { |
1028 |
my ($patron) = @_; |
1079 |
my ($patron) = @_; |
1029 |
my $password = 'password'; |
1080 |
my $password = 'password'; |
1030 |
- |
|
|