Bugzilla – Attachment 148793 Details for
Bug 32426
Make userid generation pluggable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32426: (follow-up) Fix api/v1/patrons.t
Bug-32426-follow-up-Fix-apiv1patronst.patch (text/plain), 4.44 KB, created by
Marcel de Rooy
on 2023-03-28 06:44:55 UTC
(
hide
)
Description:
Bug 32426: (follow-up) Fix api/v1/patrons.t
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-03-28 06:44:55 UTC
Size:
4.44 KB
patch
obsolete
>From 5820ac2a5d2fc643be7c293cb86b9e8eea8efd2b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 28 Mar 2023 06:41:59 +0000 >Subject: [PATCH] Bug 32426: (follow-up) Fix api/v1/patrons.t >Content-Type: text/plain; charset=utf-8 > >We use another exception now. > >Test plan: >Run t/db_dependent/api/v1/patrons.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/REST/V1/Patrons.pm | 12 ++++++++++++ > t/db_dependent/api/v1/patrons.t | 22 +++++++++------------- > 2 files changed, 21 insertions(+), 13 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 576e4f8f2c..1852d7ccd2 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -147,6 +147,12 @@ sub add { > openapi => { error => $_->error, conflict => $_->duplicate_id } > ); > } >+ elsif ( $_->isa('Koha::Exceptions::Patron::InvalidUserid') ) { >+ return $c->render( >+ status => 400, >+ openapi => { error => "Problem with ". $_->userid } >+ ); >+ } > elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { > return $c->render( > status => 400, >@@ -282,6 +288,12 @@ sub update { > openapi => { error => $_->error, conflict => $_->duplicate_id } > ); > } >+ elsif ( $_->isa('Koha::Exceptions::Patron::InvalidUserid') ) { >+ return $c->render( >+ status => 400, >+ openapi => { error => "Problem with ". $_->userid } >+ ); >+ } > elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { > return $c->render( > status => 400, >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 172a04993a..8c4d9c13e1 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -302,7 +302,7 @@ subtest 'add() tests' => sub { > $schema->storage->txn_rollback; > > subtest 'librarian access tests' => sub { >- plan tests => 25; >+ plan tests => 24; > > $schema->storage->txn_begin; > >@@ -364,11 +364,9 @@ subtest 'add() tests' => sub { > > $newpatron->{library_id} = $deleted_library_id; > >- warning_like { >- $t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) >- ->status_is(409) >- ->json_is('/error' => "Duplicate ID"); } >- qr/DBD::mysql::st execute failed: Duplicate entry/; >+ $t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) >+ ->status_is(400) >+ ->json_is('/error' => "Problem with ". $newpatron->{userid} ); > > $newpatron->{library_id} = $patron->branchcode; > >@@ -418,6 +416,7 @@ subtest 'add() tests' => sub { > ->json_is( '/date_of_birth' => $newpatron->{ date_of_birth }, 'Date field set (Bug 28585)' ) > ->json_is( '/last_seen' => $newpatron->{ last_seen }, 'Date-time field set (Bug 28585)' ); > >+ $newpatron->{userid} = undef; # force regeneration > warning_like { > $t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) > ->status_is(409) >@@ -592,7 +591,7 @@ subtest 'update() tests' => sub { > $schema->storage->txn_rollback; > > subtest 'librarian access tests' => sub { >- plan tests => 45; >+ plan tests => 43; > > $schema->storage->txn_begin; > >@@ -677,12 +676,9 @@ subtest 'update() tests' => sub { > $newpatron->{cardnumber} = $patron_1->cardnumber; > $newpatron->{userid} = $patron_1->userid; > >- warning_like { >- $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) >- ->status_is(409) >- ->json_has( '/error', "Fails when trying to update to an existing cardnumber or userid") >- ->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); } >- qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; >+ $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) >+ ->status_is(400) >+ ->json_has( '/error', "Problem with userid ". $patron_1->userid ); > > $newpatron->{ cardnumber } = $patron_1->id . $patron_2->id; > $newpatron->{ userid } = "user" . $patron_1->id.$patron_2->id; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32426
:
146947
|
146948
|
146949
|
146950
|
146951
|
146952
|
146953
|
146954
|
147252
|
147253
|
147254
|
147255
|
147704
|
147705
|
147706
|
147707
|
147708
|
147709
|
147710
|
147711
|
147712
|
148203
|
148204
|
148205
|
148206
|
148207
|
148208
|
148209
|
148210
|
148211
|
148782
| 148793