Bugzilla – Attachment 158013 Details for
Bug 29523
Add a way to prevent embedding objects that should not be allowed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29523: Fix tests
Bug-29523-Fix-tests.patch (text/plain), 7.62 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-10-28 12:48:34 UTC
(
hide
)
Description:
Bug 29523: Fix tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-10-28 12:48:34 UTC
Size:
7.62 KB
patch
obsolete
>From 9f98be593a8bfe32ff17adeb9a9c050540b3dc96 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Sat, 28 Oct 2023 09:45:34 -0300 >Subject: [PATCH] Bug 29523: Fix tests > >Some tests compare things to the output of `->to_api` and are exploding >because the (now mandatory) `user` parameter is not passed in the call. > >In the case of IdP.t I just got rid of the use of `to_api` as we are >just trying to acknowledge a new user has been created and the API >representation of it is irrelevant. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Auth/Client.t | 5 ++- > t/db_dependent/Koha/REST/Plugin/Auth/IdP.t | 2 +- > t/db_dependent/api/v1/erm_users.t | 4 +- > t/db_dependent/api/v1/ill_requests.t | 45 ++++++++++++---------- > 4 files changed, 31 insertions(+), 25 deletions(-) > >diff --git a/t/db_dependent/Koha/Auth/Client.t b/t/db_dependent/Koha/Auth/Client.t >index 7f97e8295c8..149aaa48185 100755 >--- a/t/db_dependent/Koha/Auth/Client.t >+++ b/t/db_dependent/Koha/Auth/Client.t >@@ -69,7 +69,10 @@ subtest 'get_user() tests' => sub { > my $data = { id_token => $id_token }; > > my ( $resolved_patron, $mapped_data, $resolved_domain ) = $client->get_user( { provider => $provider->code, data => $data, interface => 'opac' } ); >- is_deeply( $resolved_patron->to_api, $patron->to_api, 'Patron correctly retrieved' ); >+ is_deeply( >+ $resolved_patron->to_api( { user => $patron } ), $patron->to_api( { user => $patron } ), >+ 'Patron correctly retrieved' >+ ); > is( $mapped_data->{firstname}, 'test name', 'Data mapped correctly' ); > is( $mapped_data->{surname}, undef, 'No surname mapped' ); > is( $domain->identity_provider_domain_id, $resolved_domain->identity_provider_domain_id, 'Is the same domain' ); >diff --git a/t/db_dependent/Koha/REST/Plugin/Auth/IdP.t b/t/db_dependent/Koha/REST/Plugin/Auth/IdP.t >index d3579cf9c1c..48325367ade 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Auth/IdP.t >+++ b/t/db_dependent/Koha/REST/Plugin/Auth/IdP.t >@@ -40,7 +40,7 @@ post '/register_user' => sub { > interface => $params->{interface} > } > ); >- $c->render( status => 200, json => $patron->to_api ); >+ $c->render( status => 200, json => $patron->unblessed ); > } catch { > if ( ref($_) eq 'Koha::Exceptions::Auth::Unauthorized' ) { > $c->render( status => 401, json => { message => 'unauthorized' } ); >diff --git a/t/db_dependent/api/v1/erm_users.t b/t/db_dependent/api/v1/erm_users.t >index fff58cbe9dd..379db6562f6 100755 >--- a/t/db_dependent/api/v1/erm_users.t >+++ b/t/db_dependent/api/v1/erm_users.t >@@ -56,7 +56,7 @@ subtest 'list() tests' => sub { > # One erm_user created, should get returned > $librarian->discard_changes; > $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200) >- ->json_is( [ $librarian->to_api ] ); >+ ->json_is( [ $librarian->to_api( { user => $librarian } ) ] ); > > my $another_erm_user = $builder->build_object( > { >@@ -67,7 +67,7 @@ subtest 'list() tests' => sub { > > # Two erm_users created, they should both be returned > $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200) >- ->json_is( [ $librarian->to_api ] ); >+ ->json_is( [ $librarian->to_api( { user => $librarian } ) ] ); > > # Warn on unsupported query parameter > $t->get_ok("//$userid:$password@/api/v1/erm/users?blah=blah") >diff --git a/t/db_dependent/api/v1/ill_requests.t b/t/db_dependent/api/v1/ill_requests.t >index 0769766778d..3e7bb9d681f 100755 >--- a/t/db_dependent/api/v1/ill_requests.t >+++ b/t/db_dependent/api/v1/ill_requests.t >@@ -169,7 +169,7 @@ subtest 'list() tests' => sub { > # Three requests exist, expect all three to be returned > $t->get_ok("//$userid:$password@/api/v1/ill/requests") > ->status_is(200) >- ->json_is( [ $req_1->to_api, $req_2->to_api, $ret->to_api ]); >+ ->json_is( [ $req_1->to_api({user=> $librarian}), $req_2->to_api({user=> $librarian}), $ret->to_api({user=> $librarian}) ]); > > my $status_query = encode_json({ status => 'REQ' }); > my $status_alias_query = encode_json({ status_av => $av_code }); >@@ -177,29 +177,34 @@ subtest 'list() tests' => sub { > # x-koha-embed: +strings > # Two requests exist with status 'REQ', expect them to be returned > # One of which also has a status_alias, expect that to be in that request's body >- $t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_query" => {"x-koha-embed" => "+strings"} ) >- ->status_is(200) >- ->json_is( [ >- { _strings => { status => $response_status }, %{$req_1->to_api} }, >- { _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} } >- ] >+ $t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_query" => { "x-koha-embed" => "+strings" } ) >+ ->status_is(200)->json_is( >+ [ >+ { _strings => { status => $response_status }, %{ $req_1->to_api( { user => $librarian } ) } }, >+ { >+ _strings => { status => $response_status, status_av => $response_status_av }, >+ %{ $req_2->to_api( { user => $librarian } ) } >+ } >+ ] > ); > > # One request with status_alias 'print_copy' exists, expect that to be returned >- $t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => {"x-koha-embed" => "+strings"} ) >- ->status_is(200) >- ->json_is( [ >- { _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} } >- ] >+ $t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => { "x-koha-embed" => "+strings" } ) >+ ->status_is(200)->json_is( >+ [ >+ { >+ _strings => { status => $response_status, status_av => $response_status_av }, >+ %{ $req_2->to_api( { user => $librarian } ) } >+ } >+ ] > ); > > # x-koha-embed: patron > my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber }); > > # One request related to $patron, make sure it comes back >- $t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "patron"} ) >- ->status_is(200) >- ->json_has('/0/patron', $patron->to_api); >+ $t->get_ok( "//$userid:$password@/api/v1/ill/requests" => { "x-koha-embed" => "patron" } )->status_is(200) >+ ->json_has( '/0/patron', $patron->to_api( { user => $librarian } ) ); > > # x-koha-embed: comments > # Create comment >@@ -226,15 +231,13 @@ subtest 'list() tests' => sub { > # ILLHiddenRequestStatuses syspref > # Hide 'REQ', expect to return just 1 'RET' > t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' ); >- $t->get_ok( "//$userid:$password@/api/v1/ill/requests" ) >- ->status_is(200) >- ->json_is( [ $ret->to_api ] ); >+ $t->get_ok("//$userid:$password@/api/v1/ill/requests")->status_is(200) >+ ->json_is( [ $ret->to_api( { user => $librarian } ) ] ); > > # Hide 'RET', expect to return 2 'REQ' > t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' ); >- $t->get_ok( "//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes" ) >- ->status_is(200) >- ->json_is( [ $req_1->to_api, $req_2->to_api ]); >+ $t->get_ok("//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes")->status_is(200) >+ ->json_is( [ $req_1->to_api( { user => $librarian } ), $req_2->to_api( { user => $librarian } ) ] ); > > # Status code > # Warn on unsupported query parameter >-- >2.42.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29523
:
127886
|
127887
|
127888
|
127889
|
127991
|
127992
|
127993
|
127994
|
128042
|
128043
|
128044
|
128045
|
128046
|
128047
|
128048
|
128688
|
128689
|
128690
|
128691
|
128692
|
128693
|
128694
|
131326
|
131331
|
131332
|
136684
|
136685
|
136686
|
136687
|
136688
|
136689
|
136690
|
136691
|
136692
|
136706
|
136714
|
148736
|
148737
|
148738
|
148739
|
148740
|
148741
|
148742
|
148743
|
148744
|
148745
|
150989
|
150990
|
150991
|
150992
|
150993
|
150994
|
150995
|
150996
|
150997
|
150998
|
156939
|
156940
|
156941
|
156942
|
156943
|
156944
|
156945
|
156946
|
156947
|
156948
|
156949
|
156965
|
157049
|
157071
|
157072
|
157073
|
157074
|
157075
|
157076
|
157077
|
157078
|
157079
|
157080
|
157081
|
157406
|
157407
|
157408
|
157409
|
157410
|
157411
|
157412
|
157413
|
157414
|
157415
|
157416
|
157673
|
157679
|
157683
|
157799
|
157881
|
157882
|
157883
|
157884
|
157885
|
157886
|
157887
|
157888
|
157889
|
157890
|
157891
|
157892
|
157893
| 158013