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

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

Return to bug 21190