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 => 0 } # no additional permissions |
92 |
} |
92 |
} |
93 |
); |
93 |
); |
94 |
my $password = 'thePassword123'; |
94 |
my $password = 'thePassword123'; |
95 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
95 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
96 |
my $userid = $librarian->userid; |
96 |
my $userid = $librarian->userid; |
97 |
|
97 |
|
|
|
98 |
$t->get_ok("//$userid:$password@/api/v1/patrons/") |
99 |
->status_is(403, 'Basic librarian unable to see patrons'); |
100 |
|
101 |
$builder->build( |
102 |
{ |
103 |
source => 'UserPermission', |
104 |
value => { |
105 |
borrowernumber => $librarian->borrowernumber, |
106 |
module_bit => 4, |
107 |
code => 'list_borrowers', |
108 |
}, |
109 |
} |
110 |
); |
111 |
|
98 |
$t->get_ok("//$userid:$password@/api/v1/patrons") |
112 |
$t->get_ok("//$userid:$password@/api/v1/patrons") |
99 |
->status_is(200); |
113 |
->status_is(200, 'list_borrowers makes /patrons accessible'); |
100 |
|
114 |
|
101 |
$t->get_ok("//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber) |
115 |
$t->get_ok("//$userid:$password@/api/v1/patrons?cardnumber=" . $librarian->cardnumber) |
102 |
->status_is(200) |
116 |
->status_is(200) |
Lines 237-260
subtest 'get() tests' => sub {
Link Here
|
237 |
$schema->storage->txn_rollback; |
251 |
$schema->storage->txn_rollback; |
238 |
|
252 |
|
239 |
subtest 'librarian access tests' => sub { |
253 |
subtest 'librarian access tests' => sub { |
240 |
plan tests => 6; |
254 |
plan tests => 8; |
241 |
|
255 |
|
242 |
$schema->storage->txn_begin; |
256 |
$schema->storage->txn_begin; |
243 |
|
257 |
|
244 |
my $librarian = $builder->build_object( |
258 |
my $basic_librarian = $builder->build_object( |
245 |
{ |
259 |
{ |
246 |
class => 'Koha::Patrons', |
260 |
class => 'Koha::Patrons', |
247 |
value => { flags => 2**4 } # borrowers flag = 4 |
261 |
value => { flags => 0 } # no additional permissions |
248 |
} |
262 |
} |
249 |
); |
263 |
); |
250 |
my $password = 'thePassword123'; |
264 |
my $password = 'thePassword123'; |
251 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
265 |
$basic_librarian->set_password( { password => $password, skip_validation => 1 } ); |
252 |
my $userid = $librarian->userid; |
266 |
my $userid = $basic_librarian->userid; |
253 |
|
267 |
|
254 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
268 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
255 |
|
269 |
|
256 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
270 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
257 |
->status_is(200) |
271 |
->status_is(403, 'Basic librarian unable to see patrons'); |
|
|
272 |
|
273 |
$builder->build( |
274 |
{ |
275 |
source => 'UserPermission', |
276 |
value => { |
277 |
borrowernumber => $basic_librarian->borrowernumber, |
278 |
module_bit => 4, |
279 |
code => 'list_borrowers', |
280 |
}, |
281 |
} |
282 |
); |
283 |
|
284 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id) |
285 |
->status_is(200, 'list_borrowers permission makes patron visible') |
258 |
->json_is('/patron_id' => $patron->id) |
286 |
->json_is('/patron_id' => $patron->id) |
259 |
->json_is('/category_id' => $patron->categorycode ) |
287 |
->json_is('/category_id' => $patron->categorycode ) |
260 |
->json_is('/surname' => $patron->surname) |
288 |
->json_is('/surname' => $patron->surname) |
261 |
- |
|
|