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

(-)a/t/db_dependent/Koha/Auth/Client.t (-1 / +4 lines)
Lines 69-75 subtest 'get_user() tests' => sub { Link Here
69
    my $data = { id_token => $id_token };
69
    my $data = { id_token => $id_token };
70
70
71
    my ( $resolved_patron, $mapped_data, $resolved_domain ) = $client->get_user( { provider => $provider->code, data => $data, interface => 'opac' } );
71
    my ( $resolved_patron, $mapped_data, $resolved_domain ) = $client->get_user( { provider => $provider->code, data => $data, interface => 'opac' } );
72
    is_deeply( $resolved_patron->to_api, $patron->to_api, 'Patron correctly retrieved' );
72
    is_deeply(
73
        $resolved_patron->to_api( { user => $patron } ), $patron->to_api( { user => $patron } ),
74
        'Patron correctly retrieved'
75
    );
73
    is( $mapped_data->{firstname},            'test name',                                   'Data mapped correctly' );
76
    is( $mapped_data->{firstname},            'test name',                                   'Data mapped correctly' );
74
    is( $mapped_data->{surname},              undef,                                         'No surname mapped' );
77
    is( $mapped_data->{surname},              undef,                                         'No surname mapped' );
75
    is( $domain->identity_provider_domain_id, $resolved_domain->identity_provider_domain_id, 'Is the same domain' );
78
    is( $domain->identity_provider_domain_id, $resolved_domain->identity_provider_domain_id, 'Is the same domain' );
(-)a/t/db_dependent/Koha/REST/Plugin/Auth/IdP.t (-1 / +1 lines)
Lines 40-46 post '/register_user' => sub { Link Here
40
                interface => $params->{interface}
40
                interface => $params->{interface}
41
            }
41
            }
42
        );
42
        );
43
        $c->render( status => 200, json => $patron->to_api );
43
        $c->render( status => 200, json => $patron->unblessed );
44
    } catch {
44
    } catch {
45
        if ( ref($_) eq 'Koha::Exceptions::Auth::Unauthorized' ) {
45
        if ( ref($_) eq 'Koha::Exceptions::Auth::Unauthorized' ) {
46
            $c->render( status => 401, json => { message => 'unauthorized' } );
46
            $c->render( status => 401, json => { message => 'unauthorized' } );
(-)a/t/db_dependent/api/v1/erm_users.t (-2 / +2 lines)
Lines 56-62 subtest 'list() tests' => sub { Link Here
56
    # One erm_user created, should get returned
56
    # One erm_user created, should get returned
57
    $librarian->discard_changes;
57
    $librarian->discard_changes;
58
    $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
58
    $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
59
      ->json_is( [ $librarian->to_api ] );
59
        ->json_is( [ $librarian->to_api( { user => $librarian } ) ] );
60
60
61
    my $another_erm_user = $builder->build_object(
61
    my $another_erm_user = $builder->build_object(
62
        {
62
        {
Lines 67-73 subtest 'list() tests' => sub { Link Here
67
67
68
    # Two erm_users created, they should both be returned
68
    # Two erm_users created, they should both be returned
69
    $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
69
    $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
70
      ->json_is( [ $librarian->to_api ] );
70
        ->json_is( [ $librarian->to_api( { user => $librarian } ) ] );
71
71
72
    # Warn on unsupported query parameter
72
    # Warn on unsupported query parameter
73
    $t->get_ok("//$userid:$password@/api/v1/erm/users?blah=blah")
73
    $t->get_ok("//$userid:$password@/api/v1/erm/users?blah=blah")
(-)a/t/db_dependent/api/v1/ill_requests.t (-22 / +24 lines)
Lines 169-175 subtest 'list() tests' => sub { Link Here
169
    # Three requests exist, expect all three to be returned
169
    # Three requests exist, expect all three to be returned
170
    $t->get_ok("//$userid:$password@/api/v1/ill/requests")
170
    $t->get_ok("//$userid:$password@/api/v1/ill/requests")
171
      ->status_is(200)
171
      ->status_is(200)
172
      ->json_is( [ $req_1->to_api, $req_2->to_api, $ret->to_api ]);
172
      ->json_is( [ $req_1->to_api({user=> $librarian}), $req_2->to_api({user=> $librarian}), $ret->to_api({user=> $librarian}) ]);
173
173
174
    my $status_query = encode_json({ status => 'REQ' });
174
    my $status_query = encode_json({ status => 'REQ' });
175
    my $status_alias_query = encode_json({ status_av => $av_code });
175
    my $status_alias_query = encode_json({ status_av => $av_code });
Lines 177-205 subtest 'list() tests' => sub { Link Here
177
    # x-koha-embed: +strings
177
    # x-koha-embed: +strings
178
    # Two requests exist with status 'REQ', expect them to be returned
178
    # Two requests exist with status 'REQ', expect them to be returned
179
    # One of which also has a status_alias, expect that to be in that request's body
179
    # One of which also has a status_alias, expect that to be in that request's body
180
    $t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_query" => {"x-koha-embed" => "+strings"} )
180
    $t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_query" => { "x-koha-embed" => "+strings" } )
181
      ->status_is(200)
181
        ->status_is(200)->json_is(
182
      ->json_is( [
182
        [
183
                { _strings => { status => $response_status }, %{$req_1->to_api} },
183
            { _strings => { status => $response_status }, %{ $req_1->to_api( { user => $librarian } ) } },
184
                { _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} }
184
            {
185
            ]
185
                _strings => { status => $response_status, status_av => $response_status_av },
186
                %{ $req_2->to_api( { user => $librarian } ) }
187
            }
188
        ]
186
        );
189
        );
187
190
188
    # One request with status_alias 'print_copy' exists, expect that to be returned
191
    # One request with status_alias 'print_copy' exists, expect that to be returned
189
    $t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => {"x-koha-embed" => "+strings"} )
192
    $t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => { "x-koha-embed" => "+strings" } )
190
      ->status_is(200)
193
        ->status_is(200)->json_is(
191
      ->json_is( [
194
        [
192
                { _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} }
195
            {
193
            ]
196
                _strings => { status => $response_status, status_av => $response_status_av },
197
                %{ $req_2->to_api( { user => $librarian } ) }
198
            }
199
        ]
194
        );
200
        );
195
201
196
    # x-koha-embed: patron
202
    # x-koha-embed: patron
197
    my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber });
203
    my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber });
198
204
199
    # One request related to $patron, make sure it comes back
205
    # One request related to $patron, make sure it comes back
200
    $t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "patron"} )
206
    $t->get_ok( "//$userid:$password@/api/v1/ill/requests" => { "x-koha-embed" => "patron" } )->status_is(200)
201
      ->status_is(200)
207
        ->json_has( '/0/patron', $patron->to_api( { user => $librarian } ) );
202
      ->json_has('/0/patron', $patron->to_api);
203
208
204
    # x-koha-embed: comments
209
    # x-koha-embed: comments
205
    # Create comment
210
    # Create comment
Lines 226-240 subtest 'list() tests' => sub { Link Here
226
    # ILLHiddenRequestStatuses syspref
231
    # ILLHiddenRequestStatuses syspref
227
    # Hide 'REQ', expect to return just 1 'RET'
232
    # Hide 'REQ', expect to return just 1 'RET'
228
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' );
233
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' );
229
    $t->get_ok( "//$userid:$password@/api/v1/ill/requests" )
234
    $t->get_ok("//$userid:$password@/api/v1/ill/requests")->status_is(200)
230
      ->status_is(200)
235
        ->json_is( [ $ret->to_api( { user => $librarian } ) ] );
231
      ->json_is( [ $ret->to_api ] );
232
236
233
    # Hide 'RET', expect to return 2 'REQ'
237
    # Hide 'RET', expect to return 2 'REQ'
234
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' );
238
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' );
235
    $t->get_ok( "//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes" )
239
    $t->get_ok("//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes")->status_is(200)
236
      ->status_is(200)
240
        ->json_is( [ $req_1->to_api( { user => $librarian } ), $req_2->to_api( { user => $librarian } ) ] );
237
      ->json_is( [ $req_1->to_api, $req_2->to_api ]);
238
241
239
    # Status code
242
    # Status code
240
    # Warn on unsupported query parameter
243
    # Warn on unsupported query parameter
241
- 

Return to bug 29523