Bugzilla – Attachment 143820 Details for
Bug 31908
New login fails while having cookie from previous session
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31908: Add a test to show issue
Bug-31908-Add-a-test-to-show-issue.patch (text/plain), 3.37 KB, created by
Marcel de Rooy
on 2022-11-14 12:20:49 UTC
(
hide
)
Description:
Bug 31908: Add a test to show issue
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-11-14 12:20:49 UTC
Size:
3.37 KB
patch
obsolete
>From 4c0959c9bc139b8cb6d906d294ce877cead977f4 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 14 Nov 2022 11:07:09 +0000 >Subject: [PATCH] Bug 31908: Add a test to show issue >Content-Type: text/plain; charset=utf-8 > >Test plan: >Without next patch, run Auth.t. >Should fail now before next patch resolves problem: > not ok 2 - Login of patron2 approved > ok 3 - Did not return previous session ID > not ok 4 - New session ID not empty > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Auth.t | 45 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index c8da8bd89d..38ed732671 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -41,7 +41,7 @@ $schema->storage->txn_begin; > > subtest 'checkauth() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => undef } }); > >@@ -152,6 +152,49 @@ subtest 'checkauth() tests' => sub { > }; > }; > >+ subtest 'While still logged in, relogin with another user' => sub { >+ plan tests => 4; >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => {} }); >+ my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => {} }); >+ # Create 'former' session >+ 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; >+ my $sessionID = $session->id; >+ C4::Context->_new_userenv($sessionID); >+ >+ my ( $return ) = C4::Auth::check_cookie_auth( $sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } ); >+ is( $return, 'ok', 'Former session in shape now' ); >+ >+ my $mock1 = Test::MockModule->new('C4::Auth')->mock( 'safe_exit', sub {} ); >+ my $mock2 = Test::MockModule->new('CGI') ->mock( 'request_method', 'POST' ) >+ ->mock( 'cookie', sub { return $sessionID; } ); # oversimplified.. >+ my $cgi = CGI->new; >+ my $password = 'Incr3d1blyZtr@ng93$'; >+ $patron2->set_password({ password => $password }); >+ $cgi->param( -name => 'userid', -value => $patron2->userid ); >+ $cgi->param( -name => 'password', -value => $password ); >+ $cgi->param( -name => 'koha_login_context', -value => 1 ); >+ my @return; >+ { >+ local *STDOUT; >+ local %ENV; >+ $ENV{REMOTE_ADDR} = '1.2.3.4'; >+ my $stdout; >+ open STDOUT, '>', \$stdout; >+ @return = C4::Auth::checkauth( $cgi, 0, {} ); >+ close STDOUT; >+ } >+ # Note: We can test return values from checkauth here since we mocked the safe_exit after the Redirect 303 >+ is( $return[0], $patron2->userid, 'Login of patron2 approved' ); >+ isnt( $return[2], $sessionID, 'Did not return previous session ID' ); >+ ok( $return[2], 'New session ID not empty' ); >+ }; >+ > subtest 'Two-factor authentication' => sub { > plan tests => 18; > >-- >2.30.2
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 31908
:
142361
|
143392
|
143491
|
143786
|
143819
|
143820
|
143821
|
143822
|
143884
|
143885
|
143886
|
143887
|
145092
|
145093
|
145250
|
145251
|
145252