Lines 1141-1147
subtest 'delete() tests' => sub {
Link Here
|
1141 |
|
1141 |
|
1142 |
subtest 'guarantors_can_see_charges() tests' => sub { |
1142 |
subtest 'guarantors_can_see_charges() tests' => sub { |
1143 |
|
1143 |
|
1144 |
plan tests => 11; |
1144 |
plan tests => 17; |
1145 |
|
1145 |
|
1146 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
1146 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
1147 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
1147 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
Lines 1149-1154
subtest 'guarantors_can_see_charges() tests' => sub {
Link Here
|
1149 |
$schema->storage->txn_begin; |
1149 |
$schema->storage->txn_begin; |
1150 |
|
1150 |
|
1151 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { privacy_guarantor_fines => 0 } }); |
1151 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { privacy_guarantor_fines => 0 } }); |
|
|
1152 |
my $other_patron_id = $builder->build_object( { class => 'Koha::Patrons' } )->borrowernumber; |
1152 |
my $password = 'thePassword123'; |
1153 |
my $password = 'thePassword123'; |
1153 |
$patron->set_password({ password => $password, skip_validation => 1 }); |
1154 |
$patron->set_password({ password => $password, skip_validation => 1 }); |
1154 |
my $userid = $patron->userid; |
1155 |
my $userid = $patron->userid; |
Lines 1156-1161
subtest 'guarantors_can_see_charges() tests' => sub {
Link Here
|
1156 |
|
1157 |
|
1157 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetFinesVisibilityForGuarantor', 0 ); |
1158 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetFinesVisibilityForGuarantor', 0 ); |
1158 |
|
1159 |
|
|
|
1160 |
$t->put_ok( |
1161 |
"/api/v1/public/patrons/$other_patron_id/guarantors/can_see_charges" => json => { allowed => Mojo::JSON->true } |
1162 |
)->status_is(401)->json_is( { error => "Authentication failure." } ); |
1163 |
|
1164 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_charges" => json => |
1165 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
1166 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
1167 |
|
1159 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_charges" => json => { allowed => Mojo::JSON->true } ) |
1168 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_charges" => json => { allowed => Mojo::JSON->true } ) |
1160 |
->status_is( 403 ) |
1169 |
->status_is( 403 ) |
1161 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
1170 |
->json_is( '/error', 'The current configuration doesn\'t allow the requested action.' ); |
Lines 1179-1185
subtest 'guarantors_can_see_charges() tests' => sub {
Link Here
|
1179 |
|
1188 |
|
1180 |
subtest 'guarantors_can_see_checkouts() tests' => sub { |
1189 |
subtest 'guarantors_can_see_checkouts() tests' => sub { |
1181 |
|
1190 |
|
1182 |
plan tests => 11; |
1191 |
plan tests => 17; |
1183 |
|
1192 |
|
1184 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
1193 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
1185 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
1194 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
Lines 1187-1197
subtest 'guarantors_can_see_checkouts() tests' => sub {
Link Here
|
1187 |
$schema->storage->txn_begin; |
1196 |
$schema->storage->txn_begin; |
1188 |
|
1197 |
|
1189 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { privacy_guarantor_checkouts => 0 } }); |
1198 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { privacy_guarantor_checkouts => 0 } }); |
|
|
1199 |
my $other_patron_id = $builder->build_object( { class => 'Koha::Patrons' } )->borrowernumber; |
1190 |
my $password = 'thePassword123'; |
1200 |
my $password = 'thePassword123'; |
1191 |
$patron->set_password({ password => $password, skip_validation => 1 }); |
1201 |
$patron->set_password({ password => $password, skip_validation => 1 }); |
1192 |
my $userid = $patron->userid; |
1202 |
my $userid = $patron->userid; |
1193 |
my $patron_id = $patron->borrowernumber; |
1203 |
my $patron_id = $patron->borrowernumber; |
1194 |
|
1204 |
|
|
|
1205 |
$t->put_ok( "/api/v1/public/patrons/$other_patron_id/guarantors/can_see_checkouts" => json => |
1206 |
{ allowed => Mojo::JSON->true } )->status_is(401)->json_is( { error => "Authentication failure." } ); |
1207 |
|
1208 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$other_patron_id/guarantors/can_see_checkouts" => json => |
1209 |
{ allowed => Mojo::JSON->true } )->status_is(403) |
1210 |
->json_is( { error => "Unprivileged user cannot access another user's resources" } ); |
1211 |
|
1195 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 0 ); |
1212 |
t::lib::Mocks::mock_preference( 'AllowPatronToSetCheckoutsVisibilityForGuarantor', 0 ); |
1196 |
|
1213 |
|
1197 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_checkouts" => json => { allowed => Mojo::JSON->true } ) |
1214 |
$t->put_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/guarantors/can_see_checkouts" => json => { allowed => Mojo::JSON->true } ) |
1198 |
- |
|
|