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> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
60c8534b8d
commit
b97bf747e9
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -177,8 +177,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":
|
||||
|
|
|
|||
|
|
@ -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).",
|
||||
|
|
|
|||
Loading…
Reference in New Issue