Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it |
6 |
# under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 3 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use Test::More tests => 3; |
21 |
|
22 |
use_ok('Koha::Auth::Permissions'); |
23 |
|
24 |
subtest 'normal staff user test' => sub { |
25 |
plan tests => 1; |
26 |
my $flags = { |
27 |
'permissions' => 0, |
28 |
'circulate' => { |
29 |
circulate_remaining_permissions => 1, |
30 |
}, |
31 |
'staffaccess' => 1, |
32 |
'editcatalogue' => 0, |
33 |
'cash_management' => 0, |
34 |
'reserveforothers' => 0, |
35 |
'serials' => 0, |
36 |
'borrowers' => 0, |
37 |
'lists' => 0, |
38 |
'suggestions' => 0, |
39 |
'acquisition' => 0, |
40 |
'tools' => 0, |
41 |
'stockrotation' => 0, |
42 |
'clubs' => 0, |
43 |
'reports' => 0, |
44 |
'editauthorities' => 0, |
45 |
'updatecharges' => 0, |
46 |
'ill' => 0, |
47 |
'coursereserves' => 0, |
48 |
'self_check' => 0, |
49 |
'plugins' => 0, |
50 |
'superlibrarian' => 0, |
51 |
'recalls' => 0, |
52 |
'catalogue' => 0, |
53 |
'problem_reports' => 0, |
54 |
'parameters' => 0 |
55 |
}; |
56 |
my $authz = Koha::Auth::Permissions->get_authz_from_flags({ flags => $flags }); |
57 |
my $expected = { |
58 |
'CAN_user_staffaccess' => 1, |
59 |
'CAN_user_circulate' => 1, |
60 |
'CAN_user_circulate_circulate_remaining_permissions' => 1, |
61 |
}; |
62 |
is_deeply($authz,$expected,'Expected permissions generated for superlibrarian'); |
63 |
}; |
64 |
|
65 |
subtest 'superlibrarian tests' => sub { |
66 |
plan tests => 1; |
67 |
my $flags = { |
68 |
'permissions' => 0, |
69 |
'circulate' => 0, |
70 |
'staffaccess' => 0, |
71 |
'editcatalogue' => 0, |
72 |
'cash_management' => 0, |
73 |
'reserveforothers' => 0, |
74 |
'serials' => 0, |
75 |
'borrowers' => 0, |
76 |
'lists' => 0, |
77 |
'suggestions' => 0, |
78 |
'acquisition' => 0, |
79 |
'tools' => 0, |
80 |
'stockrotation' => 0, |
81 |
'clubs' => 0, |
82 |
'reports' => 0, |
83 |
'editauthorities' => 0, |
84 |
'updatecharges' => 0, |
85 |
'ill' => 0, |
86 |
'coursereserves' => 0, |
87 |
'self_check' => 0, |
88 |
'plugins' => 0, |
89 |
'superlibrarian' => 1, |
90 |
'recalls' => 0, |
91 |
'catalogue' => 0, |
92 |
'problem_reports' => 0, |
93 |
'parameters' => 0 |
94 |
}; |
95 |
my $authz = Koha::Auth::Permissions->get_authz_from_flags({ flags => $flags }); |
96 |
my $expected = { |
97 |
'CAN_user_staffaccess' => 1, |
98 |
'CAN_user_parameters_manage_curbside_pickups' => 1, |
99 |
'CAN_user_serials' => 1, |
100 |
'CAN_user_self_check_self_checkout_module' => 1, |
101 |
'CAN_user_parameters_manage_audio_alerts' => 1, |
102 |
'CAN_user_parameters_manage_additional_fields' => 1, |
103 |
'CAN_user_parameters_manage_accounts' => 1, |
104 |
'CAN_user_tools_moderate_tags' => 1, |
105 |
'CAN_user_coursereserves_manage_courses' => 1, |
106 |
'CAN_user_clubs_enroll' => 1, |
107 |
'CAN_user_tools_manage_staged_marc' => 1, |
108 |
'CAN_user_updatecharges_discount' => 1, |
109 |
'CAN_user_tools_moderate_comments' => 1, |
110 |
'CAN_user_parameters_manage_search_engine_config' => 1, |
111 |
'CAN_user_acquisition_planning_manage' => 1, |
112 |
'CAN_user_updatecharges_refund' => 1, |
113 |
'CAN_user_self_check_self_checkin_module' => 1, |
114 |
'CAN_user_acquisition_currencies_manage' => 1, |
115 |
'CAN_user_acquisition_vendors_manage' => 1, |
116 |
'CAN_user_updatecharges_writeoff' => 1, |
117 |
'CAN_user_tools_edit_quotes' => 1, |
118 |
'CAN_user_acquisition_group_manage' => 1, |
119 |
'CAN_user_circulate' => 1, |
120 |
'CAN_user_acquisition_budget_modify' => 1, |
121 |
'CAN_user_permissions' => 1, |
122 |
'CAN_user_plugins' => 1, |
123 |
'CAN_user_superlibrarian' => 1, |
124 |
'CAN_user_parameters_manage_marc_overlay_rules' => 1, |
125 |
'CAN_user_circulate_circulate_remaining_permissions' => 1, |
126 |
'CAN_user_circulate_manage_curbside_pickups' => 1, |
127 |
'CAN_user_acquisition_budget_manage' => 1, |
128 |
'CAN_user_tools_manage_patron_lists' => 1, |
129 |
'CAN_user_reserveforothers_modify_holds_priority' => 1, |
130 |
'CAN_user_cash_management_anonymous_refund' => 1, |
131 |
'CAN_user_editcatalogue_edit_items_restricted' => 1, |
132 |
'CAN_user_tools_delete_anonymize_patrons' => 1, |
133 |
'CAN_user_editcatalogue' => 1, |
134 |
'CAN_user_tools_upload_manage' => 1, |
135 |
'CAN_user_parameters_manage_marc_frameworks' => 1, |
136 |
'CAN_user_reports_delete_reports' => 1, |
137 |
'CAN_user_tools_import_patrons' => 1, |
138 |
'CAN_user_borrowers_delete_borrowers' => 1, |
139 |
'CAN_user_tools_rotating_collections' => 1, |
140 |
'CAN_user_acquisition_budget_manage_all' => 1, |
141 |
'CAN_user_circulate_override_renewals' => 1, |
142 |
'CAN_user_serials_claim_serials' => 1, |
143 |
'CAN_user_tools_stage_marc_import' => 1, |
144 |
'CAN_user_serials_edit_subscription' => 1, |
145 |
'CAN_user_cash_management_cashup' => 1, |
146 |
'CAN_user_parameters_manage_cities' => 1, |
147 |
'CAN_user_parameters_manage_auth_values' => 1, |
148 |
'CAN_user_parameters_manage_column_config' => 1, |
149 |
'CAN_user_parameters_manage_didyoumean' => 1, |
150 |
'CAN_user_problem_reports' => 1, |
151 |
'CAN_user_acquisition_delete_invoices' => 1, |
152 |
'CAN_user_cash_management_takepayment' => 1, |
153 |
'CAN_user_tools_batch_extend_due_dates' => 1, |
154 |
'CAN_user_circulate_manage_checkout_notes' => 1, |
155 |
'CAN_user_circulate_overdues_report' => 1, |
156 |
'CAN_user_reports_execute_reports' => 1, |
157 |
'CAN_user_tools_marc_modification_templates' => 1, |
158 |
'CAN_user_tools_manage_csv_profiles' => 1, |
159 |
'CAN_user_recalls_manage_recalls' => 1, |
160 |
'CAN_user_reserveforothers_place_holds' => 1, |
161 |
'CAN_user_plugins_tool' => 1, |
162 |
'CAN_user_editcatalogue_delete_all_items' => 1, |
163 |
'CAN_user_editcatalogue_edit_catalogue' => 1, |
164 |
'CAN_user_coursereserves_delete_reserves' => 1, |
165 |
'CAN_user_lists_edit_public_lists' => 1, |
166 |
'CAN_user_parameters_manage_item_search_fields' => 1, |
167 |
'CAN_user_editcatalogue_manage_item_groups' => 1, |
168 |
'CAN_user_borrowers_view_borrower_infos_from_any_libraries' => 1, |
169 |
'CAN_user_stockrotation_manage_rota_items' => 1, |
170 |
'CAN_user_editauthorities' => 1, |
171 |
'CAN_user_parameters_manage_usage_stats' => 1, |
172 |
'CAN_user_parameters_manage_item_circ_alerts' => 1, |
173 |
'CAN_user_circulate_manage_restrictions' => 1, |
174 |
'CAN_user_parameters_manage_classifications' => 1, |
175 |
'CAN_user_clubs' => 1, |
176 |
'CAN_user_tools_items_batchdel' => 1, |
177 |
'CAN_user_borrowers_edit_borrowers' => 1, |
178 |
'CAN_user_parameters_manage_sms_providers' => 1, |
179 |
'CAN_user_reports_create_reports' => 1, |
180 |
'CAN_user_parameters_manage_oai_sets' => 1, |
181 |
'CAN_user_acquisition_order_manage' => 1, |
182 |
'CAN_user_editcatalogue_advanced_editor' => 1, |
183 |
'CAN_user_suggestions' => 1, |
184 |
'CAN_user_clubs_edit_clubs' => 1, |
185 |
'CAN_user_parameters_manage_patron_attributes' => 1, |
186 |
'CAN_user_reserveforothers' => 1, |
187 |
'CAN_user_acquisition_period_manage' => 1, |
188 |
'CAN_user_editcatalogue_create_shared_macros' => 1, |
189 |
'CAN_user_plugins_manage' => 1, |
190 |
'CAN_user_problem_reports_manage_problem_reports' => 1, |
191 |
'CAN_user_tools_label_creator' => 1, |
192 |
'CAN_user_parameters_manage_circ_rules_from_any_libraries' => 1, |
193 |
'CAN_user_serials_create_subscription' => 1, |
194 |
'CAN_user_tools_inventory' => 1, |
195 |
'CAN_user_tools_upload_general_files' => 1, |
196 |
'CAN_user_tools_edit_additional_contents' => 1, |
197 |
'CAN_user_acquisition_edi_manage' => 1, |
198 |
'CAN_user_tools_edit_notice_status_triggers' => 1, |
199 |
'CAN_user_parameters_manage_smtp_servers' => 1, |
200 |
'CAN_user_parameters_manage_libraries' => 1, |
201 |
'CAN_user_serials_receive_serials' => 1, |
202 |
'CAN_user_parameters_manage_patron_categories' => 1, |
203 |
'CAN_user_tools_items_batchmod' => 1, |
204 |
'CAN_user_tools_view_system_logs' => 1, |
205 |
'CAN_user_serials_renew_subscription' => 1, |
206 |
'CAN_user_parameters_manage_keyboard_shortcuts' => 1, |
207 |
'CAN_user_recalls' => 1, |
208 |
'CAN_user_acquisition_contracts_manage' => 1, |
209 |
'CAN_user_circulate_force_checkout' => 1, |
210 |
'CAN_user_coursereserves_add_reserves' => 1, |
211 |
'CAN_user_acquisition_order_receive' => 1, |
212 |
'CAN_user_stockrotation_manage_rotas' => 1, |
213 |
'CAN_user_updatecharges_payout' => 1, |
214 |
'CAN_user_tools_batch_upload_patron_images' => 1, |
215 |
'CAN_user_catalogue' => 1, |
216 |
'CAN_user_serials_delete_subscription' => 1, |
217 |
'CAN_user_stockrotation' => 1, |
218 |
'CAN_user_self_check' => 1, |
219 |
'CAN_user_tools_upload_local_cover_images' => 1, |
220 |
'CAN_user_tools_edit_notices' => 1, |
221 |
'CAN_user_acquisition_reopen_closed_invoices' => 1, |
222 |
'CAN_user_parameters_manage_mana' => 1, |
223 |
'CAN_user_tools_export_catalog' => 1, |
224 |
'CAN_user_parameters_manage_itemtypes' => 1, |
225 |
'CAN_user_parameters_manage_matching_rules' => 1, |
226 |
'CAN_user_suggestions_suggestions_manage' => 1, |
227 |
'CAN_user_parameters_manage_background_jobs' => 1, |
228 |
'CAN_user_tools_records_batchmod' => 1, |
229 |
'CAN_user_tools_items_batchmod_restricted' => 1, |
230 |
'CAN_user_parameters_manage_sysprefs' => 1, |
231 |
'CAN_user_tools_edit_calendar' => 1, |
232 |
'CAN_user_acquisition_merge_invoices' => 1, |
233 |
'CAN_user_tools_records_batchdel' => 1, |
234 |
'CAN_user_tools_edit_patrons' => 1, |
235 |
'CAN_user_borrowers' => 1, |
236 |
'CAN_user_updatecharges_remaining_permissions' => 1, |
237 |
'CAN_user_parameters_parameters_remaining_permissions' => 1, |
238 |
'CAN_user_parameters' => 1, |
239 |
'CAN_user_cash_management' => 1, |
240 |
'CAN_user_tools' => 1, |
241 |
'CAN_user_editcatalogue_edit_items' => 1, |
242 |
'CAN_user_tools_access_files' => 1, |
243 |
'CAN_user_parameters_manage_cash_registers' => 1, |
244 |
'CAN_user_plugins_report' => 1, |
245 |
'CAN_user_clubs_edit_templates' => 1, |
246 |
'CAN_user_serials_routing' => 1, |
247 |
'CAN_user_editcatalogue_delete_shared_macros' => 1, |
248 |
'CAN_user_parameters_manage_circ_rules' => 1, |
249 |
'CAN_user_ill' => 1, |
250 |
'CAN_user_lists_delete_public_lists' => 1, |
251 |
'CAN_user_parameters_manage_search_targets' => 1, |
252 |
'CAN_user_editcatalogue_fast_cataloging' => 1, |
253 |
'CAN_user_acquisition' => 1, |
254 |
'CAN_user_acquisition_edit_invoices' => 1, |
255 |
'CAN_user_acquisition_order_manage_all' => 1, |
256 |
'CAN_user_parameters_manage_transfers' => 1, |
257 |
'CAN_user_coursereserves' => 1, |
258 |
'CAN_user_serials_check_expiration' => 1, |
259 |
'CAN_user_updatecharges' => 1, |
260 |
'CAN_user_reports' => 1, |
261 |
'CAN_user_plugins_configure' => 1, |
262 |
'CAN_user_tools_schedule_tasks' => 1, |
263 |
'CAN_user_lists' => 1, |
264 |
'CAN_user_acquisition_delete_baskets' => 1, |
265 |
'CAN_user_acquisition_budget_add_del' => 1, |
266 |
'CAN_user_serials_superserials' => 1 |
267 |
}; |
268 |
is_deeply($authz,$expected,'Expected permissions generated for superlibrarian'); |
269 |
}; |