View | Details | Raw Unified | Return to bug 21190
Collapse All | Expand All

(-)a/t/db_dependent/Log.t (-4 / +22 lines)
Lines 21-26 use Test::More tests => 5; Link Here
21
21
22
use C4::Context;
22
use C4::Context;
23
use C4::Log;
23
use C4::Log;
24
use C4::Auth qw/checkpw/;
24
use Koha::Database;
25
use Koha::Database;
25
use Koha::DateUtils;
26
use Koha::DateUtils;
26
27
Lines 164-170 subtest 'GetLogs() respects interface filters' => sub { Link Here
164
};
165
};
165
166
166
subtest 'GDPR logging' => sub {
167
subtest 'GDPR logging' => sub {
167
    plan tests => 1;
168
    plan tests => 6;
168
169
169
    my $builder = t::lib::TestBuilder->new;
170
    my $builder = t::lib::TestBuilder->new;
170
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
171
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
Lines 172-179 subtest 'GDPR logging' => sub { Link Here
172
    t::lib::Mocks::mock_userenv({ patron => $patron });
173
    t::lib::Mocks::mock_userenv({ patron => $patron });
173
    logaction( 'AUTH', 'FAILURE', $patron->id, '', 'opac' );
174
    logaction( 'AUTH', 'FAILURE', $patron->id, '', 'opac' );
174
    my $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['FAILURE'], $patron->id );
175
    my $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['FAILURE'], $patron->id );
175
    is( @$logs, 1, 'We should find one auth failure for this patron' );
176
    is( @$logs, 1, 'We should find one auth failure' );
176
177
178
    t::lib::Mocks::mock_preference('AuthFailureLog', 1);
179
    my $strong_password = 'N0tStr0ngAnyM0reN0w:)';
180
    $patron->set_password({ password => $strong_password });
181
    my @ret = checkpw( $dbh, $patron->userid, 'WrongPassword', undef, undef, 1);
182
    is( $ret[0], 0, 'Authentication failed' );
183
    # Look for auth failure but NOT on patron id, pass userid in info parameter
184
    $logs = GetLogs( undef, undef, 0, ['AUTH'], ['FAILURE'], undef, $patron->userid );
185
    is( @$logs, 1, 'We should find one auth failure with this userid' );
186
    t::lib::Mocks::mock_preference('AuthFailureLog', 0);
187
    @ret = checkpw( $dbh, $patron->userid, 'WrongPassword', undef, undef, 1);
188
    $logs = GetLogs( undef, undef, 0, ['AUTH'], ['FAILURE'], undef, $patron->userid );
189
    is( @$logs, 1, 'Still only one failure with this userid' );
190
    t::lib::Mocks::mock_preference('AuthSuccessLog', 1);
191
    @ret = checkpw( $dbh, $patron->userid, $strong_password, undef, undef, 1);
192
    is( $ret[0], 1, 'Authentication succeeded' );
193
    # Now we can look for patron id
194
    $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['SUCCESS'], $patron->id );
195
    is( @$logs, 1, 'We expect only one auth success line for this patron' );
177
};
196
};
178
197
179
$schema->storage->txn_rollback;
198
$schema->storage->txn_rollback;
180
- 

Return to bug 21190