From 828394e1c00707bee4cd24e30a856abebc7a7384 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 17 Dec 2019 14:38:41 -0300 Subject: [PATCH] Bug 24232: Regression tests This patch enhances the tests for the DELETE /biblios/:biblio_id endpoint so more fine grained permissions are tested. It highlights the fact that the required permissions defined on the spec are not correcttly defined. To test: 1. Run: $ kshell k$ prove t/db_dependent/api/v1/biblios.t => FAIL: Tests fail because the user (that now has subpermissions only) does not have enough permissions for a non-existent subpermission Signed-off-by: Kelly McElligott --- t/db_dependent/api/v1/biblios.t | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t index 8bf7e4d97e..6b38b6778e 100644 --- a/t/db_dependent/api/v1/biblios.t +++ b/t/db_dependent/api/v1/biblios.t @@ -98,14 +98,14 @@ subtest 'get() tests' => sub { subtest 'delete() tests' => sub { - plan tests => 7; + plan tests => 9; $schema->storage->txn_begin; my $patron = $builder->build_object( { class => 'Koha::Patrons', - value => { flags => 9 } + value => { flags => 0 } # no permissions } ); my $password = 'thePassword123'; @@ -115,6 +115,22 @@ subtest 'delete() tests' => sub { my $item = $builder->build_sample_item(); my $biblio_id = $item->biblionumber; + $t->delete_ok("//$userid:$password@/api/v1/biblios/$biblio_id") + ->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' + } + } + ); + + # Bibs with items cannot be deleted $t->delete_ok("//$userid:$password@/api/v1/biblios/$biblio_id") ->status_is(409); -- 2.11.0