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 393-399
subtest 'add() tests' => sub {
Link Here
|
393 |
delete $newpatron->{falseproperty}; |
400 |
delete $newpatron->{falseproperty}; |
394 |
|
401 |
|
395 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
402 |
my $patron_to_delete = $builder->build_object({ class => 'Koha::Patrons' }); |
396 |
$newpatron = $patron_to_delete->to_api; |
403 |
$newpatron = $patron_to_delete->to_api({ user => $librarian }); |
397 |
# delete RO attributes |
404 |
# delete RO attributes |
398 |
delete $newpatron->{patron_id}; |
405 |
delete $newpatron->{patron_id}; |
399 |
delete $newpatron->{restricted}; |
406 |
delete $newpatron->{restricted}; |
Lines 618-624
subtest 'update() tests' => sub {
Link Here
|
618 |
|
625 |
|
619 |
my $patron_1 = $authorized_patron; |
626 |
my $patron_1 = $authorized_patron; |
620 |
my $patron_2 = $unauthorized_patron; |
627 |
my $patron_2 = $unauthorized_patron; |
621 |
my $newpatron = $unauthorized_patron->to_api; |
628 |
my $newpatron = $unauthorized_patron->to_api({ user => $authorized_patron }); |
622 |
# delete RO attributes |
629 |
# delete RO attributes |
623 |
delete $newpatron->{patron_id}; |
630 |
delete $newpatron->{patron_id}; |
624 |
delete $newpatron->{restricted}; |
631 |
delete $newpatron->{restricted}; |
Lines 698-706
subtest 'update() tests' => sub {
Link Here
|
698 |
->status_is(200, 'Patron updated successfully'); |
705 |
->status_is(200, 'Patron updated successfully'); |
699 |
|
706 |
|
700 |
# Put back the RO attributes |
707 |
# Put back the RO attributes |
701 |
$newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; |
708 |
$newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id}; |
702 |
$newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; |
709 |
$newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted}; |
703 |
$newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; |
710 |
$newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized}; |
704 |
|
711 |
|
705 |
my $got = $result->tx->res->json; |
712 |
my $got = $result->tx->res->json; |
706 |
my $updated_on_got = delete $got->{updated_on}; |
713 |
my $updated_on_got = delete $got->{updated_on}; |
707 |
- |
|
|