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

(-)a/t/db_dependent/ILSDI_Services.t (-2 / +51 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
21
22
use Test::More tests => 9;
22
use Test::More tests => 10;
23
use Test::MockModule;
23
use Test::MockModule;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 104-109 subtest 'AuthenticatePatron test' => sub { Link Here
104
};
104
};
105
105
106
106
107
subtest 'AuthenticatePatron Secure Password test' => sub {
108
109
    plan tests => 10;
110
111
    $schema->storage->txn_begin;
112
113
    my $plain_password = 'tomasito';
114
115
    $builder->build({
116
        source => 'Borrower',
117
        value => {
118
            cardnumber => undef,
119
        }
120
    });
121
122
    my $borrower = $builder->build({
123
        source => 'Borrower',
124
        value  => {
125
            cardnumber => undef,
126
            password => Koha::AuthUtils::hash_password( $plain_password )
127
        }
128
    });
129
130
    my $query = new CGI;
131
    $query->param( 'username', $borrower->{userid});
132
    $query->param( 'password', $plain_password);
133
134
    my $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
135
    is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" );
136
    is( $reply->{code}, undef, "Error code undef");
137
138
    t::lib::Mocks::mock_preference( 'minPasswordLength', 10 );
139
    $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
140
    is( $reply->{id}, $borrower->{borrowernumber}, "existing user");
141
    is( $reply->{code}, 'PatronPasswordNotSecure', "PasswordNotSecure" );
142
    is( $reply->{securePasswordLabel}, 'too_short', "PasswordTooShort" );
143
    is( $reply->{securePasswordPattern}, '.{10}', "Password must be at least 10 char" );
144
145
    t::lib::Mocks::mock_preference( 'RequireStrongPassword', 1 );
146
    t::lib::Mocks::mock_preference( 'minPasswordLength', 5 );
147
    $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
148
    is( $reply->{id}, $borrower->{borrowernumber}, "existing user");
149
    is( $reply->{code}, 'PatronPasswordNotSecure', "PasswordNotSecure" );
150
    is( $reply->{securePasswordLabel}, 'too_weak', "PasswordTooWeak" );
151
    is( $reply->{securePasswordPattern}, '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5}', "Password must be strong (pattern match)" );
152
153
    $schema->storage->txn_rollback;
154
};
155
156
107
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
157
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
108
158
109
    plan tests => 5;
159
    plan tests => 5;
110
- 

Return to bug 23011