Lines 34-40
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
Link Here
|
34 |
|
34 |
|
35 |
subtest 'list_effective_rules() tests' => sub { |
35 |
subtest 'list_effective_rules() tests' => sub { |
36 |
|
36 |
|
37 |
plan tests => 26; |
37 |
plan tests => 32; |
38 |
|
38 |
|
39 |
$schema->storage->txn_begin; |
39 |
$schema->storage->txn_begin; |
40 |
|
40 |
|
Lines 140-158
subtest 'list_effective_rules() tests' => sub {
Link Here
|
140 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400) |
140 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400) |
141 |
->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] ); |
141 |
->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] ); |
142 |
|
142 |
|
|
|
143 |
# Make sure we have a non-existent library |
144 |
my $library_to_delete = $builder->build_object( { class => 'Koha::Libraries' } ); |
145 |
my $non_existent_library = $library_to_delete->branchcode; |
146 |
$library_to_delete->delete; |
147 |
|
143 |
# Warn on incorrect query parameter value |
148 |
# Warn on incorrect query parameter value |
144 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?library_id=SMITH")->status_is(400)->json_is( |
149 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?library_id=$non_existent_library")->status_is(400) |
|
|
150 |
->json_is( |
145 |
'' => { |
151 |
'' => { |
146 |
error => 'Invalid parameter value', |
152 |
error => 'Invalid parameter value', |
147 |
error_code => 'invalid_parameter_value', |
153 |
error_code => 'invalid_parameter_value', |
148 |
path => '/query/library', |
154 |
path => '/query/library_id', |
149 |
values => { |
155 |
values => { |
150 |
uri => '/api/v1/libraries', |
156 |
uri => '/api/v1/libraries', |
151 |
field => 'library_id' |
157 |
field => 'library_id' |
152 |
} |
158 |
} |
153 |
}, |
159 |
}, |
154 |
"Invalid parameter value handled correctly" |
160 |
"Invalid parameter value handled correctly" |
155 |
); |
161 |
); |
|
|
162 |
|
163 |
# Make sure we have a non-existent category |
164 |
my $category_to_delete = $builder->build_object( { class => 'Koha::Patron::Categories' } ); |
165 |
my $non_existent_category = $category_to_delete->categorycode; |
166 |
$category_to_delete->delete; |
167 |
|
168 |
# Warn on incorrect query parameter value |
169 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?patron_category_id=$non_existent_category") |
170 |
->status_is(400)->json_is( |
171 |
'' => { |
172 |
error => 'Invalid parameter value', |
173 |
error_code => 'invalid_parameter_value', |
174 |
path => '/query/patron_category_id', |
175 |
values => { |
176 |
uri => '/api/v1/patron_categories', |
177 |
field => 'patron_category_id' |
178 |
} |
179 |
}, |
180 |
"Invalid parameter value handled correctly" |
181 |
); |
182 |
|
183 |
# Make sure we have a non-existent itemtype |
184 |
my $itemtype_to_delete = $builder->build_object( { class => 'Koha::ItemTypes' } ); |
185 |
my $non_existent_itemtype = $itemtype_to_delete->itemtype; |
186 |
$itemtype_to_delete->delete; |
187 |
|
188 |
# Warn on incorrect query parameter value |
189 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?item_type_id=$non_existent_itemtype")->status_is(400) |
190 |
->json_is( |
191 |
'' => { |
192 |
error => 'Invalid parameter value', |
193 |
error_code => 'invalid_parameter_value', |
194 |
path => '/query/item_type_id', |
195 |
values => { |
196 |
uri => '/api/v1/item_types', |
197 |
field => 'item_type_id' |
198 |
} |
199 |
}, |
200 |
"Invalid parameter value handled correctly" |
201 |
); |
156 |
|
202 |
|
157 |
# Unauthorized access |
203 |
# Unauthorized access |
158 |
$t->get_ok("//$unauth_userid:$password@/api/v1/circulation_rules")->status_is(403); |
204 |
$t->get_ok("//$unauth_userid:$password@/api/v1/circulation_rules")->status_is(403); |