Created attachment 144472 [details] [review] Bug 31793: Add REST endpoint to delete authorities To test: 1. Apply patch 2. Set RESTBasicAuth preference to true 3. Get the id of an authority 4. Make a DELETE request to /api/v1/authorities/{authid} 5. Check that the authority was deleted 6. Sign off
Created attachment 144705 [details] [review] Bug 31793: Add REST endpoint to delete authorities To test: 1. Apply patch 2. Set RESTBasicAuth preference to true 3. Get the id of an authority 4. Make a DELETE request to /api/v1/authorities/{authid} 5. Check that the authority was deleted 6. Sign off Signed-off-by: David Nind <david@davidnind.com>
Testing notes (using KTD): 1. I used this command to delete an existing authority: curl -u koha:koha --request DELETE http://127.0.0.1:8080/api/v1/authorities/419 2. This authority (419) had associated records - the authority deleted was removed from the record.
+ return try { + my $error = DelAuthority( { authid => $authority->authid } ); + + if ($error) { + return $c->render( + status => 409, I would probably go for 500 as long as we dont know what has been going on in DelAuthority.
+ "404": + description: Biblio not found + schema: + $ref: "../swagger.yaml#/definitions/error" Copy and paste. Correct ! + "409": + description: Unable to perform action on biblio
+ x-koha-authorization: + permissions: + editcatalogue: edit_catalogue I would probably expect: flagsrequired => {editauthorities => 1},
Created attachment 147808 [details] [review] Bug 31793: Add REST endpoint to delete authorities To test: 1. Apply patch 2. Set RESTBasicAuth preference to true 3. Get the id of an authority 4. Make a DELETE request to /api/v1/authorities/{authid} 5. Check that the authority was deleted 6. Sign off Signed-off-by: David Nind <david@davidnind.com>
Created attachment 147809 [details] [review] Bug 31793: (QA follow-up) DelAuthority doesn't return errors DelAuthority doesn't return an error, so the only possible error conditions are exceptions, that are unknown for now. Removing the error checking control structure and the 409 error returning, which is inherited from DelBiblio's call on the biblios endpoint. It will now just return a 500 in the event of an unhandled internal error. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 147810 [details] [review] Bug 31793: (QA follow-up) Require editauthorities flag This patch makes the route require the right permissions. Tests are adjusted to reflect this new situation. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/authorities.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 147831 [details] [review] Bug 31793: Add REST endpoint to delete authorities To test: 1. Apply patch 2. Set RESTBasicAuth preference to true 3. Get the id of an authority 4. Make a DELETE request to /api/v1/authorities/{authid} 5. Check that the authority was deleted 6. Sign off Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 147832 [details] [review] Bug 31793: (QA follow-up) DelAuthority doesn't return errors DelAuthority doesn't return an error, so the only possible error conditions are exceptions, that are unknown for now. Removing the error checking control structure and the 409 error returning, which is inherited from DelBiblio's call on the biblios endpoint. It will now just return a 500 in the event of an unhandled internal error. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 147833 [details] [review] Bug 31793: (QA follow-up) Require editauthorities flag This patch makes the route require the right permissions. Tests are adjusted to reflect this new situation. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/authorities.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 23.05. Nice work everyone, thanks!
Enhancement - not backporting to 22.11.x Good work everyone!