|
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 |
|
| 213 |
plan tests => 3; |
| 214 |
|
| 215 |
$schema->storage->txn_begin; |
| 216 |
|
| 217 |
my $patron = $builder->build_object( |
| 218 |
{ |
| 219 |
class => 'Koha::Patrons', |
| 220 |
value => { flags => 2**2 } # catalogue flag = 2 |
| 221 |
} |
| 222 |
); |
| 223 |
my $patron_password = 'thePassword123'; |
| 224 |
$patron->set_password( { password => $patron_password, skip_validation => 1 } ); |
| 225 |
|
| 226 |
my $date = dt_from_string(); |
| 227 |
my $expiration_date = $date->subtract( days => 1 ); |
| 228 |
|
| 229 |
$patron->password_expiration_date($expiration_date)->store; |
| 230 |
|
| 231 |
my $json = { |
| 232 |
identifier => $patron->userid, |
| 233 |
password => $patron_password, |
| 234 |
}; |
| 235 |
|
| 236 |
$t->post_ok( "//$userid:$password@/api/v1/auth/password/validation" => json => $json )->status_is(400) |
| 237 |
->json_is( '/error' => 'Password expired' ); |
| 238 |
|
| 239 |
$schema->storage->txn_rollback; |
| 240 |
}; |
| 241 |
|
| 210 |
$schema->storage->txn_rollback; |
242 |
$schema->storage->txn_rollback; |
| 211 |
- |
|
|