Bugzilla – Attachment 98117 Details for
Bug 21190
Add logging of successful/unsuccessful login attempts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21190: Add tests for authentication success and failure
Bug-21190-Add-tests-for-authentication-success-and.patch (text/plain), 2.67 KB, created by
ByWater Sandboxes
on 2020-01-30 09:17:16 UTC
(
hide
)
Description:
Bug 21190: Add tests for authentication success and failure
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2020-01-30 09:17:16 UTC
Size:
2.67 KB
patch
obsolete
>From 200d1a74aab89c93f9f26cf912f4a8280ecd62a5 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 28 Oct 2019 10:06:11 +0000 >Subject: [PATCH] Bug 21190: Add tests for authentication success and failure > >Test plan: >Run t/db_dependent/Log.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Jon Knight <J.P.Knight@lboro.ac.uk> >--- > t/db_dependent/Log.t | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index f84fb14265..2665ead03a 100644 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -21,6 +21,7 @@ use Test::More tests => 5; > > use C4::Context; > use C4::Log; >+use C4::Auth qw/checkpw/; > use Koha::Database; > use Koha::DateUtils; > >@@ -164,7 +165,7 @@ subtest 'GetLogs() respects interface filters' => sub { > }; > > subtest 'GDPR logging' => sub { >- plan tests => 1; >+ plan tests => 6; > > my $builder = t::lib::TestBuilder->new; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >@@ -172,8 +173,26 @@ subtest 'GDPR logging' => sub { > t::lib::Mocks::mock_userenv({ patron => $patron }); > logaction( 'AUTH', 'FAILURE', $patron->id, '', 'opac' ); > my $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['FAILURE'], $patron->id ); >- is( @$logs, 1, 'We should find one auth failure for this patron' ); >- >+ is( @$logs, 1, 'We should find one auth failure' ); >+ >+ t::lib::Mocks::mock_preference('AuthFailureLog', 1); >+ my $strong_password = 'N0tStr0ngAnyM0reN0w:)'; >+ $patron->set_password({ password => $strong_password }); >+ my @ret = checkpw( $dbh, $patron->userid, 'WrongPassword', undef, undef, 1); >+ is( $ret[0], 0, 'Authentication failed' ); >+ # Look for auth failure but NOT on patron id, pass userid in info parameter >+ $logs = GetLogs( undef, undef, 0, ['AUTH'], ['FAILURE'], undef, $patron->userid ); >+ is( @$logs, 1, 'We should find one auth failure with this userid' ); >+ t::lib::Mocks::mock_preference('AuthFailureLog', 0); >+ @ret = checkpw( $dbh, $patron->userid, 'WrongPassword', undef, undef, 1); >+ $logs = GetLogs( undef, undef, 0, ['AUTH'], ['FAILURE'], undef, $patron->userid ); >+ is( @$logs, 1, 'Still only one failure with this userid' ); >+ t::lib::Mocks::mock_preference('AuthSuccessLog', 1); >+ @ret = checkpw( $dbh, $patron->userid, $strong_password, undef, undef, 1); >+ is( $ret[0], 1, 'Authentication succeeded' ); >+ # Now we can look for patron id >+ $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['SUCCESS'], $patron->id ); >+ is( @$logs, 1, 'We expect only one auth success line for this patron' ); > }; > > $schema->storage->txn_rollback; >-- >2.11.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 21190
:
94713
|
94714
|
94715
|
94717
|
94732
|
94733
|
94734
|
94735
|
94736
|
94805
|
98067
|
98068
|
98069
|
98070
|
98071
|
98072
|
98073
|
98074
|
98110
|
98111
|
98112
|
98113
|
98114
|
98115
|
98116
|
98117
|
98125
|
98133
|
98134
|
98135
|
98136
|
98137
|
98138
|
98139
|
98140
|
98141
|
101971
|
101972
|
101973
|
101974
|
101975
|
101976
|
101977
|
101978
|
101979
|
102493
|
102494
|
102496
|
102497
|
102498
|
102499
|
102500
|
102501
|
102502
|
123540