Lines 238-244
$schema->storage->txn_rollback;
Link Here
|
238 |
|
238 |
|
239 |
subtest 'get_availability' => sub { |
239 |
subtest 'get_availability' => sub { |
240 |
|
240 |
|
241 |
plan tests => 28; |
241 |
plan tests => 29; |
242 |
|
242 |
|
243 |
$schema->storage->txn_begin; |
243 |
$schema->storage->txn_begin; |
244 |
my $librarian = $builder->build_object( |
244 |
my $librarian = $builder->build_object( |
Lines 340-352
subtest 'get_availability' => sub {
Link Here
|
340 |
), |
340 |
), |
341 |
'Correct token' |
341 |
'Correct token' |
342 |
); |
342 |
); |
|
|
343 |
%needsconfirmation = (); |
344 |
|
345 |
subtest 'public availability' => sub { |
346 |
plan tests => 18; |
347 |
|
348 |
# Available, Not authentication required |
349 |
$t->get_ok( |
350 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
351 |
)->status_is(200)->json_is( '/blockers' => {} ) |
352 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
353 |
->json_has('/confirmation_token'); |
354 |
|
355 |
# Needs confirmation upgrade to blocker |
356 |
%needsconfirmation = ( TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 ); |
357 |
$t->get_ok( |
358 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
359 |
)->status_is(200) |
360 |
->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } ) |
361 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
362 |
->json_has('/confirmation_token'); |
363 |
%needsconfirmation = (); |
364 |
|
365 |
# Remove personal information from public endpoint |
366 |
%issuingimpossible = ( |
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 |
%alerts = ( |
381 |
issued_borrowernumber => 'private', |
382 |
issued_cardnumber => 'private', |
383 |
issued_firstname => 'private', |
384 |
issued_surname => 'private', |
385 |
resborrowernumber => 'private', |
386 |
resbranchcode => 'private', |
387 |
rescardnumber => 'private', |
388 |
reserve_id => 'private', |
389 |
resfirstname => 'private', |
390 |
resreservedate => 'private', |
391 |
ressurname => 'private', |
392 |
item_notforloan => 'private' |
393 |
); |
394 |
|
395 |
%needsconfirmation = ( |
396 |
issued_borrowernumber => 'private', |
397 |
issued_cardnumber => 'private', |
398 |
issued_firstname => 'private', |
399 |
issued_surname => 'private', |
400 |
resborrowernumber => 'private', |
401 |
resbranchcode => 'private', |
402 |
rescardnumber => 'private', |
403 |
reserve_id => 'private', |
404 |
resfirstname => 'private', |
405 |
resreservedate => 'private', |
406 |
ressurname => 'private', |
407 |
item_notforloan => 'private' |
408 |
); |
409 |
$t->get_ok( |
410 |
"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" |
411 |
)->status_is(200)->json_is( '/blockers' => {} ) |
412 |
->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) |
413 |
->json_has('/confirmation_token'); |
414 |
%issuingimpossible = (); |
415 |
%alerts = (); |
416 |
%needsconfirmation = (); |
417 |
}; |
343 |
|
418 |
|
344 |
$schema->storage->txn_rollback; |
419 |
$schema->storage->txn_rollback; |
345 |
}; |
420 |
}; |
346 |
|
421 |
|
347 |
subtest 'add checkout' => sub { |
422 |
subtest 'add checkout' => sub { |
348 |
|
423 |
|
349 |
plan tests => 9; |
424 |
plan tests => 10; |
350 |
|
425 |
|
351 |
$schema->storage->txn_begin; |
426 |
$schema->storage->txn_begin; |
352 |
my $librarian = $builder->build_object( |
427 |
my $librarian = $builder->build_object( |
Lines 426-430
subtest 'add checkout' => sub {
Link Here
|
426 |
)->status_is(201)->or(sub { diag $t->tx->res->body }); |
501 |
)->status_is(201)->or(sub { diag $t->tx->res->body }); |
427 |
%needsconfirmation = (); |
502 |
%needsconfirmation = (); |
428 |
|
503 |
|
|
|
504 |
subtest 'public add' => sub { |
505 |
plan tests => 14; |
506 |
|
507 |
my $useridp = $patron->userid; |
508 |
$patron->set_password( |
509 |
{ password => $password, skip_validation => 1 } ); |
510 |
|
511 |
# Feature disabled |
512 |
t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 0 ); |
513 |
|
514 |
$t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => |
515 |
{ item_id => $item1_id, patron_id => $patron_id } ) |
516 |
->status_is(401)->json_is( |
517 |
{ |
518 |
error => "Authentication failure." |
519 |
} |
520 |
); |
521 |
|
522 |
$t->post_ok( |
523 |
"//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" |
524 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
525 |
->status_is(405) |
526 |
->json_is( |
527 |
{ error => "Feature disabled", error_code => "FEATURE_DISABLED" } ); |
528 |
|
529 |
# Feature enabled |
530 |
t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 1 ); |
531 |
|
532 |
$t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => |
533 |
{ item_id => $item1_id, patron_id => $patron_id } ) |
534 |
->status_is(401)->json_is( |
535 |
{ |
536 |
error => "Authentication failure." |
537 |
} |
538 |
); |
539 |
|
540 |
$t->post_ok( |
541 |
"//$userid:$password@/api/v1/public/patrons/$patron_id/checkouts" |
542 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
543 |
->status_is(403)->json_is( |
544 |
{ |
545 |
error => |
546 |
"Authorization failure. Missing required permission(s).", |
547 |
required_permissions => undef |
548 |
} |
549 |
); |
550 |
|
551 |
$t->post_ok( |
552 |
"//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" |
553 |
=> json => { item_id => $item1_id, patron_id => $patron_id } ) |
554 |
->status_is(201); |
555 |
}; |
556 |
|
429 |
$schema->storage->txn_rollback; |
557 |
$schema->storage->txn_rollback; |
430 |
}; |
558 |
}; |
431 |
- |
|
|