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