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

(-)a/t/db_dependent/Auth.t (-2 / +25 lines)
Lines 10-16 use CGI qw ( -utf8 ); Link Here
10
use Test::MockObject;
10
use Test::MockObject;
11
use Test::MockModule;
11
use Test::MockModule;
12
use List::MoreUtils qw/all any none/;
12
use List::MoreUtils qw/all any none/;
13
use Test::More tests => 20;
13
use Test::More tests => 21;
14
use Test::Warn;
14
use Test::Warn;
15
use t::lib::Mocks;
15
use t::lib::Mocks;
16
use t::lib::TestBuilder;
16
use t::lib::TestBuilder;
Lines 137-142 subtest 'no_set_userenv parameter tests' => sub { Link Here
137
    isnt( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is overwritten if no_set_userenv is false' );
137
    isnt( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv branch is overwritten if no_set_userenv is false' );
138
};
138
};
139
139
140
subtest 'checkpw lockout tests' => sub {
141
142
    plan tests => 5;
143
144
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
145
    my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
146
    my $password = 'password';
147
    t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
148
    t::lib::Mocks::mock_preference( 'FailedLoginAttempts', 1 );
149
    $patron->set_password({ password => $password });
150
151
    my ( $checkpw, undef, undef ) = checkpw( $dbh, $patron->cardnumber, $password, undef, undef, 1 );
152
    ok( $checkpw, 'checkpw returns true with right password when logging in via cardnumber' );
153
    ( $checkpw, undef, undef ) = checkpw( $dbh, $patron->userid, "wrong_password", undef, undef, 1 );
154
    is( $checkpw, 0, 'checkpw returns false when given wrong password' );
155
    $patron = $patron->get_from_storage;
156
    is( $patron->account_locked, 1, "Account is locked from failed login");
157
    ( $checkpw, undef, undef ) = checkpw( $dbh, $patron->userid, $password, undef, undef, 1 );
158
    is( $checkpw, undef, 'checkpw returns undef with right password when account locked' );
159
    ( $checkpw, undef, undef ) = checkpw( $dbh, $patron->cardnumber, $password, undef, undef, 1 );
160
    is( $checkpw, undef, 'checkpw returns undefwith right password when logging in via cardnumber if account locked' );
161
162
};
163
140
# get_template_and_user tests
164
# get_template_and_user tests
141
165
142
{   # Tests for the language URL parameter
166
{   # Tests for the language URL parameter
143
- 

Return to bug 22692