Bugzilla – Attachment 98110 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.87 KB, created by
ByWater Sandboxes
on 2020-01-30 09:16:54 UTC
(
hide
)
Description:
Bug 21190: Prepare Log.t for further changes
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2020-01-30 09:16:54 UTC
Size:
4.87 KB
patch
obsolete
>From 63be88e0cb18a72f899910342f77bbfeb8e1d80e 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> >--- > t/db_dependent/Log.t | 104 ++++++++++++++++++++++++++------------------------- > 1 file changed, 54 insertions(+), 50 deletions(-) > >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index 82c9b59012..3267e08ebf 100644 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -1,11 +1,11 @@ > #!/usr/bin/perl > # > # Copyright 2011 MJ Ray and software.coop >-# This Koha test module is a stub! >+# This Koha test module is a stub! > # Add more tests here!!! > > use Modern::Perl; >-use Test::More tests => 10; >+use Test::More tests => 5; > > use C4::Context; > use Koha::Database; >@@ -16,7 +16,7 @@ use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog > $| = 1; > > BEGIN { >- use_ok('C4::Log'); >+ use_ok('C4::Log'); > } > my $success; > >@@ -25,55 +25,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.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