Bugzilla – Attachment 102493 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: Prepare Log.t for further changes
Bug-21190-Prepare-Logt-for-further-changes.patch (text/plain), 4.85 KB, created by
Jonathan Druart
on 2020-04-07 10:27:19 UTC
(
hide
)
Description:
Bug 21190: Prepare Log.t for further changes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-07 10:27:19 UTC
Size:
4.85 KB
patch
obsolete
>From 2afca9466caf3d25f9bd7f13f28e0f4a48460160 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 25 Oct 2019 07:14:18 +0000 >Subject: [PATCH] Bug 21190: Prepare Log.t for further changes > >This patch only makes cosmetic changes: >[1] It moves the existing tests at 'root level' inside a new subtest. >[2] It obviously adds indentation for step 1. >[3] It fixes some whitespace (tabs, space before newline) > >Test plan: >Run t/db../Log.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Jon Knight <J.P.Knight@lboro.ac.uk> > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Log.t | 102 ++++++++++++++++++++++--------------------- > 1 file changed, 53 insertions(+), 49 deletions(-) > >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index cd0acc0778..d24a405afd 100644 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -18,7 +18,7 @@ > # Add more tests here!!! > > use Modern::Perl; >-use Test::More tests => 10; >+use Test::More tests => 5; > > use C4::Context; > use Koha::Database; >@@ -29,7 +29,7 @@ use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog > $| = 1; > > BEGIN { >- use_ok('C4::Log'); >+ use_ok('C4::Log'); > } > my $success; > >@@ -38,55 +38,59 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > my $dbh = C4::Context->dbh; > >-eval { >- # FIXME: are we sure there is an member number 1? >- logaction("MEMBERS","MODIFY",1,"test operation"); >- $success = 1; >-} or do { >- diag($@); >- $success = 0; >-}; >-ok($success, "logaction seemed to work"); >- >-eval { >- # FIXME: US formatted date hardcoded into test for now >- $success = scalar(@{GetLogs("","","",undef,undef,"","")}); >-} or do { >- diag($@); >- $success = 0; >-}; >-ok($success, "GetLogs returns results for an open search"); >- >-eval { >- # FIXME: US formatted date hardcoded into test for now >- my $date = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); >- $success = scalar(@{GetLogs( $date, $date, "", undef, undef, "", "") } ); >-} or do { >- diag($@); >- $success = 0; >-}; >-ok($success, "GetLogs accepts dates in an All-matching search"); >- >-eval { >- $success = scalar(@{GetLogs("","","",["MEMBERS"],["MODIFY"],1,"")}); >-} or do { >- diag($@); >- $success = 0; >-}; >-ok($success, "GetLogs seemed to find ".$success." like our test record in a tighter search"); >- >-# We want numbers to be the same between runs. >-$dbh->do("DELETE FROM action_logs;"); >+subtest 'Existing tests' => sub { >+ plan tests => 6; >+ >+ eval { >+ # FIXME: are we sure there is an member number 1? >+ logaction("MEMBERS","MODIFY",1,"test operation"); >+ $success = 1; >+ } or do { >+ diag($@); >+ $success = 0; >+ }; >+ ok($success, "logaction seemed to work"); >+ >+ eval { >+ # FIXME: US formatted date hardcoded into test for now >+ $success = scalar(@{GetLogs("","","",undef,undef,"","")}); >+ } or do { >+ diag($@); >+ $success = 0; >+ }; >+ ok($success, "GetLogs returns results for an open search"); >+ >+ eval { >+ # FIXME: US formatted date hardcoded into test for now >+ my $date = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ); >+ $success = scalar(@{GetLogs( $date, $date, "", undef, undef, "", "") } ); >+ } or do { >+ diag($@); >+ $success = 0; >+ }; >+ ok($success, "GetLogs accepts dates in an All-matching search"); >+ >+ eval { >+ $success = scalar(@{GetLogs("","","",["MEMBERS"],["MODIFY"],1,"")}); >+ } or do { >+ diag($@); >+ $success = 0; >+ }; >+ ok($success, "GetLogs seemed to find ".$success." like our test record in a tighter search"); >+ >+ # We want numbers to be the same between runs. >+ $dbh->do("DELETE FROM action_logs;"); > >-t::lib::Mocks::mock_preference('CronjobLog',0); >-cronlogaction(); >-my $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{}); >-is($cronJobCount,0,"Cronjob not logged as expected."); >+ t::lib::Mocks::mock_preference('CronjobLog',0); >+ cronlogaction(); >+ my $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{}); >+ is($cronJobCount,0,"Cronjob not logged as expected."); > >-t::lib::Mocks::mock_preference('CronjobLog',1); >-cronlogaction(); >-$cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{}); >-is($cronJobCount,1,"Cronjob logged as expected."); >+ t::lib::Mocks::mock_preference('CronjobLog',1); >+ cronlogaction(); >+ $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{}); >+ is($cronJobCount,1,"Cronjob logged as expected."); >+}; > > subtest "GetLogs should return all logs if dates are not set" => sub { > plan tests => 2; >-- >2.20.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 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