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

(-)a/t/db_dependent/api/v1/password_validation.t (-2 / +32 lines)
Lines 18-30 Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
20
21
use Test::More tests => 4;
21
use Test::More tests => 5;
22
use Test::Mojo;
22
use Test::Mojo;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use t::lib::Mocks;
25
use t::lib::Mocks;
26
26
27
use Koha::Database;
27
use Koha::Database;
28
use Koha::DateUtils qw(dt_from_string);
28
29
29
my $schema  = Koha::Database->new->schema;
30
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
31
my $builder = t::lib::TestBuilder->new;
Lines 207-210 subtest 'Password validation - authorized requests tests' => sub { Link Here
207
    $schema->storage->txn_rollback;
208
    $schema->storage->txn_rollback;
208
};
209
};
209
210
211
subtest 'password validation - expired password' => sub {
212
    plan tests => 3;
213
214
    $schema->storage->txn_begin;
215
216
    my $patron = $builder->build_object(
217
        {
218
            class => 'Koha::Patrons',
219
            value => { flags => 2**2 }    # catalogue flag = 2
220
        }
221
    );
222
    my $patron_password = 'thePassword123';
223
    $patron->set_password( { password => $patron_password, skip_validation => 1 } );
224
    my $date = dt_from_string();
225
    my $expiration_date = $date->subtract( days => 1 );
226
    $patron->password_expiration_date( $expiration_date )->store;
227
    my $patronid = $patron->userid;
228
229
    my $json = {
230
        identifier => $patronid,
231
        password   => $patron_password,
232
    };
233
234
    $t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json )->status_is(400)
235
        ->json_is( '/error' => 'Password expired' );
236
237
    $schema->storage->txn_rollback;
238
};
239
240
210
$schema->storage->txn_rollback;
241
$schema->storage->txn_rollback;
211
- 

Return to bug 35204