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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomas Cohen Arazi 2023-03-06 17:39:14 -03:00
parent b9d8e6be11
commit b70ce9dcad
2 changed files with 4 additions and 18 deletions

View File

@ -74,11 +74,7 @@
schema:
$ref: "../swagger.yaml#/definitions/error"
"404":
description: Biblio not found
schema:
$ref: "../swagger.yaml#/definitions/error"
"409":
description: Unable to perform action on biblio
description: Authority not found
schema:
$ref: "../swagger.yaml#/definitions/error"
"500":
@ -91,4 +87,4 @@
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
editcatalogue: edit_catalogue
editauthorities: "1"

View File

@ -141,17 +141,7 @@ subtest 'delete() tests' => sub {
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid)
->status_is(403, 'Not enough permissions makes it return the right code');
# Add permissions
$builder->build(
{
source => 'UserPermission',
value => {
borrowernumber => $patron->borrowernumber,
module_bit => 9,
code => 'edit_catalogue'
}
}
);
$patron->flags( 2 ** 14 )->store; # 14 => editauthorities userflag
$t->delete_ok("//$userid:$password@/api/v1/authorities/".$authority->authid)
->status_is(204, 'SWAGGER3.2.4')
@ -161,4 +151,4 @@ subtest 'delete() tests' => sub {
->status_is(404);
$schema->storage->txn_rollback;
};
};