Bugzilla – Attachment 167073 Details for
Bug 36908
Clarify and standardize the behavior of AutoLocation/ StaffLoginBranchBasedOnIP system preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36908: Expand, clarify, and tidy tests for AutoLocation
Bug-36908-Expand-clarify-and-tidy-tests-for-AutoLo.patch (text/plain), 4.51 KB, created by
Jonathan Druart
on 2024-05-23 07:19:05 UTC
(
hide
)
Description:
Bug 36908: Expand, clarify, and tidy tests for AutoLocation
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-05-23 07:19:05 UTC
Size:
4.51 KB
patch
obsolete
>From 55a6989388a22dd6b00dbcb17c6237c5bebc8202 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 21 May 2024 12:14:50 +0000 >Subject: [PATCH] Bug 36908: Expand, clarify, and tidy tests for AutoLocation > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Auth.t | 38 +++++++++++++++++++++++++++++--------- > 1 file changed, 29 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 3ef06fc44dc..43b040e263d 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -1344,7 +1344,7 @@ subtest 'StaffLoginBranchBasedOnIP' => sub { > > subtest 'AutoLocation' => sub { > >- plan tests => 8; >+ plan tests => 9; > > $schema->storage->txn_begin; > >@@ -1366,7 +1366,7 @@ subtest 'AutoLocation' => sub { > > $ENV{REMOTE_ADDR} = '127.0.0.1'; > my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >- is( $userid, $patron->userid ); >+ is( $userid, $patron->userid, "Standard login without AutoLocation" ); > > my $template; > t::lib::Mocks::mock_preference( 'AutoLocation', 1 ); >@@ -1375,33 +1375,53 @@ subtest 'AutoLocation' => sub { > $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 ); >+ is( $userid, $patron->userid, "Login is successful when patron's branch does not have an IP" ); >+ is( $template, undef, "Template is undef as none passed and not sent to error page" ); > > $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 ); >+ is( >+ $template->{VARS}->{wrongip}, 1, >+ "Login denied when no branch specified and IP does not match patron's branch IP" >+ ); > > $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 ); >+ is( $userid, $patron->userid, "Login is successful when patron IP and branch IP match" ); >+ is( $template, undef, "Template is undef as none passed and not sent to error page" ); > > my $other_library = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => '127.0.0.1' } } ); > $patron->library->branchip('127.0.0.1')->store; > ( $userid, $cookie, $sessionID, $flags, $template ) = > C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); > my $session = C4::Auth::get_session($sessionID); >- is( $session->param('branch'), $patron->branchcode ); >+ is( >+ $session->param('branch'), $patron->branchcode, >+ "If no branch specified, and IP matches patron branch, login is successful at patron branch even if another branch IP matches" >+ ); >+ >+ $cgi->param( 'branch', $other_library->branchcode ); >+ ( $userid, $cookie, $sessionID, $flags, $template ) = >+ C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); >+ $session = C4::Auth::get_session($sessionID); >+ is( >+ $session->param('branch'), $other_library->branchcode, >+ "AutoLocation allows specifying a branch as long as the IP matches" >+ ); >+ >+ $other_library->branchip('129.0.0.1')->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, "Login denied when branch specified and IP does not match branch IP" ); > > my $noip_library = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => '' } } ); > $cgi->param( 'branch', $noip_library->branchcode ); > ( $userid, $cookie, $sessionID, $flags, $template ) = > C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); > $session = C4::Auth::get_session($sessionID); >- is( $session->param('branch'), $noip_library->branchcode ); >+ is( $session->param('branch'), $noip_library->branchcode, "When a branch with no IP set is chosen, we respect the choice regardless of current IP" ); > > $schema->storage->txn_rollback; > >-- >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 36908
:
166966
|
166967
|
166968
|
167044
|
167045
|
167046
|
167073
|
167074
|
167075
|
167084
|
167085
|
167086
|
167087
|
167090