Bugzilla – Attachment 162137 Details for
Bug 35890
AutoLocation system preference + setting the library IP field - can still login and unexpected results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35890: Add tests for AutoLocation
Bug-35890-Add-tests-for-AutoLocation.patch (text/plain), 2.92 KB, created by
Jonathan Druart
on 2024-02-14 09:18:56 UTC
(
hide
)
Description:
Bug 35890: Add tests for AutoLocation
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-02-14 09:18:56 UTC
Size:
2.92 KB
patch
obsolete
>From 1b2765abdeb47ab6d4daa58a2f6b4470aded20f5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 25 Jan 2024 09:36:01 +0100 >Subject: [PATCH] Bug 35890: Add tests for AutoLocation > >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >--- > t/db_dependent/Auth.t | 53 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 55e8aaaa199..dace642faf9 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -7,7 +7,7 @@ use CGI qw ( -utf8 ); > use Test::MockObject; > use Test::MockModule; > use List::MoreUtils qw/all any none/; >-use Test::More tests => 19; >+use Test::More tests => 20; > use Test::Warn; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -1240,6 +1240,57 @@ subtest 'checkpw() return values tests' => sub { > }; > }; > >+subtest 'AutoLocation' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'AutoLocation', 0 ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); >+ my $password = 'password'; >+ t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); >+ $patron->set_password( { password => $password } ); >+ >+ my $cgi_mock = Test::MockModule->new('CGI'); >+ $cgi_mock->mock( 'request_method', sub { return 'POST' } ); >+ my $cgi = CGI->new; >+ my $auth = Test::MockModule->new('C4::Auth'); >+ >+ # Simulating the login form submission >+ $cgi->param( 'userid', $patron->userid ); >+ $cgi->param( 'password', $password ); >+ >+ $ENV{REMOTE_ADDR} = '127.0.0.1'; >+ my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >+ is( $userid, $patron->userid ); >+ >+ my $template; >+ t::lib::Mocks::mock_preference( 'AutoLocation', 1 ); >+ >+ # AutoLocation: "Require staff to log in from a computer in the IP address range specified by their library (if any)" >+ $patron->library->branchip('')->store; # There is none, allow access from anywhere >+ ( $userid, $cookie, $sessionID, $flags, $template ) = >+ C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >+ is( $userid, $patron->userid ); >+ is( $template, undef ); >+ >+ $patron->library->branchip('1.2.3.4')->store; >+ ( $userid, $cookie, $sessionID, $flags, $template ) = >+ C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); >+ is( $template->{VARS}->{wrongip}, 1 ); >+ >+ $patron->library->branchip('127.0.0.1')->store; >+ ( $userid, $cookie, $sessionID, $flags, $template ) = >+ C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >+ is( $userid, $patron->userid ); >+ is( $template, undef ); >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ > sub set_weak_password { > my ($patron) = @_; > my $password = 'password'; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35890
:
161347
|
161348
|
161375
|
161385
|
161386
|
161701
|
161702
|
161703
|
162136
|
162137
|
162152
|
162153
|
162154