Bugzilla – Attachment 133890 Details for
Bug 29926
Add ability for superlibrarians to edit password expiration dates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29926: (QA follow-up) API design fixes
Bug-29926-QA-follow-up-API-design-fixes.patch (text/plain), 7.50 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-04-26 13:14:09 UTC
(
hide
)
Description:
Bug 29926: (QA follow-up) API design fixes
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-04-26 13:14:09 UTC
Size:
7.50 KB
patch
obsolete
>From ccd8e8a1179a7f980ddf7e58080b2a9ca23837fd Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 26 Apr 2022 09:52:21 -0300 >Subject: [PATCH] Bug 29926: (QA follow-up) API design fixes > >This patch makes the following changes to the spec: > >* Password being the resource and expiration_date an attribute for it, > so reorganizing things and also renaming the route. >* Be it undefined or defined, expiration date is only one and thus > should use the PUT verb (as in overwrite). >* Minor bug 30194-related fixes. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > api/v1/swagger/paths/patrons_password.yaml | 56 ++++++++++++++++++ > .../paths/patrons_password_expiration.yaml | 57 ------------------- > api/v1/swagger/swagger.yaml | 4 +- > .../api/v1/patrons_password_expiration.t | 16 +++--- > 4 files changed, 66 insertions(+), 67 deletions(-) > delete mode 100644 api/v1/swagger/paths/patrons_password_expiration.yaml > >diff --git a/api/v1/swagger/paths/patrons_password.yaml b/api/v1/swagger/paths/patrons_password.yaml >index 2d2f07e08f3..20c23db0e5b 100644 >--- a/api/v1/swagger/paths/patrons_password.yaml >+++ b/api/v1/swagger/paths/patrons_password.yaml >@@ -59,3 +59,59 @@ > x-koha-authorization: > permissions: > borrowers: "1" >+"/patrons/{patron_id}/password/expiration_date": >+ put: >+ x-mojo-to: Patrons::Password::Expiration#set >+ operationId: setPatronPasswordExpiration >+ tags: >+ - patrons >+ summary: Set password expiration for a patron >+ parameters: >+ - $ref: ../swagger.yaml#/parameters/patron_id_pp >+ - name: body >+ in: body >+ description: A JSON object containing password expiration date >+ schema: >+ type: object >+ properties: >+ expiration_date: >+ description: Date to expire password >+ type: string >+ required: >+ - expiration_date >+ additionalProperties: false >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: Password expiration changed >+ "400": >+ description: Bad request >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ "401": >+ description: Authentication required >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ "404": >+ description: Patron not found >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: ../swagger.yaml#/definitions/error >+ x-koha-authorization: >+ permissions: >+ superlibrarian: "1" >diff --git a/api/v1/swagger/paths/patrons_password_expiration.yaml b/api/v1/swagger/paths/patrons_password_expiration.yaml >deleted file mode 100644 >index 87f7a8a037e..00000000000 >--- a/api/v1/swagger/paths/patrons_password_expiration.yaml >+++ /dev/null >@@ -1,57 +0,0 @@ >---- >-"/patrons/{patron_id}/password/expiration": >- post: >- x-mojo-to: Patrons::Password::Expiration#set >- operationId: setPatronPasswordExpiration >- tags: >- - patrons >- summary: Set password expiration for a patron >- parameters: >- - $ref: ../parameters.yaml#/patron_id_pp >- - name: body >- in: body >- description: A JSON object containing password expiration date >- schema: >- type: object >- properties: >- expiration_date: >- description: Date to expire password >- type: string >- required: >- - expiration_date >- additionalProperties: false >- produces: >- - application/json >- responses: >- "200": >- description: Password expiration changed >- "400": >- description: Bad request >- schema: >- $ref: ../definitions.yaml#/error >- "401": >- description: Authentication required >- schema: >- $ref: ../definitions.yaml#/error >- "403": >- description: Access forbidden >- schema: >- $ref: ../definitions.yaml#/error >- "404": >- description: Patron not found >- schema: >- $ref: ../definitions.yaml#/error >- "500": >- description: | >- Internal server error. Possible `error_code` attribute values: >- >- * `internal_server_error` >- schema: >- $ref: ../definitions.yaml#/error >- "503": >- description: Under maintenance >- schema: >- $ref: ../definitions.yaml#/error >- x-koha-authorization: >- permissions: >- superlibrarian: "1" >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index bb8c9ac1206..25f68006da8 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -173,8 +173,8 @@ paths: > $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds" > "/patrons/{patron_id}/password": > $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password" >- "/patrons/{patron_id}/password/expiration": >- $ref: "./paths/patrons_password_expiration.yaml#/~1patrons~1{patron_id}~1password~1expiration" >+ "/patrons/{patron_id}/password/expiration_date": >+ $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date" > "/public/biblios/{biblio_id}": > $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}" > "/public/biblios/{biblio_id}/items": >diff --git a/t/db_dependent/api/v1/patrons_password_expiration.t b/t/db_dependent/api/v1/patrons_password_expiration.t >index ae5e4c1bbca..603d8d9c113 100755 >--- a/t/db_dependent/api/v1/patrons_password_expiration.t >+++ b/t/db_dependent/api/v1/patrons_password_expiration.t >@@ -56,21 +56,21 @@ subtest 'basic tests' => sub { > > my $new_password = 'abc'; > >- $t->post_ok( "//$userid:$password@/api/v1/patrons/" >+ $t->put_ok( "//$userid:$password@/api/v1/patrons/" > . $patron->id >- . "/password/expiration" => json => >+ . "/password/expiration_date" => json => > { expiration_date => '2021-01-01' } ) > ->status_is(200)->json_is(''); > >- $t->post_ok( "//$userid:$password@/api/v1/patrons/" >+ $t->put_ok( "//$userid:$password@/api/v1/patrons/" > . $patron->id >- . "/password/expiration" => json => >+ . "/password/expiration_date" => json => > { expiration_date => '01/13/2021' } ) > ->status_is(200)->json_is(''); > >- $t->post_ok( "//$userid:$password@/api/v1/patrons/" >+ $t->put_ok( "//$userid:$password@/api/v1/patrons/" > . $patron->id >- . "/password/expiration" => json => >+ . "/password/expiration_date" => json => > { expiration_date => '13/01/2021' } ) > ->status_is(500)->json_is({ > error => 'Something went wrong, check Koha logs for details.', >@@ -79,9 +79,9 @@ subtest 'basic tests' => sub { > > $privileged_patron->flags(0)->store(); > >- $t->post_ok( "//$userid:$password@/api/v1/patrons/" >+ $t->put_ok( "//$userid:$password@/api/v1/patrons/" > . $patron->id >- . "/password/expiration" => json => >+ . "/password/expiration_date" => json => > { expiration_date => '2021-01-01' } ) > ->status_is(403)->json_is({ > error => "Authorization failure. Missing required permission(s).", >-- >2.34.1
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 29926
:
130551
|
130552
|
130553
|
130686
|
130687
|
130688
|
133759
|
133760
|
133761
|
133887
|
133888
|
133889
| 133890 |
133891