|
Lines 81-102
subtest 'list() tests' => sub {
Link Here
|
| 81 |
|
81 |
|
| 82 |
subtest 'librarian access tests' => sub { |
82 |
subtest 'librarian access tests' => sub { |
| 83 |
|
83 |
|
| 84 |
plan tests => 19; |
84 |
plan tests => 21; |
| 85 |
|
85 |
|
| 86 |
$schema->storage->txn_begin; |
86 |
$schema->storage->txn_begin; |
| 87 |
|
87 |
|
| 88 |
my $librarian = $builder->build_object( |
88 |
my $librarian = $builder->build_object( |
| 89 |
{ |
89 |
{ |
| 90 |
class => 'Koha::Patrons', |
90 |
class => 'Koha::Patrons', |
| 91 |
value => { flags => 2**4 } # borrowers flag = 4 |
91 |
value => { flags => 2 ** 2 } # catalog only, no additional permissions |
| 92 |
} |
92 |
} |
| 93 |
); |
93 |
); |
|
|
94 |
|
| 95 |
# Ensure our librarian can see users from all branches (once list_borrowers is added) |
| 96 |
$builder->build( |
| 97 |
{ |
| 98 |
source => 'UserPermission', |
| 99 |
value => { |
| 100 |
borrowernumber => $librarian->borrowernumber, |
| 101 |
module_bit => 4, |
| 102 |
code => 'view_borrower_infos_from_any_libraries', |
| 103 |
}, |
| 104 |
} |
| 105 |
); |
| 106 |
|
| 94 |
my $password = 'thePassword123'; |
107 |
my $password = 'thePassword123'; |
| 95 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
108 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
| 96 |
my $userid = $librarian->userid; |
109 |
my $userid = $librarian->userid; |
| 97 |
|
110 |
|
|
|
111 |
$t->get_ok("//$userid:$password@/api/v1/patrons/") |
| 112 |
->status_is(403, 'Basic librarian unable to see patrons'); |
| 113 |
|
| 114 |
$builder->build( |
| 115 |
{ |
| 116 |
source => 'UserPermission', |
| 117 |
value => { |
| 118 |
borrowernumber => $librarian->borrowernumber, |
| 119 |
module_bit => 4, |
| 120 |
code => 'list_borrowers', |
| 121 |
}, |
| 122 |
} |
| 123 |
); |
| 124 |
|
| 98 |
$t->get_ok("//$userid:$password@/api/v1/patrons") |
125 |
$t->get_ok("//$userid:$password@/api/v1/patrons") |
| 99 |
->status_is(200); |
126 |
->status_is(200, 'list_borrowers makes /patrons accessible'); |
| 100 |
|
127 |
|
| 101 |
$t->get_ok("//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber) |
128 |
$t->get_ok("//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber) |
| 102 |
->status_is(200) |
129 |
->status_is(200) |
|
Lines 110-117
subtest 'list() tests' => sub {
Link Here
|
| 110 |
->status_is(200) |
137 |
->status_is(200) |
| 111 |
->json_is('/0/address2' => $librarian->address2); |
138 |
->json_is('/0/address2' => $librarian->address2); |
| 112 |
|
139 |
|
| 113 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
140 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 114 |
AddDebarment({ borrowernumber => $patron->borrowernumber }); |
141 |
AddDebarment( { borrowernumber => $patron->borrowernumber } ); |
| 115 |
|
142 |
|
| 116 |
$t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber ) |
143 |
$t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber ) |
| 117 |
->status_is(200) |
144 |
->status_is(200) |
|
Lines 237-260
subtest 'get() tests' => sub {
Link Here
|
| 237 |
$schema->storage->txn_rollback; |
264 |
$schema->storage->txn_rollback; |
| 238 |
|
265 |
|
| 239 |
subtest 'librarian access tests' => sub { |
266 |
subtest 'librarian access tests' => sub { |
| 240 |
plan tests => 6; |
267 |
plan tests => 8; |
| 241 |
|
268 |
|
| 242 |
$schema->storage->txn_begin; |
269 |
$schema->storage->txn_begin; |
| 243 |
|
270 |
|
| 244 |
my $librarian = $builder->build_object( |
271 |
my $librarian = $builder->build_object( |
| 245 |
{ |
272 |
{ |
| 246 |
class => 'Koha::Patrons', |
273 |
class => 'Koha::Patrons', |
| 247 |
value => { flags => 2**4 } # borrowers flag = 4 |
274 |
value => { flags => 2 ** 2 } # catalog only, no additional permissions |
| 248 |
} |
275 |
} |
| 249 |
); |
276 |
); |
|
|
277 |
|
| 278 |
# Ensure our librarian can see users from all branches (once list_borrowers is added) |
| 279 |
$builder->build( |
| 280 |
{ |
| 281 |
source => 'UserPermission', |
| 282 |
value => { |
| 283 |
borrowernumber => $librarian->borrowernumber, |
| 284 |
module_bit => 4, |
| 285 |
code => 'view_borrower_infos_from_any_libraries', |
| 286 |
}, |
| 287 |
} |
| 288 |
); |
| 289 |
|
| 250 |
my $password = 'thePassword123'; |
290 |
my $password = 'thePassword123'; |
| 251 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
291 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
| 252 |
my $userid = $librarian->userid; |
292 |
my $userid = $librarian->userid; |
| 253 |
|
293 |
|
| 254 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
294 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 255 |
|
295 |
|
| 256 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
296 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
| 257 |
->status_is(200) |
297 |
->status_is(403, 'Basic librarian unable to see patrons'); |
|
|
298 |
|
| 299 |
$builder->build( |
| 300 |
{ |
| 301 |
source => 'UserPermission', |
| 302 |
value => { |
| 303 |
borrowernumber => $librarian->borrowernumber, |
| 304 |
module_bit => 4, |
| 305 |
code => 'list_borrowers', |
| 306 |
}, |
| 307 |
} |
| 308 |
); |
| 309 |
|
| 310 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
| 311 |
->status_is(200, 'list_borrowers permission makes patron visible') |
| 258 |
->json_is('/patron_id' => $patron->id) |
312 |
->json_is('/patron_id' => $patron->id) |
| 259 |
->json_is('/category_id' => $patron->categorycode ) |
313 |
->json_is('/category_id' => $patron->categorycode ) |
| 260 |
->json_is('/surname' => $patron->surname) |
314 |
->json_is('/surname' => $patron->surname) |
| 261 |
- |
|
|