View | Details | Raw Unified | Return to bug 36641
Collapse All | Expand All

(-)a/Koha/REST/V1/CirculationRules.pm (-3 / +3 lines)
Lines 58-64 sub list_effective_rules { Link Here
58
        my $type = Koha::ItemTypes->find($item_type);
58
        my $type = Koha::ItemTypes->find($item_type);
59
        return $c->render_invalid_parameter_value(
59
        return $c->render_invalid_parameter_value(
60
            {
60
            {
61
                path   => '/query/item_type',
61
                path   => '/query/item_type_id',
62
                values => {
62
                values => {
63
                    uri   => '/api/v1/item_types',
63
                    uri   => '/api/v1/item_types',
64
                    field => 'item_type_id'
64
                    field => 'item_type_id'
Lines 71-77 sub list_effective_rules { Link Here
71
        my $library = Koha::Libraries->find($branchcode);
71
        my $library = Koha::Libraries->find($branchcode);
72
        return $c->render_invalid_parameter_value(
72
        return $c->render_invalid_parameter_value(
73
            {
73
            {
74
                path   => '/query/library',
74
                path   => '/query/library_id',
75
                values => {
75
                values => {
76
                    uri   => '/api/v1/libraries',
76
                    uri   => '/api/v1/libraries',
77
                    field => 'library_id'
77
                    field => 'library_id'
Lines 84-90 sub list_effective_rules { Link Here
84
        my $category = Koha::Patron::Categories->find($patron_category);
84
        my $category = Koha::Patron::Categories->find($patron_category);
85
        return $c->render_invalid_parameter_value(
85
        return $c->render_invalid_parameter_value(
86
            {
86
            {
87
                path   => '/query/patron_category',
87
                path   => '/query/patron_category_id',
88
                values => {
88
                values => {
89
                    uri   => '/api/v1/patron_categories',
89
                    uri   => '/api/v1/patron_categories',
90
                    field => 'patron_category_id'
90
                    field => 'patron_category_id'
(-)a/t/db_dependent/api/v1/circulation_rules.t (-4 / +50 lines)
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);
(-)a/t/db_dependent/api/v1/responses.t (-2 / +1 lines)
Lines 154-160 subtest 'render_invalid_parameter_value() tests' => sub { Link Here
154
154
155
    my $t = Test::Mojo->new('Koha::REST::V1');
155
    my $t = Test::Mojo->new('Koha::REST::V1');
156
156
157
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules?library=SOMETHING")->status_is('400')->json_is(
157
    $t->get_ok("//$userid:$password@/api/v1/circulation_rules?library_id=SOMETHING")->status_is('400')->json_is(
158
        {
158
        {
159
            error      => 'Invalid parameter value',
159
            error      => 'Invalid parameter value',
160
            error_code => 'invalid_parameter_value',
160
            error_code => 'invalid_parameter_value',
161
- 

Return to bug 36641