|
Lines 237-243
$schema->storage->txn_rollback;
Link Here
|
| 237 |
|
237 |
|
| 238 |
subtest 'get_availability' => sub { |
238 |
subtest 'get_availability' => sub { |
| 239 |
|
239 |
|
| 240 |
plan tests => 27; |
240 |
plan tests => 28; |
| 241 |
|
241 |
|
| 242 |
$schema->storage->txn_begin; |
242 |
$schema->storage->txn_begin; |
| 243 |
my $librarian = $builder->build_object( |
243 |
my $librarian = $builder->build_object( |
|
Lines 326-338
subtest 'get_availability' => sub {
Link Here
|
| 326 |
->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } ) |
326 |
->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } ) |
| 327 |
->json_is( '/warnings' => {} ) |
327 |
->json_is( '/warnings' => {} ) |
| 328 |
->json_is( '/confirmation_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw' ); |
328 |
->json_is( '/confirmation_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw' ); |
|
|
329 |
%needsconfirmation = (); |
| 330 |
|
| 331 |
subtest 'public availability' => sub { |
| 332 |
plan tests => 18; |
| 333 |
|
| 334 |
# Available, Not authentication required |
| 335 |
$t->get_ok( |
| 336 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
| 337 |
)->status_is(200)->json_is( '/blockers' => {} ) |
| 338 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
| 339 |
->json_is( '/confirmation_token' => undef ); |
| 340 |
|
| 341 |
# Needs confirmation upgrade to blocker |
| 342 |
%needsconfirmation = ( TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 ); |
| 343 |
$t->get_ok( |
| 344 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
| 345 |
)->status_is(200) |
| 346 |
->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } ) |
| 347 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
| 348 |
->json_is( '/confirmation_token' => undef ); |
| 349 |
%needsconfirmation = (); |
| 350 |
|
| 351 |
# Remove personal information from public endpoint |
| 352 |
%issuingimpossible = ( |
| 353 |
issued_borrowernumber => 'private', |
| 354 |
issued_cardnumber => 'private', |
| 355 |
issued_firstname => 'private', |
| 356 |
issued_surname => 'private', |
| 357 |
resborrowernumber => 'private', |
| 358 |
resbranchcode => 'private', |
| 359 |
rescardnumber => 'private', |
| 360 |
reserve_id => 'private', |
| 361 |
resfirstname => 'private', |
| 362 |
resreservedate => 'private', |
| 363 |
ressurname => 'private', |
| 364 |
item_notforloan => 'private' |
| 365 |
); |
| 366 |
%alerts = ( |
| 367 |
issued_borrowernumber => 'private', |
| 368 |
issued_cardnumber => 'private', |
| 369 |
issued_firstname => 'private', |
| 370 |
issued_surname => 'private', |
| 371 |
resborrowernumber => 'private', |
| 372 |
resbranchcode => 'private', |
| 373 |
rescardnumber => 'private', |
| 374 |
reserve_id => 'private', |
| 375 |
resfirstname => 'private', |
| 376 |
resreservedate => 'private', |
| 377 |
ressurname => 'private', |
| 378 |
item_notforloan => 'private' |
| 379 |
); |
| 380 |
|
| 381 |
%needsconfirmation = ( |
| 382 |
issued_borrowernumber => 'private', |
| 383 |
issued_cardnumber => 'private', |
| 384 |
issued_firstname => 'private', |
| 385 |
issued_surname => 'private', |
| 386 |
resborrowernumber => 'private', |
| 387 |
resbranchcode => 'private', |
| 388 |
rescardnumber => 'private', |
| 389 |
reserve_id => 'private', |
| 390 |
resfirstname => 'private', |
| 391 |
resreservedate => 'private', |
| 392 |
ressurname => 'private', |
| 393 |
item_notforloan => 'private' |
| 394 |
); |
| 395 |
$t->get_ok( |
| 396 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
| 397 |
)->status_is(200)->json_is( '/blockers' => {} ) |
| 398 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
| 399 |
->json_is( '/confirmation_token' => undef ); |
| 400 |
%issuingimpossible = (); |
| 401 |
%alerts = (); |
| 402 |
%needsconfirmation = (); |
| 403 |
}; |
| 329 |
|
404 |
|
| 330 |
$schema->storage->txn_rollback; |
405 |
$schema->storage->txn_rollback; |
| 331 |
}; |
406 |
}; |
| 332 |
|
407 |
|
| 333 |
subtest 'add checkout' => sub { |
408 |
subtest 'add checkout' => sub { |
| 334 |
|
409 |
|
| 335 |
plan tests => 9; |
410 |
plan tests => 10; |
| 336 |
|
411 |
|
| 337 |
$schema->storage->txn_begin; |
412 |
$schema->storage->txn_begin; |
| 338 |
my $librarian = $builder->build_object( |
413 |
my $librarian = $builder->build_object( |
|
Lines 406-410
subtest 'add checkout' => sub {
Link Here
|
| 406 |
)->status_is(201)->or(sub { diag $t->tx->res->body }); |
481 |
)->status_is(201)->or(sub { diag $t->tx->res->body }); |
| 407 |
%needsconfirmation = (); |
482 |
%needsconfirmation = (); |
| 408 |
|
483 |
|
|
|
484 |
subtest 'public add' => sub { |
| 485 |
plan tests => 14; |
| 486 |
|
| 487 |
my $useridp = $patron->userid; |
| 488 |
$patron->set_password( |
| 489 |
{ password => $password, skip_validation => 1 } ); |
| 490 |
|
| 491 |
# Feature disabled |
| 492 |
t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 0 ); |
| 493 |
|
| 494 |
$t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => |
| 495 |
{ item_id => $item1_id, patron_id => $patron_id } ) |
| 496 |
->status_is(401)->json_is( |
| 497 |
{ |
| 498 |
error => "Authentication failure." |
| 499 |
} |
| 500 |
); |
| 501 |
|
| 502 |
$t->post_ok( |
| 503 |
"//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" |
| 504 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
| 505 |
->status_is(405) |
| 506 |
->json_is( |
| 507 |
{ error => "Feature disabled", error_code => "FEATURE_DISABLED" } ); |
| 508 |
|
| 509 |
# Feature enabled |
| 510 |
t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 1 ); |
| 511 |
|
| 512 |
$t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => |
| 513 |
{ item_id => $item1_id, patron_id => $patron_id } ) |
| 514 |
->status_is(401)->json_is( |
| 515 |
{ |
| 516 |
error => "Authentication failure." |
| 517 |
} |
| 518 |
); |
| 519 |
|
| 520 |
$t->post_ok( |
| 521 |
"//$userid:$password@/api/v1/public/patrons/$patron_id/checkouts" |
| 522 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
| 523 |
->status_is(403)->json_is( |
| 524 |
{ |
| 525 |
error => |
| 526 |
"Authorization failure. Missing required permission(s).", |
| 527 |
required_permissions => undef |
| 528 |
} |
| 529 |
); |
| 530 |
|
| 531 |
$t->post_ok( |
| 532 |
"//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" |
| 533 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
| 534 |
->status_is(201); |
| 535 |
}; |
| 536 |
|
| 409 |
$schema->storage->txn_rollback; |
537 |
$schema->storage->txn_rollback; |
| 410 |
}; |
538 |
}; |
| 411 |
- |
|
|