|
Lines 44-50
my $remote_address = '127.0.0.1';
Link Here
|
| 44 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
44 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
| 45 |
|
45 |
|
| 46 |
subtest 'recovery() tests' => sub { |
46 |
subtest 'recovery() tests' => sub { |
| 47 |
plan tests => 31; |
47 |
plan tests => 32; |
| 48 |
|
48 |
|
| 49 |
$schema->storage->txn_begin; |
49 |
$schema->storage->txn_begin; |
| 50 |
|
50 |
|
|
Lines 246-251
subtest 'recovery() tests' => sub {
Link Here
|
| 246 |
); |
246 |
); |
| 247 |
}; |
247 |
}; |
| 248 |
|
248 |
|
|
|
249 |
subtest 'skip letter enqueueing' => sub { |
| 250 |
plan tests => 10; |
| 251 |
|
| 252 |
t::lib::Mocks::mock_preference( |
| 253 |
'OpacResetPasswordHostWhitelist', 'anotherallowed' |
| 254 |
); |
| 255 |
my ($service_borrowernumber, $service_session) = create_user_and_session({ |
| 256 |
borrowers => 'get_password_reset_uuid' |
| 257 |
}); |
| 258 |
|
| 259 |
$tx = $t->ua->build_tx(POST => $url => json => { |
| 260 |
email => $patron->email, |
| 261 |
userid => $patron->userid, |
| 262 |
custom_link => 'https://anotherallowed/reset-password.pl', |
| 263 |
skip_mail => Mojo::JSON->true |
| 264 |
}); |
| 265 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
| 266 |
$t->request_ok($tx) |
| 267 |
->status_is(401); |
| 268 |
|
| 269 |
$tx = $t->ua->build_tx(POST => $url => json => { |
| 270 |
email => $patron->email, |
| 271 |
userid => $patron->userid, |
| 272 |
custom_link => 'https://anotherallowed/reset-password.pl', |
| 273 |
skip_mail => Mojo::JSON->true |
| 274 |
}); |
| 275 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
| 276 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
| 277 |
$t->request_ok($tx) |
| 278 |
->status_is(403); |
| 279 |
|
| 280 |
Koha::Notice::Messages->search({ |
| 281 |
borrowernumber => $patron->borrowernumber, |
| 282 |
letter_code => 'PASSWORD_RESET', |
| 283 |
message_transport_type => 'email' |
| 284 |
})->delete; |
| 285 |
|
| 286 |
$tx = $t->ua->build_tx(POST => $url => json => { |
| 287 |
email => $patron->email, |
| 288 |
userid => $patron->userid, |
| 289 |
custom_link => 'https://notallowed/reset-password.pl', |
| 290 |
skip_mail => Mojo::JSON->true, |
| 291 |
}); |
| 292 |
$tx->req->cookies({name => 'CGISESSID', value => $service_session->id}); |
| 293 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
| 294 |
$t->request_ok($tx) |
| 295 |
->status_is(400); |
| 296 |
|
| 297 |
$tx = $t->ua->build_tx(POST => $url => json => { |
| 298 |
email => $patron->email, |
| 299 |
userid => $patron->userid, |
| 300 |
custom_link => 'https://anotherallowed/reset-password.pl', |
| 301 |
skip_mail => Mojo::JSON->true, |
| 302 |
}); |
| 303 |
$tx->req->cookies({name => 'CGISESSID', value => $service_session->id}); |
| 304 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
| 305 |
$t->request_ok($tx) |
| 306 |
->status_is(201); |
| 307 |
my $uuid = $rs->search({ |
| 308 |
borrowernumber => $patron->borrowernumber |
| 309 |
}, { |
| 310 |
order_by => { '-desc' => 'valid_until' } |
| 311 |
})->next->uuid; |
| 312 |
$t->json_is('/uuid', $uuid); |
| 313 |
|
| 314 |
is(Koha::Notice::Messages->search({ |
| 315 |
borrowernumber => $patron->borrowernumber, |
| 316 |
letter_code => 'PASSWORD_RESET', |
| 317 |
message_transport_type => 'email' |
| 318 |
})->count, 0, 'Email not enqueued'); |
| 319 |
}; |
| 320 |
|
| 249 |
$schema->storage->txn_rollback; |
321 |
$schema->storage->txn_rollback; |
| 250 |
}; |
322 |
}; |
| 251 |
|
323 |
|
| 252 |
- |
|
|