|
Lines 15-21
Link Here
|
| 15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
| 16 |
|
16 |
|
| 17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
| 18 |
use Test::More tests => 3; |
18 |
use Test::More tests => 4; |
|
|
19 |
use Data::Dumper qw( Dumper ); |
| 19 |
|
20 |
|
| 20 |
use C4::Context; |
21 |
use C4::Context; |
| 21 |
use C4::Log qw( logaction cronlogaction ); |
22 |
use C4::Log qw( logaction cronlogaction ); |
|
Lines 30-35
use t::lib::TestBuilder;
Link Here
|
| 30 |
our $schema = Koha::Database->new->schema; |
31 |
our $schema = Koha::Database->new->schema; |
| 31 |
$schema->storage->txn_begin; |
32 |
$schema->storage->txn_begin; |
| 32 |
our $dbh = C4::Context->dbh; |
33 |
our $dbh = C4::Context->dbh; |
|
|
34 |
our $builder = t::lib::TestBuilder->new; |
| 33 |
|
35 |
|
| 34 |
subtest 'Existing tests' => sub { |
36 |
subtest 'Existing tests' => sub { |
| 35 |
plan tests => 3; |
37 |
plan tests => 3; |
|
Lines 95-101
subtest 'logaction(): interface is correctly logged' => sub {
Link Here
|
| 95 |
subtest 'GDPR logging' => sub { |
97 |
subtest 'GDPR logging' => sub { |
| 96 |
plan tests => 6; |
98 |
plan tests => 6; |
| 97 |
|
99 |
|
| 98 |
my $builder = t::lib::TestBuilder->new; |
|
|
| 99 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
100 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 100 |
|
101 |
|
| 101 |
t::lib::Mocks::mock_userenv({ patron => $patron }); |
102 |
t::lib::Mocks::mock_userenv({ patron => $patron }); |
|
Lines 150-153
subtest 'GDPR logging' => sub {
Link Here
|
| 150 |
is( $logs->count, 1, 'We expect only one auth success line for this patron' ); |
151 |
is( $logs->count, 1, 'We expect only one auth success line for this patron' ); |
| 151 |
}; |
152 |
}; |
| 152 |
|
153 |
|
|
|
154 |
subtest 'Condense logging' => sub { |
| 155 |
plan tests => 4; |
| 156 |
|
| 157 |
# Log a patron object |
| 158 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 159 |
t::lib::Mocks::mock_preference('LogCondenseLimit', 2000 ); |
| 160 |
logaction( "MEMBERS", "MODIFY", $patron->id, $patron, 'test1' ); |
| 161 |
my $logs = Koha::ActionLogs->search({ object => $patron->id }); |
| 162 |
my $rec = $logs->next; |
| 163 |
is( length($rec->info), 2000, 'First 2000 chars in log' ); |
| 164 |
|
| 165 |
# Lower limit |
| 166 |
t::lib::Mocks::mock_preference('LogCondenseLimit', 1000 ); |
| 167 |
logaction( "MEMBERS", "MODIFY", $patron->id, $patron, 'test2' ); |
| 168 |
#$logs->reset; |
| 169 |
$rec = $logs->search({ interface => 'test2' })->next; |
| 170 |
is( length($rec->info), 1000, 'First 1000 chars found as expected' ); |
| 171 |
|
| 172 |
# Log an unblessed hold |
| 173 |
t::lib::Mocks::mock_preference('LogCondenseLimit', 200 ); |
| 174 |
my $hold_unblessed = $builder->build_object( { class => 'Koha::Holds' } )->unblessed; |
| 175 |
my $info = Dumper( $hold_unblessed ); |
| 176 |
logaction( "HOLDS", "TEST", $hold_unblessed->{reserve_id}, $hold_unblessed, 'test3' ); |
| 177 |
$logs = Koha::ActionLogs->search({ object => $hold_unblessed->{reserve_id}, interface => 'test3' }); |
| 178 |
$rec = $logs->next; |
| 179 |
is( $rec->info, substr($info, 0, 200), 'Dump of unblessed hold found' ); |
| 180 |
|
| 181 |
# Pass a too long string |
| 182 |
logaction( "HOLDS", "TEST", $hold_unblessed->{reserve_id}, $info, 'test4' ); |
| 183 |
$logs = Koha::ActionLogs->search({ object => $hold_unblessed->{reserve_id}, interface => 'test4' }); |
| 184 |
$rec = $logs->next; |
| 185 |
is( length($rec->info), 200, 'First 200 chars found as expected' ); |
| 186 |
}; |
| 187 |
|
| 153 |
$schema->storage->txn_rollback; |
188 |
$schema->storage->txn_rollback; |
| 154 |
- |
|
|