@@ -, +, @@ --- installer/data/mysql/userpermissions.sql | 1 + t/db_dependent/Auth/haspermission.t | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) --- a/installer/data/mysql/userpermissions.sql +++ a/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'), --- a/t/db_dependent/Auth/haspermission.t +++ a/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; --