Bugzilla – Attachment 129682 Details for
Bug 29914
check_cookie_auth not strict enough
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29914: Add tests
Bug-29914-Add-tests.patch (text/plain), 1.87 KB, created by
Jonathan Druart
on 2022-01-21 08:35:22 UTC
(
hide
)
Description:
Bug 29914: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-01-21 08:35:22 UTC
Size:
1.87 KB
patch
obsolete
>From 852c71c0664ad3101694f630e4f7033db85e59a5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 21 Jan 2022 09:23:38 +0100 >Subject: [PATCH] Bug 29914: Add tests > >--- > t/db_dependent/Auth.t | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 5fdf29a9137..bc5f67fc92b 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -10,7 +10,7 @@ use CGI qw ( -utf8 ); > use Test::MockObject; > use Test::MockModule; > use List::MoreUtils qw/all any none/; >-use Test::More tests => 23; >+use Test::More tests => 24; > use Test::Warn; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -441,4 +441,30 @@ subtest '_timeout_syspref' => sub { > is( C4::Auth::_timeout_syspref, 600, ); > }; > >+subtest 'check_cookie_auth' => sub { >+ plan tests => 1; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 1 } }); >+ >+ # Mock a CGI object with real userid param >+ my $cgi = Test::MockObject->new(); >+ $cgi->mock( >+ 'param', >+ sub { >+ my $var = shift; >+ if ( $var eq 'userid' ) { return $patron->userid; } >+ elsif ( $var eq 'timeout' ) { return 3600; } >+ } >+ ); >+ $cgi->mock('multi_param', sub {return q{}} ); >+ $cgi->mock( 'cookie', sub { return; } ); >+ $cgi->mock( 'request_method', sub { return 'POST' } ); >+ >+ # Setting authnotrequired=1 or we wont' hit the return but the end of the sub that prints headers >+ my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 1 ); >+ >+ my ($auth_status, $session) = C4::Auth::check_cookie_auth($sessionID, {catalogue => 1}); >+ is( $auth_status, 'anon', 'check_cookie_auth should not return ok if the user has not been authenticated before' ); >+}; >+ > $schema->storage->txn_rollback; >-- >2.25.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 29914
:
129634
|
129643
|
129652
|
129664
|
129682
|
129693
|
129694
|
129718
|
129719
|
129720
|
129725
|
129726
|
129727
|
129728
|
129729
|
129742
|
129743