Lines 322-328
subtest 'add() tests' => sub {
Link Here
|
322 |
|
322 |
|
323 |
$schema->storage->txn_begin; |
323 |
$schema->storage->txn_begin; |
324 |
|
324 |
|
325 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } )->to_api; |
325 |
my $librarian = $builder->build_object( |
|
|
326 |
{ |
327 |
class => 'Koha::Patrons', |
328 |
value => { flags => 2**4 } # borrowers flag = 4 |
329 |
} |
330 |
); |
331 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } )->to_api({ user => $librarian }); |
326 |
|
332 |
|
327 |
unauthorized_access_tests('POST', undef, $patron); |
333 |
unauthorized_access_tests('POST', undef, $patron); |
328 |
|
334 |
|
Lines 344-351
subtest 'add() tests' => sub {
Link Here
|
344 |
# Mock early, so existing mandatory attributes don't break all the tests |
350 |
# Mock early, so existing mandatory attributes don't break all the tests |
345 |
my $mocked_patron = Test::MockModule->new('Koha::Patron'); |
351 |
my $mocked_patron = Test::MockModule->new('Koha::Patron'); |
346 |
|
352 |
|
347 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
353 |
my $librarian = $builder->build_object( |
348 |
my $newpatron = $patron->to_api; |
354 |
{ |
|
|
355 |
class => 'Koha::Patrons', |
356 |
value => { flags => 2**4 } # borrowers flag = 4 |
357 |
} |
358 |
); |
359 |
|
360 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
361 |
my $newpatron = $patron->to_api({ user => $librarian }); |
349 |
# delete RO attributes |
362 |
# delete RO attributes |
350 |
delete $newpatron->{patron_id}; |
363 |
delete $newpatron->{patron_id}; |
351 |
delete $newpatron->{restricted}; |
364 |
delete $newpatron->{restricted}; |
Lines 357-368
subtest 'add() tests' => sub {
Link Here
|
357 |
# Delete library |
370 |
# Delete library |
358 |
$library_to_delete->delete; |
371 |
$library_to_delete->delete; |
359 |
|
372 |
|
360 |
my $librarian = $builder->build_object( |
|
|
361 |
{ |
362 |
class => 'Koha::Patrons', |
363 |
value => { flags => 2**4 } # borrowers flag = 4 |
364 |
} |
365 |
); |
366 |
my $password = 'thePassword123'; |
373 |
my $password = 'thePassword123'; |
367 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
374 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
368 |
my $userid = $librarian->userid; |
375 |
my $userid = $librarian->userid; |
Lines 396-402
subtest 'add() tests' => sub {
Link Here
|
396 |
delete $newpatron->{falseproperty}; |
403 |
delete $newpatron->{falseproperty}; |
397 |
|
404 |
|
398 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
405 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
399 |
$newpatron = $patron_to_delete->to_api; |
406 |
$newpatron = $patron_to_delete->to_api({ user => $librarian }); |
400 |
# delete RO attributes |
407 |
# delete RO attributes |
401 |
delete $newpatron->{patron_id}; |
408 |
delete $newpatron->{patron_id}; |
402 |
delete $newpatron->{restricted}; |
409 |
delete $newpatron->{restricted}; |
Lines 646-652
subtest 'update() tests' => sub {
Link Here
|
646 |
|
653 |
|
647 |
my $patron_1 = $authorized_patron; |
654 |
my $patron_1 = $authorized_patron; |
648 |
my $patron_2 = $unauthorized_patron; |
655 |
my $patron_2 = $unauthorized_patron; |
649 |
my $newpatron = $unauthorized_patron->to_api; |
656 |
my $newpatron = $unauthorized_patron->to_api({ user => $authorized_patron }); |
650 |
# delete RO attributes |
657 |
# delete RO attributes |
651 |
delete $newpatron->{patron_id}; |
658 |
delete $newpatron->{patron_id}; |
652 |
delete $newpatron->{restricted}; |
659 |
delete $newpatron->{restricted}; |
Lines 723-731
subtest 'update() tests' => sub {
Link Here
|
723 |
->status_is(200, 'Patron updated successfully'); |
730 |
->status_is(200, 'Patron updated successfully'); |
724 |
|
731 |
|
725 |
# Put back the RO attributes |
732 |
# Put back the RO attributes |
726 |
$newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; |
733 |
$newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id}; |
727 |
$newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; |
734 |
$newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted}; |
728 |
$newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; |
735 |
$newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized}; |
729 |
|
736 |
|
730 |
my $got = $result->tx->res->json; |
737 |
my $got = $result->tx->res->json; |
731 |
my $updated_on_got = delete $got->{updated_on}; |
738 |
my $updated_on_got = delete $got->{updated_on}; |
732 |
- |
|
|