Bugzilla – Attachment 152735 Details for
Bug 33879
check_cookie_auth overwrites interface set by get_template_and_user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33879: Add unit test to show problem
Bug-33879-Add-unit-test-to-show-problem.patch (text/plain), 2.51 KB, created by
Martin Renvoize (ashimema)
on 2023-06-27 13:07:47 UTC
(
hide
)
Description:
Bug 33879: Add unit test to show problem
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-06-27 13:07:47 UTC
Size:
2.51 KB
patch
obsolete
>From 3025afd5da84e42e46a4382eb1b39085687a5c55 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 1 Jun 2023 13:42:03 +0000 >Subject: [PATCH] Bug 33879: Add unit test to show problem >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: >Run t/db_dependent/Auth.t without second patch. >Should fail: > # got: 'opac' > # expected: 'intranet' > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Björn Nylén <bjorn.nylen@ub.lu.se> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Auth.t | 29 +++++++++++++++++++++++++---- > 1 file changed, 25 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 5c2aad72d4..4f4ad6a78c 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -1,7 +1,4 @@ > #!/usr/bin/perl >-# >-# This Koha test module is a stub! >-# Add more tests here!!! > > use Modern::Perl; > >@@ -10,7 +7,7 @@ use CGI qw ( -utf8 ); > use Test::MockObject; > use Test::MockModule; > use List::MoreUtils qw/all any none/; >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Warn; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -981,4 +978,28 @@ subtest 'create_basic_session tests' => sub { > is( $session->param('interface'), 'intranet', 'Staff interface gets converted to intranet' ); > }; > >+subtest 'check_cookie_auth overwriting interface already set' => sub { >+ plan tests => 2; >+ >+ t::lib::Mocks::mock_preference( 'SessionRestrictionByIP', 0 ); >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $session = C4::Auth::get_session(); >+ $session->param( 'number', $patron->id ); >+ $session->param( 'id', $patron->userid ); >+ $session->param( 'ip', '1.2.3.4' ); >+ $session->param( 'lasttime', time() ); >+ $session->param( 'interface', 'opac' ); >+ $session->flush; >+ >+ C4::Context->interface('intranet'); >+ C4::Auth::check_cookie_auth( $session->id ); >+ is( C4::Context->interface, 'intranet', 'check_cookie_auth did not overwrite' ); >+ delete $C4::Context::context->{interface}; # clear context interface >+ C4::Auth::check_cookie_auth( $session->id ); >+ is( C4::Context->interface, 'opac', 'check_cookie_auth used interface from session when context interface was empty' ); >+ >+ t::lib::Mocks::mock_preference( 'SessionRestrictionByIP', 1 ); >+}; >+ > $schema->storage->txn_rollback; >-- >2.41.0
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 33879
:
151928
|
151931
|
151932
|
151933
|
152300
|
152301
|
152328
|
152329
|
152366
|
152367
| 152735 |
152736