Bugzilla – Attachment 47743 Details for
Bug 15756
Some tests for haspermission in C4::Auth
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF]Bug 15756: Some tests for haspermission in C4::Auth
SIGNED-OFFBug-15756-Some-tests-for-haspermission-i.patch (text/plain), 4.54 KB, created by
Héctor Eduardo Castro Avalos
on 2016-02-08 16:32:21 UTC
(
hide
)
Description:
[SIGNED-OFF]Bug 15756: Some tests for haspermission in C4::Auth
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2016-02-08 16:32:21 UTC
Size:
4.54 KB
patch
obsolete
>From b632934264022fee42f18337973ea8c9eb00645f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 8 Feb 2016 14:58:56 +0100 >Subject: [PATCH] [SIGNED-OFF]Bug 15756: Some tests for haspermission in > C4::Auth > >Test plan: >Run this new test. > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >All tests successful. koha-qa.pl run OK. >--- > t/db_dependent/Auth/haspermission.t | 108 +++++++++++++++++++++++++++++++++++ > 1 file changed, 108 insertions(+) > create mode 100644 t/db_dependent/Auth/haspermission.t > >diff --git a/t/db_dependent/Auth/haspermission.t b/t/db_dependent/Auth/haspermission.t >new file mode 100644 >index 0000000..bf0290d >--- /dev/null >+++ b/t/db_dependent/Auth/haspermission.t >@@ -0,0 +1,108 @@ >+#!/usr/bin/perl >+ >+# Tests for C4::Auth::haspermission >+ >+# This file is part of Koha. >+# >+# Copyright 2016 Rijksmuseum >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Test::More tests => 13; >+ >+use Koha::Database; >+use t::lib::TestBuilder; >+use C4::Auth qw(haspermission); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+# Adding two borrowers and granular permissions for the second borrower >+my $builder = t::lib::TestBuilder->new(); >+my $borr1 = $builder->build({ >+ source => 'Borrower', >+ value => { >+ surname => 'Superlib', >+ flags => 1, >+ }, >+}); >+my $borr2 = $builder->build({ >+ source => 'Borrower', >+ value => { >+ surname => 'Bor2', >+ flags => 2 + 4 + 2**11, # circulate, catalogue, acquisition >+ }, >+}); >+$builder->build({ >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $borr2->{borrowernumber}, >+ module_bit => 13, # tools >+ code => 'upload_local_cover_images', >+ }, >+}); >+$builder->build({ >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $borr2->{borrowernumber}, >+ module_bit => 13, # tools >+ code => 'batch_upload_patron_images', >+ }, >+}); >+ >+# Check top level permission for superlibrarian >+my $r = haspermission( $borr1->{userid}, >+ { circulate => 1, editcatalogue => 1 } ); >+is( ref($r), 'HASH', 'Superlibrarian/circulate' ); >+ >+# Check specific top level permission(s) for borr2 >+$r = haspermission( $borr2->{userid}, >+ { circulate => 1, catalogue => 1 } ); >+is( ref($r), 'HASH', 'Borrower2/circulate' ); >+$r = haspermission( $borr2->{userid}, { updatecharges => 1 } ); >+is( $r, 0, 'Borrower2/updatecharges should fail' ); >+ >+# Check granular permission with 1: means all subpermissions >+$r = haspermission( $borr1->{userid}, { tools => 1 } ); >+is( ref($r), 'HASH', 'Superlibrarian/tools granular all' ); >+$r = haspermission( $borr2->{userid}, { tools => 1 } ); >+is( $r, 0, 'Borrower2/tools granular all should fail' ); >+ >+# Check granular permission with *: means at least one subpermission >+$r = haspermission( $borr1->{userid}, { tools => '*' } ); >+is( ref($r), 'HASH', 'Superlibrarian/tools granular *' ); >+$r = haspermission( $borr2->{userid}, { acquisition => '*' } ); >+is( ref($r), 'HASH', 'Borrower2/acq granular *' ); >+$r = haspermission( $borr2->{userid}, { tools => '*' } ); >+is( ref($r), 'HASH', 'Borrower2/tools granular *' ); >+$r = haspermission( $borr2->{userid}, { serials => '*' } ); >+is( $r, 0, 'Borrower2/serials granular * should fail' ); >+ >+# Check granular permission with one or more specific subperms >+$r = haspermission( $borr1->{userid}, { tools => 'edit_news' } ); >+is( ref($r), 'HASH', 'Superlibrarian/tools edit_news' ); >+$r = haspermission( $borr2->{userid}, { acquisition => 'budget_manage' } ); >+is( ref($r), 'HASH', 'Borrower2/acq budget_manage' ); >+$r = haspermission( $borr2->{userid}, >+ { acquisition => 'budget_manage', tools => 'edit_news' } ); >+is( $r, 0, 'Borrower2/two granular should fail' ); >+$r = haspermission( $borr2->{userid}, { >+ tools => 'upload_local_cover_images', >+ tools => 'batch_upload_patron_images', >+}); >+is( ref($r), 'HASH', 'Borrower2/tools granular two upload subperms' ); >+ >+# End >+$schema->storage->txn_rollback; >-- >1.7.10.4
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 15756
:
47739
|
47743
|
47897