Bugzilla – Attachment 153562 Details for
Bug 34288
Cannot use cataloguing tools without cataloguing permissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34288: Unit tests
Bug-34288-Unit-tests.patch (text/plain), 3.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-07-17 15:15:45 UTC
(
hide
)
Description:
Bug 34288: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-07-17 15:15:45 UTC
Size:
3.63 KB
patch
obsolete
>From 4a9d0a08cdd105331a8b1c799133761edfae3e3a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 17 Jul 2023 12:08:34 -0300 >Subject: [PATCH] Bug 34288: Unit tests > >--- > t/db_dependent/Auth.t | 85 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 83 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 4f4ad6a78cd..5de81401e10 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -7,7 +7,7 @@ use CGI qw ( -utf8 ); > use Test::MockObject; > use Test::MockModule; > use List::MoreUtils qw/all any none/; >-use Test::More tests => 18; >+use Test::More tests => 19; > use Test::Warn; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -20,7 +20,10 @@ use Koha::Patrons; > use Koha::Auth::TwoFactorAuth; > > BEGIN { >- use_ok('C4::Auth', qw( checkauth haspermission track_login_daily checkpw get_template_and_user checkpw_hash )); >+ use_ok( >+ 'C4::Auth', >+ qw( checkauth haspermission track_login_daily checkpw get_template_and_user checkpw_hash get_cataloguing_page_permissions ) >+ ); > } > > my $schema = Koha::Database->schema; >@@ -1003,3 +1006,81 @@ subtest 'check_cookie_auth overwriting interface already set' => sub { > }; > > $schema->storage->txn_rollback; >+ >+subtest 'get_cataloguing_page_permissions() tests' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 2**2 } } ); # catalogue >+ >+ ok( >+ !C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ '"catalogue" is not enough to see the cataloguing page' >+ ); >+ >+ $builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $patron->id, >+ module_bit => 24, # stockrotation >+ code => 'manage_rotas', >+ }, >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'StockRotation', 1 ); >+ ok( >+ C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ '"stockrotation => manage_rotas" is enough' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'StockRotation', 0 ); >+ ok( >+ !C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ '"stockrotation => manage_rotas" is not enough when `StockRotation` is disabled' >+ ); >+ >+ $builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $patron->id, >+ module_bit => 13, # tools >+ code => 'manage_staged_marc', >+ }, >+ } >+ ); >+ >+ ok( >+ C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ 'Having one of the listed `tools` subperm is enough' >+ ); >+ >+ $schema->resultset('UserPermission')->search( { borrowernumber => $patron->id } )->delete; >+ >+ ok( >+ !C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ 'Permission removed, no access' >+ ); >+ >+ $builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $patron->id, >+ module_bit => 9, # editcatalogue >+ code => 'delete_all_items', >+ }, >+ } >+ ); >+ >+ ok( >+ C4::Auth::haspermission( $patron->userid, get_cataloguing_page_permissions() ), >+ 'Having any `editcatalogue` subperm is enough' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34288
:
153527
|
153560
|
153561
|
153562
|
153565
|
153566
|
153567
|
153571
|
153572
|
153573