From 3de4fc9fefb88c21672257301426379b9d33e2e2 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Mon, 26 Feb 2018 12:32:56 -0700 Subject: [PATCH] Bug 15520: (QA follow-up) Add tests, missing installer data --- installer/data/mysql/userpermissions.sql | 1 + t/db_dependent/Auth/haspermission.t | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 52adbceebf..78765a3990 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -7,6 +7,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID'), ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'), ( 3, 'manage_circ_rules', 'Manage circulation rules'), + ( 3, 'manage_circ_rules_restricted', 'Only manage circ rules for own library'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), ( 6, 'place_holds', 'Place holds for patrons'), diff --git a/t/db_dependent/Auth/haspermission.t b/t/db_dependent/Auth/haspermission.t index bf0290d6be..0c9c53cc0c 100644 --- a/t/db_dependent/Auth/haspermission.t +++ b/t/db_dependent/Auth/haspermission.t @@ -20,7 +20,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 13; +use Test::More tests => 14; use Koha::Database; use t::lib::TestBuilder; @@ -104,5 +104,19 @@ $r = haspermission( $borr2->{userid}, { }); is( ref($r), 'HASH', 'Borrower2/tools granular two upload subperms' ); +subtest 'no_inherit' => sub { + $r = haspermission( $borr1->{userid}, { circulate => 'override_renewals' }, { no_inherit => 1 } ); + is( $r, 0, 'checking specific permission when only has superlibrarian should fail' ); + + $r = haspermission( $borr2->{userid}, { parameters => 'parameters_remaining_permissions' }, { no_inherit => 1 } ); + is( $r, 0, 'checking specific permission when doesn\'t even have module permission should fail' ); + + $r = haspermission( $borr2->{userid}, { circulate => 'override_renewals' }, { no_inherit => 1 } ); + is( $r, 0, 'checking specific permission when only has module permission should fail' ); + + $r = haspermission( $borr2->{userid}, { tools => 'upload_local_cover_images' }, { no_inherit => 1 } ); + is( ref($r), 'HASH', 'checking specific permission when user has specifically that should succeed' ); +}; + # End $schema->storage->txn_rollback; -- 2.15.1