Lines 295-301
subtest 'add() tests' => sub {
Link Here
|
295 |
|
295 |
|
296 |
$schema->storage->txn_begin; |
296 |
$schema->storage->txn_begin; |
297 |
|
297 |
|
298 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } )->to_api; |
298 |
my $librarian = $builder->build_object( |
|
|
299 |
{ |
300 |
class => 'Koha::Patrons', |
301 |
value => { flags => 2**4 } # borrowers flag = 4 |
302 |
} |
303 |
); |
304 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } )->to_api({ user => $librarian }); |
299 |
|
305 |
|
300 |
unauthorized_access_tests('POST', undef, $patron); |
306 |
unauthorized_access_tests('POST', undef, $patron); |
301 |
|
307 |
|
Lines 339-346
subtest 'add() tests' => sub {
Link Here
|
339 |
} |
345 |
} |
340 |
); |
346 |
); |
341 |
|
347 |
|
342 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
348 |
my $librarian = $builder->build_object( |
343 |
my $newpatron = $patron->to_api; |
349 |
{ |
|
|
350 |
class => 'Koha::Patrons', |
351 |
value => { flags => 2**4 } # borrowers flag = 4 |
352 |
} |
353 |
); |
354 |
|
355 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
356 |
my $newpatron = $patron->to_api({ user => $librarian }); |
344 |
# delete RO attributes |
357 |
# delete RO attributes |
345 |
delete $newpatron->{patron_id}; |
358 |
delete $newpatron->{patron_id}; |
346 |
delete $newpatron->{restricted}; |
359 |
delete $newpatron->{restricted}; |
Lines 352-363
subtest 'add() tests' => sub {
Link Here
|
352 |
# Delete library |
365 |
# Delete library |
353 |
$library_to_delete->delete; |
366 |
$library_to_delete->delete; |
354 |
|
367 |
|
355 |
my $librarian = $builder->build_object( |
|
|
356 |
{ |
357 |
class => 'Koha::Patrons', |
358 |
value => { flags => 2**4 } # borrowers flag = 4 |
359 |
} |
360 |
); |
361 |
my $password = 'thePassword123'; |
368 |
my $password = 'thePassword123'; |
362 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
369 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
363 |
my $userid = $librarian->userid; |
370 |
my $userid = $librarian->userid; |
Lines 391-397
subtest 'add() tests' => sub {
Link Here
|
391 |
delete $newpatron->{falseproperty}; |
398 |
delete $newpatron->{falseproperty}; |
392 |
|
399 |
|
393 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
400 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
394 |
$newpatron = $patron_to_delete->to_api; |
401 |
$newpatron = $patron_to_delete->to_api({ user => $librarian }); |
395 |
# delete RO attributes |
402 |
# delete RO attributes |
396 |
delete $newpatron->{patron_id}; |
403 |
delete $newpatron->{patron_id}; |
397 |
delete $newpatron->{restricted}; |
404 |
delete $newpatron->{restricted}; |
Lines 617-623
subtest 'update() tests' => sub {
Link Here
|
617 |
|
624 |
|
618 |
my $patron_1 = $authorized_patron; |
625 |
my $patron_1 = $authorized_patron; |
619 |
my $patron_2 = $unauthorized_patron; |
626 |
my $patron_2 = $unauthorized_patron; |
620 |
my $newpatron = $unauthorized_patron->to_api; |
627 |
my $newpatron = $unauthorized_patron->to_api({ user => $authorized_patron }); |
621 |
# delete RO attributes |
628 |
# delete RO attributes |
622 |
delete $newpatron->{patron_id}; |
629 |
delete $newpatron->{patron_id}; |
623 |
delete $newpatron->{restricted}; |
630 |
delete $newpatron->{restricted}; |
Lines 694-702
subtest 'update() tests' => sub {
Link Here
|
694 |
->status_is(200, 'Patron updated successfully'); |
701 |
->status_is(200, 'Patron updated successfully'); |
695 |
|
702 |
|
696 |
# Put back the RO attributes |
703 |
# Put back the RO attributes |
697 |
$newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; |
704 |
$newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id}; |
698 |
$newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; |
705 |
$newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted}; |
699 |
$newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; |
706 |
$newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized}; |
700 |
|
707 |
|
701 |
my $got = $result->tx->res->json; |
708 |
my $got = $result->tx->res->json; |
702 |
my $updated_on_got = delete $got->{updated_on}; |
709 |
my $updated_on_got = delete $got->{updated_on}; |
703 |
- |
|
|