|
Lines 125-140
subtest 'list() tests' => sub {
Link Here
|
| 125 |
|
125 |
|
| 126 |
$t->get_ok("//$userid:$password@/api/v1/patrons")->status_is( 200, 'list_borrowers makes /patrons accessible' ); |
126 |
$t->get_ok("//$userid:$password@/api/v1/patrons")->status_is( 200, 'list_borrowers makes /patrons accessible' ); |
| 127 |
|
127 |
|
| 128 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber ) |
128 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber )->status_is(200) |
| 129 |
->status_is(200) |
|
|
| 130 |
->json_is( '/0/cardnumber' => $librarian->cardnumber ); |
129 |
->json_is( '/0/cardnumber' => $librarian->cardnumber ); |
| 131 |
|
130 |
|
| 132 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?q={\"cardnumber\":\"" . $librarian->cardnumber . "\"}" ) |
131 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?q={\"cardnumber\":\"" . $librarian->cardnumber . "\"}" ) |
| 133 |
->status_is(200) |
132 |
->status_is(200)->json_is( '/0/cardnumber' => $librarian->cardnumber ); |
| 134 |
->json_is( '/0/cardnumber' => $librarian->cardnumber ); |
|
|
| 135 |
|
133 |
|
| 136 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?address2=" . $librarian->address2 ) |
134 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?address2=" . $librarian->address2 )->status_is(200) |
| 137 |
->status_is(200) |
|
|
| 138 |
->json_is( '/0/address2' => $librarian->address2 ); |
135 |
->json_is( '/0/address2' => $librarian->address2 ); |
| 139 |
|
136 |
|
| 140 |
subtest 'restricted & expired' => sub { |
137 |
subtest 'restricted & expired' => sub { |
|
Lines 148-166
subtest 'list() tests' => sub {
Link Here
|
| 148 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?restricted=" |
145 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?restricted=" |
| 149 |
. Mojo::JSON->true |
146 |
. Mojo::JSON->true |
| 150 |
. "&cardnumber=" |
147 |
. "&cardnumber=" |
| 151 |
. $patron->cardnumber ) |
148 |
. $patron->cardnumber )->status_is(200)->json_has('/0/restricted') |
| 152 |
->status_is(200) |
149 |
->json_is( '/0/restricted' => Mojo::JSON->true )->json_has('/0/expired') |
| 153 |
->json_has('/0/restricted') |
150 |
->json_is( '/0/expired' => Mojo::JSON->false )->json_hasnt('/1'); |
| 154 |
->json_is( '/0/restricted' => Mojo::JSON->true ) |
|
|
| 155 |
->json_has('/0/expired') |
| 156 |
->json_is( '/0/expired' => Mojo::JSON->false ) |
| 157 |
->json_hasnt('/1'); |
| 158 |
|
151 |
|
| 159 |
$patron->dateexpiry( dt_from_string->subtract( days => 2 ) )->store; |
152 |
$patron->dateexpiry( dt_from_string->subtract( days => 2 ) )->store; |
| 160 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
153 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber )->status_is(200) |
| 161 |
->status_is(200) |
154 |
->json_has('/expired')->json_is( '/expired' => Mojo::JSON->true ); |
| 162 |
->json_has('/expired') |
|
|
| 163 |
->json_is( '/expired' => Mojo::JSON->true ); |
| 164 |
|
155 |
|
| 165 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?" |
156 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?" |
| 166 |
. 'q={"extended_attributes.type":"CODE"}' => { 'x-koha-embed' => 'extended_attributes' } ) |
157 |
. 'q={"extended_attributes.type":"CODE"}' => { 'x-koha-embed' => 'extended_attributes' } ) |
|
Lines 189-203
subtest 'list() tests' => sub {
Link Here
|
| 189 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?date_of_birth=" |
180 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?date_of_birth=" |
| 190 |
. $date_of_birth |
181 |
. $date_of_birth |
| 191 |
. "&cardnumber=" |
182 |
. "&cardnumber=" |
| 192 |
. $patron->cardnumber ) |
183 |
. $patron->cardnumber )->status_is(200) |
| 193 |
->status_is(200) |
|
|
| 194 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date works' ); |
184 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date works' ); |
| 195 |
|
185 |
|
| 196 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?last_seen=" |
186 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?last_seen=" |
| 197 |
. $last_seen_rfc3339 |
187 |
. $last_seen_rfc3339 |
| 198 |
. "&cardnumber=" |
188 |
. "&cardnumber=" |
| 199 |
. $patron->cardnumber ) |
189 |
. $patron->cardnumber )->status_is(200) |
| 200 |
->status_is(200) |
|
|
| 201 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
190 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
| 202 |
|
191 |
|
| 203 |
my $q = encode_json( |
192 |
my $q = encode_json( |
|
Lines 207-214
subtest 'list() tests' => sub {
Link Here
|
| 207 |
} |
196 |
} |
| 208 |
); |
197 |
); |
| 209 |
|
198 |
|
| 210 |
$t->get_ok("//$userid:$password@/api/v1/patrons?q=$q") |
199 |
$t->get_ok("//$userid:$password@/api/v1/patrons?q=$q")->status_is(200) |
| 211 |
->status_is(200) |
|
|
| 212 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date works' ); |
200 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date works' ); |
| 213 |
|
201 |
|
| 214 |
$q = encode_json( |
202 |
$q = encode_json( |
|
Lines 218-225
subtest 'list() tests' => sub {
Link Here
|
| 218 |
} |
206 |
} |
| 219 |
); |
207 |
); |
| 220 |
|
208 |
|
| 221 |
$t->get_ok("//$userid:$password@/api/v1/patrons?q=$q") |
209 |
$t->get_ok("//$userid:$password@/api/v1/patrons?q=$q")->status_is(200) |
| 222 |
->status_is(200) |
|
|
| 223 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
210 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
| 224 |
}; |
211 |
}; |
| 225 |
|
212 |
|
|
Lines 263-282
subtest 'list() tests' => sub {
Link Here
|
| 263 |
my $userid = $librarian->userid; |
250 |
my $userid = $librarian->userid; |
| 264 |
|
251 |
|
| 265 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" |
252 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" |
| 266 |
. encode_json( { library_id => [ $library_1->id, $library_2->id ] } ) ) |
253 |
. encode_json( { library_id => [ $library_1->id, $library_2->id ] } ) )->status_is(200) |
| 267 |
->status_is(200) |
254 |
->json_is( '/0/patron_id' => $patron_1->id )->json_is( '/1/patron_id' => $patron_2->id ) |
| 268 |
->json_is( '/0/patron_id' => $patron_1->id ) |
|
|
| 269 |
->json_is( '/1/patron_id' => $patron_2->id ) |
| 270 |
->json_is( '/2/patron_id' => $patron_3->id ); |
255 |
->json_is( '/2/patron_id' => $patron_3->id ); |
| 271 |
|
256 |
|
| 272 |
@libraries_where_can_see_patrons = ( $library_2->id ); |
257 |
@libraries_where_can_see_patrons = ( $library_2->id ); |
| 273 |
|
258 |
|
| 274 |
my $res = |
259 |
my $res = |
| 275 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" |
260 |
$t->get_ok( "//$userid:$password@/api/v1/patrons?_order_by=patron_id&q=" |
| 276 |
. encode_json( { library_id => [ $library_1->id, $library_2->id ] } ) ) |
261 |
. encode_json( { library_id => [ $library_1->id, $library_2->id ] } ) )->status_is(200) |
| 277 |
->status_is(200) |
262 |
->json_is( '/0/patron_id' => $patron_3->id, 'Returns the only allowed patron' )->tx->res->json; |
| 278 |
->json_is( '/0/patron_id' => $patron_3->id, 'Returns the only allowed patron' ) |
|
|
| 279 |
->tx->res->json; |
| 280 |
|
263 |
|
| 281 |
is( scalar @{$res}, 1, 'Only one patron returned' ); |
264 |
is( scalar @{$res}, 1, 'Only one patron returned' ); |
| 282 |
|
265 |
|
|
Lines 339-348
subtest 'get() tests' => sub {
Link Here
|
| 339 |
|
322 |
|
| 340 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id ) |
323 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id ) |
| 341 |
->status_is( 200, 'list_borrowers permission makes patron visible' ) |
324 |
->status_is( 200, 'list_borrowers permission makes patron visible' ) |
| 342 |
->json_is( '/patron_id' => $patron->id ) |
325 |
->json_is( '/patron_id' => $patron->id )->json_is( '/category_id' => $patron->categorycode ) |
| 343 |
->json_is( '/category_id' => $patron->categorycode ) |
326 |
->json_is( '/surname' => $patron->surname )->json_is( '/patron_card_lost' => Mojo::JSON->false ); |
| 344 |
->json_is( '/surname' => $patron->surname ) |
|
|
| 345 |
->json_is( '/patron_card_lost' => Mojo::JSON->false ); |
| 346 |
|
327 |
|
| 347 |
$schema->storage->txn_rollback; |
328 |
$schema->storage->txn_rollback; |
| 348 |
}; |
329 |
}; |
|
Lines 384-405
subtest 'get() tests' => sub {
Link Here
|
| 384 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
365 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
| 385 |
my $userid = $librarian->userid; |
366 |
my $userid = $librarian->userid; |
| 386 |
|
367 |
|
| 387 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_1->id ) |
368 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_1->id )->status_is(200) |
| 388 |
->status_is(200) |
|
|
| 389 |
->json_is( '/patron_id' => $patron_1->id ); |
369 |
->json_is( '/patron_id' => $patron_1->id ); |
| 390 |
|
370 |
|
| 391 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->id ) |
371 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->id )->status_is(200) |
| 392 |
->status_is(200) |
|
|
| 393 |
->json_is( '/patron_id' => $patron_2->id ); |
372 |
->json_is( '/patron_id' => $patron_2->id ); |
| 394 |
|
373 |
|
| 395 |
@libraries_where_can_see_patrons = ( $library_1->id ); |
374 |
@libraries_where_can_see_patrons = ( $library_1->id ); |
| 396 |
|
375 |
|
| 397 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_1->id ) |
376 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_1->id )->status_is(200) |
| 398 |
->status_is(200) |
|
|
| 399 |
->json_is( '/patron_id' => $patron_1->id ); |
377 |
->json_is( '/patron_id' => $patron_1->id ); |
| 400 |
|
378 |
|
| 401 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->id ) |
379 |
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->id )->status_is(404) |
| 402 |
->status_is(404) |
|
|
| 403 |
->json_is( '/error' => 'Patron not found' ); |
380 |
->json_is( '/error' => 'Patron not found' ); |
| 404 |
|
381 |
|
| 405 |
$schema->storage->txn_rollback; |
382 |
$schema->storage->txn_rollback; |
|
Lines 481-494
subtest 'add() tests' => sub {
Link Here
|
| 481 |
delete $newpatron->{restricted}; |
458 |
delete $newpatron->{restricted}; |
| 482 |
delete $newpatron->{expired}; |
459 |
delete $newpatron->{expired}; |
| 483 |
delete $newpatron->{anonymized}; |
460 |
delete $newpatron->{anonymized}; |
|
|
461 |
delete $newpatron->{self_renewal_available}; |
| 484 |
|
462 |
|
| 485 |
my $password = 'thePassword123'; |
463 |
my $password = 'thePassword123'; |
| 486 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
464 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
| 487 |
my $userid = $librarian->userid; |
465 |
my $userid = $librarian->userid; |
| 488 |
t::lib::Mocks::mock_preference( 'PatronDuplicateMatchingAddFields', 'firstname|surname|dateofbirth' ); |
466 |
t::lib::Mocks::mock_preference( 'PatronDuplicateMatchingAddFields', 'firstname|surname|dateofbirth' ); |
| 489 |
|
467 |
|
| 490 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => json => $newpatron ) |
468 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => json => $newpatron )->status_is(409) |
| 491 |
->status_is(409) |
|
|
| 492 |
->json_is( '/error' => "A patron record matching these details already exists" ); |
469 |
->json_is( '/error' => "A patron record matching these details already exists" ); |
| 493 |
|
470 |
|
| 494 |
# Create a library just to make sure its ID doesn't exist on the DB |
471 |
# Create a library just to make sure its ID doesn't exist on the DB |
|
Lines 502-509
subtest 'add() tests' => sub {
Link Here
|
| 502 |
|
479 |
|
| 503 |
# Test duplicate userid constraint |
480 |
# Test duplicate userid constraint |
| 504 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
481 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
| 505 |
->status_is(400) |
482 |
->status_is(400)->json_is( '/error' => "Problem with " . $newpatron->{userid} ); |
| 506 |
->json_is( '/error' => "Problem with " . $newpatron->{userid} ); |
|
|
| 507 |
|
483 |
|
| 508 |
$newpatron->{library_id} = $patron->branchcode; |
484 |
$newpatron->{library_id} = $patron->branchcode; |
| 509 |
|
485 |
|
|
Lines 512-519
subtest 'add() tests' => sub {
Link Here
|
| 512 |
warning_like { |
488 |
warning_like { |
| 513 |
$t->post_ok( |
489 |
$t->post_ok( |
| 514 |
"//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
490 |
"//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
| 515 |
->status_is(409) |
491 |
->status_is(409)->json_has( '/error', 'Fails when trying to POST duplicate cardnumber' ) |
| 516 |
->json_has( '/error', 'Fails when trying to POST duplicate cardnumber' ) |
|
|
| 517 |
->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); |
492 |
->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); |
| 518 |
} |
493 |
} |
| 519 |
qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; |
494 |
qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; |
|
Lines 528-535
subtest 'add() tests' => sub {
Link Here
|
| 528 |
$newpatron->{category_id} = $deleted_category_id; # Test invalid patron category |
503 |
$newpatron->{category_id} = $deleted_category_id; # Test invalid patron category |
| 529 |
|
504 |
|
| 530 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
505 |
$t->post_ok( "//$userid:$password@/api/v1/patrons" => { 'x-confirm-not-duplicate' => 1 } => json => $newpatron ) |
| 531 |
->status_is(400) |
506 |
->status_is(400)->json_is( '/error' => "Given category_id does not exist" ); |
| 532 |
->json_is( '/error' => "Given category_id does not exist" ); |
|
|
| 533 |
$newpatron->{category_id} = $patron->categorycode; |
507 |
$newpatron->{category_id} = $patron->categorycode; |
| 534 |
|
508 |
|
| 535 |
$newpatron->{falseproperty} = "Non existent property"; |
509 |
$newpatron->{falseproperty} = "Non existent property"; |
|
Lines 546-551
subtest 'add() tests' => sub {
Link Here
|
| 546 |
delete $newpatron->{restricted}; |
520 |
delete $newpatron->{restricted}; |
| 547 |
delete $newpatron->{expired}; |
521 |
delete $newpatron->{expired}; |
| 548 |
delete $newpatron->{anonymized}; |
522 |
delete $newpatron->{anonymized}; |
|
|
523 |
delete $newpatron->{self_renewal_available}; |
| 549 |
$patron_to_delete->delete; |
524 |
$patron_to_delete->delete; |
| 550 |
|
525 |
|
| 551 |
# Set a date field |
526 |
# Set a date field |
|
Lines 559-573
subtest 'add() tests' => sub {
Link Here
|
| 559 |
$letter_enqueued = 0; |
534 |
$letter_enqueued = 0; |
| 560 |
$t->post_ok( |
535 |
$t->post_ok( |
| 561 |
"//$userid:$password@/api/v1/patrons" => { 'x-koha-override' => 'welcome_yes' } => json => $newpatron ) |
536 |
"//$userid:$password@/api/v1/patrons" => { 'x-koha-override' => 'welcome_yes' } => json => $newpatron ) |
| 562 |
->status_is( 201, 'Patron created successfully' ) |
537 |
->status_is( 201, 'Patron created successfully' )->header_like( |
| 563 |
->header_like( |
|
|
| 564 |
Location => qr|^\/api\/v1\/patrons/\d*|, |
538 |
Location => qr|^\/api\/v1\/patrons/\d*|, |
| 565 |
'REST3.4.1' |
539 |
'REST3.4.1' |
| 566 |
) |
540 |
)->json_has( '/patron_id', 'got a patron_id' )->json_is( '/cardnumber' => $newpatron->{cardnumber} ) |
| 567 |
->json_has( '/patron_id', 'got a patron_id' ) |
541 |
->json_is( '/surname' => $newpatron->{surname} )->json_is( '/firstname' => $newpatron->{firstname} ) |
| 568 |
->json_is( '/cardnumber' => $newpatron->{cardnumber} ) |
|
|
| 569 |
->json_is( '/surname' => $newpatron->{surname} ) |
| 570 |
->json_is( '/firstname' => $newpatron->{firstname} ) |
| 571 |
->json_is( '/date_of_birth' => $newpatron->{date_of_birth}, 'Date field set (Bug 28585)' ) |
542 |
->json_is( '/date_of_birth' => $newpatron->{date_of_birth}, 'Date field set (Bug 28585)' ) |
| 572 |
->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); |
543 |
->json_is( '/last_seen' => $newpatron->{last_seen}, 'Date-time field set (Bug 28585)' ); |
| 573 |
|
544 |
|
|
Lines 694-701
subtest 'add() tests' => sub {
Link Here
|
| 694 |
"city" => "Konstanz", |
665 |
"city" => "Konstanz", |
| 695 |
"library_id" => "MPL" |
666 |
"library_id" => "MPL" |
| 696 |
} |
667 |
} |
| 697 |
) |
668 |
)->status_is(400) |
| 698 |
->status_is(400) |
|
|
| 699 |
->json_is( '/error' => "Tried to add more than one non-repeatable attributes. type=$code value=$attr" ); |
669 |
->json_is( '/error' => "Tried to add more than one non-repeatable attributes. type=$code value=$attr" ); |
| 700 |
|
670 |
|
| 701 |
is( Koha::Patrons->search->count, $patrons_count, 'No patron added' ); |
671 |
is( Koha::Patrons->search->count, $patrons_count, 'No patron added' ); |
|
Lines 710-717
subtest 'add() tests' => sub {
Link Here
|
| 710 |
"city" => "Konstanz", |
680 |
"city" => "Konstanz", |
| 711 |
"library_id" => "MPL" |
681 |
"library_id" => "MPL" |
| 712 |
} |
682 |
} |
| 713 |
) |
683 |
)->status_is(400) |
| 714 |
->status_is(400) |
|
|
| 715 |
->json_is( |
684 |
->json_is( |
| 716 |
'/error' => "Your action breaks a unique constraint on the attribute. type=$code value=$attr" ); |
685 |
'/error' => "Your action breaks a unique constraint on the attribute. type=$code value=$attr" ); |
| 717 |
|
686 |
|
|
Lines 872-879
subtest 'add() tests' => sub {
Link Here
|
| 872 |
"city" => "Bigtown", |
841 |
"city" => "Bigtown", |
| 873 |
"library_id" => "MPL", |
842 |
"library_id" => "MPL", |
| 874 |
} |
843 |
} |
| 875 |
) |
844 |
)->status_is( 201, 'Patron added with EnhancedMessagingPreferences disabled' ) |
| 876 |
->status_is( 201, 'Patron added with EnhancedMessagingPreferences disabled' ) |
|
|
| 877 |
->tx->res->json->{patron_id}; |
845 |
->tx->res->json->{patron_id}; |
| 878 |
|
846 |
|
| 879 |
# No messaging preferences should be set |
847 |
# No messaging preferences should be set |
|
Lines 931-939
subtest 'update() tests' => sub {
Link Here
|
| 931 |
delete $newpatron->{restricted}; |
899 |
delete $newpatron->{restricted}; |
| 932 |
delete $newpatron->{expired}; |
900 |
delete $newpatron->{expired}; |
| 933 |
delete $newpatron->{anonymized}; |
901 |
delete $newpatron->{anonymized}; |
|
|
902 |
delete $newpatron->{self_renewal_available}; |
| 934 |
|
903 |
|
| 935 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/-1" => json => $newpatron ) |
904 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/-1" => json => $newpatron )->status_is(404) |
| 936 |
->status_is(404) |
|
|
| 937 |
->json_has( '/error', 'Fails when trying to PUT nonexistent patron' ); |
905 |
->json_has( '/error', 'Fails when trying to PUT nonexistent patron' ); |
| 938 |
|
906 |
|
| 939 |
# Create a library just to make sure its ID doesn't exist on the DB |
907 |
# Create a library just to make sure its ID doesn't exist on the DB |
|
Lines 947-954
subtest 'update() tests' => sub {
Link Here
|
| 947 |
$newpatron->{category_id} = $deleted_category_id; |
915 |
$newpatron->{category_id} = $deleted_category_id; |
| 948 |
|
916 |
|
| 949 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
917 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 950 |
->status_is(400) |
918 |
->status_is(400)->json_is( '/error' => "Given category_id does not exist" ); |
| 951 |
->json_is( '/error' => "Given category_id does not exist" ); |
|
|
| 952 |
|
919 |
|
| 953 |
# Restore the valid category |
920 |
# Restore the valid category |
| 954 |
$newpatron->{category_id} = $patron_2->categorycode; |
921 |
$newpatron->{category_id} = $patron_2->categorycode; |
|
Lines 965-972
subtest 'update() tests' => sub {
Link Here
|
| 965 |
|
932 |
|
| 966 |
warning_like { |
933 |
warning_like { |
| 967 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
934 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 968 |
->status_is(400) |
935 |
->status_is(400)->json_is( '/error' => "Given library_id does not exist" ); |
| 969 |
->json_is( '/error' => "Given library_id does not exist" ); |
|
|
| 970 |
} |
936 |
} |
| 971 |
qr/DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/; |
937 |
qr/DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails/; |
| 972 |
|
938 |
|
|
Lines 977-984
subtest 'update() tests' => sub {
Link Here
|
| 977 |
$newpatron->{falseproperty} = "Non existent property"; |
943 |
$newpatron->{falseproperty} = "Non existent property"; |
| 978 |
|
944 |
|
| 979 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
945 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 980 |
->status_is(400) |
946 |
->status_is(400)->json_is( '/errors/0/message' => 'Properties not allowed: falseproperty.' ); |
| 981 |
->json_is( '/errors/0/message' => 'Properties not allowed: falseproperty.' ); |
|
|
| 982 |
|
947 |
|
| 983 |
# Get rid of the invalid attribute |
948 |
# Get rid of the invalid attribute |
| 984 |
delete $newpatron->{falseproperty}; |
949 |
delete $newpatron->{falseproperty}; |
|
Lines 988-995
subtest 'update() tests' => sub {
Link Here
|
| 988 |
$newpatron->{userid} = $patron_1->userid; |
953 |
$newpatron->{userid} = $patron_1->userid; |
| 989 |
|
954 |
|
| 990 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
955 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 991 |
->status_is(400) |
956 |
->status_is(400)->json_has( '/error', "Problem with userid " . $patron_1->userid ); |
| 992 |
->json_has( '/error', "Problem with userid " . $patron_1->userid ); |
|
|
| 993 |
|
957 |
|
| 994 |
$newpatron->{cardnumber} = $patron_1->id . $patron_2->id; |
958 |
$newpatron->{cardnumber} = $patron_1->id . $patron_2->id; |
| 995 |
$newpatron->{userid} = "user" . $patron_1->id . $patron_2->id; |
959 |
$newpatron->{userid} = "user" . $patron_1->id . $patron_2->id; |
|
Lines 1011-1016
subtest 'update() tests' => sub {
Link Here
|
| 1011 |
$newpatron->{restricted} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{restricted}; |
975 |
$newpatron->{restricted} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{restricted}; |
| 1012 |
$newpatron->{expired} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{expired}; |
976 |
$newpatron->{expired} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{expired}; |
| 1013 |
$newpatron->{anonymized} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{anonymized}; |
977 |
$newpatron->{anonymized} = $unauthorized_patron->to_api( { user => $authorized_patron } )->{anonymized}; |
|
|
978 |
$newpatron->{self_renewal_available} = |
| 979 |
$unauthorized_patron->to_api( { user => $authorized_patron } )->{self_renewal_available}; |
| 1014 |
|
980 |
|
| 1015 |
my $got = $result->tx->res->json; |
981 |
my $got = $result->tx->res->json; |
| 1016 |
my $updated_on_got = delete $got->{updated_on}; |
982 |
my $updated_on_got = delete $got->{updated_on}; |
|
Lines 1046-1051
subtest 'update() tests' => sub {
Link Here
|
| 1046 |
delete $newpatron->{restricted}; |
1012 |
delete $newpatron->{restricted}; |
| 1047 |
delete $newpatron->{expired}; |
1013 |
delete $newpatron->{expired}; |
| 1048 |
delete $newpatron->{anonymized}; |
1014 |
delete $newpatron->{anonymized}; |
|
|
1015 |
delete $newpatron->{self_renewal_available}; |
| 1049 |
|
1016 |
|
| 1050 |
# attempt to update |
1017 |
# attempt to update |
| 1051 |
$authorized_patron->flags( 2**4 )->store; # borrowers flag = 4 |
1018 |
$authorized_patron->flags( 2**4 )->store; # borrowers flag = 4 |
|
Lines 1073-1079
subtest 'update() tests' => sub {
Link Here
|
| 1073 |
->status_is( |
1040 |
->status_is( |
| 1074 |
403, |
1041 |
403, |
| 1075 |
"Non-superlibrarian user change of superlibrarian secondary_email to undefined forbidden" |
1042 |
"Non-superlibrarian user change of superlibrarian secondary_email to undefined forbidden" |
| 1076 |
)->json_is( { error => "Not enough privileges to change a superlibrarian's email" } ); |
1043 |
)->json_is( { error => "Not enough privileges to change a superlibrarian's email" } ); |
| 1077 |
|
1044 |
|
| 1078 |
$newpatron->{secondary_email} = $superlibrarian->emailpro; |
1045 |
$newpatron->{secondary_email} = $superlibrarian->emailpro; |
| 1079 |
$newpatron->{altaddress_email} = 'nonsense@no.no'; |
1046 |
$newpatron->{altaddress_email} = 'nonsense@no.no'; |
|
Lines 1089-1095
subtest 'update() tests' => sub {
Link Here
|
| 1089 |
->status_is( |
1056 |
->status_is( |
| 1090 |
403, |
1057 |
403, |
| 1091 |
"Non-superlibrarian user change of superlibrarian altaddress_email to undefined forbidden" |
1058 |
"Non-superlibrarian user change of superlibrarian altaddress_email to undefined forbidden" |
| 1092 |
)->json_is( { error => "Not enough privileges to change a superlibrarian's email" } ); |
1059 |
)->json_is( { error => "Not enough privileges to change a superlibrarian's email" } ); |
| 1093 |
|
1060 |
|
| 1094 |
# update patron without sending email |
1061 |
# update patron without sending email |
| 1095 |
delete $newpatron->{email}; |
1062 |
delete $newpatron->{email}; |
|
Lines 1160-1174
subtest 'update() tests' => sub {
Link Here
|
| 1160 |
"city" => "Konstanz", |
1127 |
"city" => "Konstanz", |
| 1161 |
"library_id" => "MPL" |
1128 |
"library_id" => "MPL" |
| 1162 |
} |
1129 |
} |
| 1163 |
) |
1130 |
)->status_is(400) |
| 1164 |
->status_is(400) |
|
|
| 1165 |
->json_is( |
1131 |
->json_is( |
| 1166 |
'/error' => "Missing mandatory extended attribute (type=" . $attr_type_mandatory->code . ")" ); |
1132 |
'/error' => "Missing mandatory extended attribute (type=" . $attr_type_mandatory->code . ")" ); |
| 1167 |
|
1133 |
|
| 1168 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
1134 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
| 1169 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
1135 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
| 1170 |
$newpatron ) |
1136 |
$newpatron )->status_is(400) |
| 1171 |
->status_is(400) |
|
|
| 1172 |
->json_is( '/error' => 'Tried to use an invalid attribute type. type=' . $deleted_attr_code ) |
1137 |
->json_is( '/error' => 'Tried to use an invalid attribute type. type=' . $deleted_attr_code ) |
| 1173 |
->json_is( '/error_code' => 'invalid_attribute_type' ); |
1138 |
->json_is( '/error_code' => 'invalid_attribute_type' ); |
| 1174 |
|
1139 |
|
|
Lines 1185-1197
subtest 'update() tests' => sub {
Link Here
|
| 1185 |
|
1150 |
|
| 1186 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
1151 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
| 1187 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
1152 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
| 1188 |
$newpatron ) |
1153 |
$newpatron )->status_is(400) |
| 1189 |
->status_is(400) |
|
|
| 1190 |
->json_is( '/error' => 'Your action breaks a unique constraint on the attribute. type=' |
1154 |
->json_is( '/error' => 'Your action breaks a unique constraint on the attribute. type=' |
| 1191 |
. $attr_type_unique->code |
1155 |
. $attr_type_unique->code |
| 1192 |
. ' value=' |
1156 |
. ' value=' |
| 1193 |
. $unique_attr->attribute ) |
1157 |
. $unique_attr->attribute )->json_is( '/error_code' => 'attribute_not_unique' ); |
| 1194 |
->json_is( '/error_code' => 'attribute_not_unique' ); |
|
|
| 1195 |
|
1158 |
|
| 1196 |
$newpatron->{extended_attributes} = [ |
1159 |
$newpatron->{extended_attributes} = [ |
| 1197 |
{ type => $attr_type_repeatable->code, value => 'a' }, |
1160 |
{ type => $attr_type_repeatable->code, value => 'a' }, |
|
Lines 1202-1214
subtest 'update() tests' => sub {
Link Here
|
| 1202 |
|
1165 |
|
| 1203 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
1166 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
| 1204 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
1167 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
| 1205 |
$newpatron ) |
1168 |
$newpatron )->status_is(400) |
| 1206 |
->status_is(400) |
|
|
| 1207 |
->json_is( '/error' => 'Your action breaks a unique constraint on the attribute. type=' |
1169 |
->json_is( '/error' => 'Your action breaks a unique constraint on the attribute. type=' |
| 1208 |
. $attr_type_unique->code |
1170 |
. $attr_type_unique->code |
| 1209 |
. ' value=' |
1171 |
. ' value=' |
| 1210 |
. $unique_attr->attribute ) |
1172 |
. $unique_attr->attribute )->json_is( '/error_code' => 'attribute_not_unique' ); |
| 1211 |
->json_is( '/error_code' => 'attribute_not_unique' ); |
|
|
| 1212 |
|
1173 |
|
| 1213 |
$newpatron->{extended_attributes} = [ |
1174 |
$newpatron->{extended_attributes} = [ |
| 1214 |
{ type => $attr_type_repeatable->code, value => 'a' }, |
1175 |
{ type => $attr_type_repeatable->code, value => 'a' }, |
|
Lines 1218-1229
subtest 'update() tests' => sub {
Link Here
|
| 1218 |
|
1179 |
|
| 1219 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
1180 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" |
| 1220 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
1181 |
. $superlibrarian->borrowernumber => { 'x-koha-embed' => 'extended_attributes' } => json => |
| 1221 |
$newpatron ) |
1182 |
$newpatron )->status_is(400) |
| 1222 |
->status_is(400) |
|
|
| 1223 |
->json_is( '/error' => 'Tried to add more than one non-repeatable attributes. type=' |
1183 |
->json_is( '/error' => 'Tried to add more than one non-repeatable attributes. type=' |
| 1224 |
. $attr_type_mandatory->code |
1184 |
. $attr_type_mandatory->code |
| 1225 |
. ' value=pong' ) |
1185 |
. ' value=pong' )->json_is( '/error_code' => 'non_repeatable_attribute' ); |
| 1226 |
->json_is( '/error_code' => 'non_repeatable_attribute' ); |
|
|
| 1227 |
|
1186 |
|
| 1228 |
my $unique_value = $unique_attr->attribute; |
1187 |
my $unique_value = $unique_attr->attribute; |
| 1229 |
$unique_attr->delete; |
1188 |
$unique_attr->delete; |
|
Lines 1282-1289
subtest 'delete() tests' => sub {
Link Here
|
| 1282 |
|
1241 |
|
| 1283 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->borrowernumber ); |
1242 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->borrowernumber ); |
| 1284 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1243 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1285 |
->status_is( 409, 'Anonymous patron cannot be deleted' ) |
1244 |
->status_is( 409, 'Anonymous patron cannot be deleted' )->json_is( |
| 1286 |
->json_is( |
|
|
| 1287 |
{ |
1245 |
{ |
| 1288 |
error => 'Anonymous patron cannot be deleted', |
1246 |
error => 'Anonymous patron cannot be deleted', |
| 1289 |
error_code => 'is_anonymous_patron' |
1247 |
error_code => 'is_anonymous_patron' |
|
Lines 1305-1312
subtest 'delete() tests' => sub {
Link Here
|
| 1305 |
$guarantee->add_guarantor( { guarantor_id => $patron->id, relationship => 'parent' } ); |
1263 |
$guarantee->add_guarantor( { guarantor_id => $patron->id, relationship => 'parent' } ); |
| 1306 |
|
1264 |
|
| 1307 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1265 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1308 |
->status_is( 409, 'Patron with checkouts cannot be deleted' ) |
1266 |
->status_is( 409, 'Patron with checkouts cannot be deleted' )->json_is( |
| 1309 |
->json_is( |
|
|
| 1310 |
{ |
1267 |
{ |
| 1311 |
error => 'Pending checkouts prevent deletion', |
1268 |
error => 'Pending checkouts prevent deletion', |
| 1312 |
error_code => 'has_checkouts' |
1269 |
error_code => 'has_checkouts' |
|
Lines 1317-1324
subtest 'delete() tests' => sub {
Link Here
|
| 1317 |
$checkout->delete; |
1274 |
$checkout->delete; |
| 1318 |
|
1275 |
|
| 1319 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1276 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1320 |
->status_is( 409, 'Patron with debt cannot be deleted' ) |
1277 |
->status_is( 409, 'Patron with debt cannot be deleted' )->json_is( |
| 1321 |
->json_is( |
|
|
| 1322 |
{ |
1278 |
{ |
| 1323 |
error => 'Pending debts prevent deletion', |
1279 |
error => 'Pending debts prevent deletion', |
| 1324 |
error_code => 'has_debt' |
1280 |
error_code => 'has_debt' |
|
Lines 1329-1336
subtest 'delete() tests' => sub {
Link Here
|
| 1329 |
$patron->account->pay( { amount => 10, debits => [$debit] } ); |
1285 |
$patron->account->pay( { amount => 10, debits => [$debit] } ); |
| 1330 |
|
1286 |
|
| 1331 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1287 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1332 |
->status_is( 409, 'Patron with guarantees cannot be deleted' ) |
1288 |
->status_is( 409, 'Patron with guarantees cannot be deleted' )->json_is( |
| 1333 |
->json_is( |
|
|
| 1334 |
{ |
1289 |
{ |
| 1335 |
error => 'Patron is a guarantor and it prevents deletion', |
1290 |
error => 'Patron is a guarantor and it prevents deletion', |
| 1336 |
error_code => 'has_guarantees' |
1291 |
error_code => 'has_guarantees' |
|
Lines 1343-1350
subtest 'delete() tests' => sub {
Link Here
|
| 1343 |
$patron->protected(1)->store(); |
1298 |
$patron->protected(1)->store(); |
| 1344 |
|
1299 |
|
| 1345 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1300 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1346 |
->status_is( 409, 'Protected patron cannot be deleted' ) |
1301 |
->status_is( 409, 'Protected patron cannot be deleted' )->json_is( |
| 1347 |
->json_is( |
|
|
| 1348 |
{ |
1302 |
{ |
| 1349 |
error => 'Protected patrons cannot be deleted', |
1303 |
error => 'Protected patrons cannot be deleted', |
| 1350 |
error_code => 'is_protected' |
1304 |
error_code => 'is_protected' |
|
Lines 1354-1361
subtest 'delete() tests' => sub {
Link Here
|
| 1354 |
$patron->protected(0)->store(); |
1308 |
$patron->protected(0)->store(); |
| 1355 |
|
1309 |
|
| 1356 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
1310 |
$t->delete_ok( "//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber ) |
| 1357 |
->status_is( 204, 'REST3.2.4' ) |
1311 |
->status_is( 204, 'REST3.2.4' )->content_is( '', 'REST3.3.4' ); |
| 1358 |
->content_is( '', 'REST3.3.4' ); |
|
|
| 1359 |
|
1312 |
|
| 1360 |
my $deleted_patrons = Koha::Old::Patrons->search( { borrowernumber => $patron->borrowernumber } ); |
1313 |
my $deleted_patrons = Koha::Old::Patrons->search( { borrowernumber => $patron->borrowernumber } ); |
| 1361 |
is( $deleted_patrons->count, 1, 'The patron has been moved to the vault' ); |
1314 |
is( $deleted_patrons->count, 1, 'The patron has been moved to the vault' ); |
|
Lines 1387-1399
subtest 'guarantors_can_see_charges() tests' => sub {
Link Here
|
| 1387 |
)->status_is(401)->json_is( { error => "Authentication failure." } ); |
1340 |
)->status_is(401)->json_is( { error => "Authentication failure." } ); |
| 1388 |
|
1341 |
|
| 1389 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_charges" => json => |
1342 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_charges" => json => |
| 1390 |
{ allowed => Mojo::JSON->true } ) |
1343 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
| 1391 |
->status_is(403) |
|
|
| 1392 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
1344 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
| 1393 |
|
1345 |
|
| 1394 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_charges" => json => |
1346 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_charges" => json => |
| 1395 |
{ allowed => Mojo::JSON->true } ) |
1347 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
| 1396 |
->status_is(403) |
|
|
| 1397 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
1348 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
| 1398 |
|
1349 |
|
| 1399 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetFinesVisibilityForGuarantor', 1 ); |
1350 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetFinesVisibilityForGuarantor', 1 ); |
|
Lines 1431-1445
subtest 'guarantors_can_see_checkouts() tests' => sub {
Link Here
|
| 1431 |
{ allowed => Mojo::JSON->true } )->status_is(401)->json_is( { error => "Authentication failure." } ); |
1382 |
{ allowed => Mojo::JSON->true } )->status_is(401)->json_is( { error => "Authentication failure." } ); |
| 1432 |
|
1383 |
|
| 1433 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_checkouts" => json => |
1384 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_checkouts" => json => |
| 1434 |
{ allowed => Mojo::JSON->true } ) |
1385 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
| 1435 |
->status_is(403) |
|
|
| 1436 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
1386 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
| 1437 |
|
1387 |
|
| 1438 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 0 ); |
1388 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 0 ); |
| 1439 |
|
1389 |
|
| 1440 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_checkouts" => json => |
1390 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_checkouts" => json => |
| 1441 |
{ allowed => Mojo::JSON->true } ) |
1391 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
| 1442 |
->status_is(403) |
|
|
| 1443 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
1392 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
| 1444 |
|
1393 |
|
| 1445 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 1 ); |
1394 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 1 ); |
|
Lines 1482-1489
sub unauthorized_access_tests {
Link Here
|
| 1482 |
$unauthorized_patron->set_password( { password => $password, skip_validation => 1 } ); |
1431 |
$unauthorized_patron->set_password( { password => $password, skip_validation => 1 } ); |
| 1483 |
my $unauth_userid = $unauthorized_patron->userid; |
1432 |
my $unauth_userid = $unauthorized_patron->userid; |
| 1484 |
|
1433 |
|
| 1485 |
$t->$verb_ok( "//$unauth_userid:$password\@$endpoint" => json => $json ) |
1434 |
$t->$verb_ok( "//$unauth_userid:$password\@$endpoint" => json => $json )->status_is(403) |
| 1486 |
->status_is(403) |
|
|
| 1487 |
->json_has('/required_permissions'); |
1435 |
->json_has('/required_permissions'); |
| 1488 |
}; |
1436 |
}; |
| 1489 |
} |
1437 |
} |