Bugzilla – Attachment 153501 Details for
Bug 30979
Add ability for OPAC users to checkout to themselves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30979: (QA follow-up) Tidy things
Bug-30979-QA-follow-up-Tidy-things.patch (text/plain), 14.71 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-07-14 19:33:14 UTC
(
hide
)
Description:
Bug 30979: (QA follow-up) Tidy things
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-07-14 19:33:14 UTC
Size:
14.71 KB
patch
obsolete
>From 0a0b1eb68bdff791060f3f9daa404bd102aa2910 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 14 Jul 2023 10:07:20 -0300 >Subject: [PATCH] Bug 30979: (QA follow-up) Tidy things > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../data/mysql/atomicupdate/bug_30979.pl | 4 +- > t/db_dependent/api/v1/checkouts.t | 173 +++++++----------- > 2 files changed, 65 insertions(+), 112 deletions(-) > mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug_30979.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_30979.pl b/installer/data/mysql/atomicupdate/bug_30979.pl >old mode 100644 >new mode 100755 >index cb5b6ce0fbe..6e11f9186e9 >--- a/installer/data/mysql/atomicupdate/bug_30979.pl >+++ b/installer/data/mysql/atomicupdate/bug_30979.pl >@@ -9,8 +9,8 @@ return { > $dbh->do( > q{ > INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >- ('OpacTrustedCheckout', '0', NULL, 'Allow logged in OPAC users to check out to themselves', 'YesNo') >- } >+ ('OpacTrustedCheckout', '0', NULL, 'Allow logged in OPAC users to check out to themselves', 'YesNo') >+ } > ); > }, > }; >diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t >index d73113c827a..1d83f8916bf 100755 >--- a/t/db_dependent/api/v1/checkouts.t >+++ b/t/db_dependent/api/v1/checkouts.t >@@ -264,8 +264,7 @@ subtest 'get_availability' => sub { > } > ); > my $unauth_password = 'thePassword000'; >- $patron->set_password( >- { password => $unauth_password, skip_validattion => 1 } ); >+ $patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); > my $unauth_userid = $patron->userid; > my $patron_id = $patron->borrowernumber; > >@@ -278,7 +277,7 @@ subtest 'get_availability' => sub { > my %needsconfirmation = (); > my %alerts = (); > my %messages = (); >- my $mocked_circ = Test::MockModule->new('C4::Circulation'); >+ my $mocked_circ = Test::MockModule->new('C4::Circulation'); > $mocked_circ->mock( > 'CanBookBeIssued', > sub { >@@ -287,60 +286,48 @@ subtest 'get_availability' => sub { > ); > > $t->get_ok( >-"//$unauth_userid:$unauth_password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(403)->json_is( >+ "//$unauth_userid:$unauth_password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id") >+ ->status_is(403)->json_is( > { >- error => "Authorization failure. Missing required permission(s).", >- required_permissions => >- { circulate => "circulate_remaining_permissions" } >+ error => "Authorization failure. Missing required permission(s).", >+ required_permissions => { circulate => "circulate_remaining_permissions" } > } >- ); >+ ); > > # Available >- $t->get_ok( >-"//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => {} ) >- ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >- ->json_has( '/confirmation_token'); >+ $t->get_ok("//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id") >+ ->status_is(200)->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >+ ->json_has('/confirmation_token'); > > # Blocked > %issuingimpossible = ( GNA => 1 ); >- $t->get_ok( >-"//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => { GNA => 1 } ) >- ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >- ->json_has( '/confirmation_token'); >+ $t->get_ok("//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id") >+ ->status_is(200)->json_is( '/blockers' => { GNA => 1 } )->json_is( '/confirms' => {} ) >+ ->json_is( '/warnings' => {} )->json_has('/confirmation_token'); > %issuingimpossible = (); > > # Warnings/Info > %alerts = ( alert1 => "this is an alert" ); > %messages = ( message1 => "this is a message" ); >- $t->get_ok( >-"//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => {} ) >- ->json_is( '/confirms' => {} ) >- ->json_is( '/warnings' => >- { alert1 => "this is an alert", message1 => "this is a message" } ) >- ->json_has( '/confirmation_token'); >+ $t->get_ok("//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id") >+ ->status_is(200)->json_is( '/blockers' => {} )->json_is( '/confirms' => {} ) >+ ->json_is( '/warnings' => { alert1 => "this is an alert", message1 => "this is a message" } ) >+ ->json_has('/confirmation_token'); > %alerts = (); > %messages = (); > > # Needs confirm > %needsconfirmation = ( confirm1 => 1, confirm2 => 'please' ); >- my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" }); >- $t->get_ok( >-"//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => {} ) >- ->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } ) >- ->json_is( '/warnings' => {} ) >- ->json_has( '/confirmation_token'); >+ my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" } ); >+ $t->get_ok("//$userid:$password@/api/v1/checkouts/availability?item_id=$item1_id&patron_id=$patron_id") >+ ->status_is(200)->json_is( '/blockers' => {} ) >+ ->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } )->json_is( '/warnings' => {} ) >+ ->json_has('/confirmation_token'); > my $confirmation_token = $t->tx->res->json('/confirmation_token'); > ok( > Koha::Token->new->check_jwt( > { >- id => $librarian->id . ":" >- . $item1_id >- . ":confirm1:confirm2", >+ id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2", > token => $confirmation_token > } > ), >@@ -352,20 +339,15 @@ subtest 'get_availability' => sub { > plan tests => 18; > > # Available, Not authentication required >- $t->get_ok( >-"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => {} ) >- ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >- ->json_has('/confirmation_token'); >+ $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200) >+ ->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >+ ->json_has('/confirmation_token'); > > # Needs confirmation upgrade to blocker > %needsconfirmation = ( TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 ); >- $t->get_ok( >-"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200) >- ->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } ) >- ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >- ->json_has('/confirmation_token'); >+ $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200) >+ ->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } )->json_is( '/confirms' => {} ) >+ ->json_is( '/warnings' => {} )->json_has('/confirmation_token'); > %needsconfirmation = (); > > # Remove personal information from public endpoint >@@ -412,11 +394,9 @@ subtest 'get_availability' => sub { > ressurname => 'private', > item_notforloan => 'private' > ); >- $t->get_ok( >-"/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id" >- )->status_is(200)->json_is( '/blockers' => {} ) >- ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >- ->json_has('/confirmation_token'); >+ $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200) >+ ->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} ) >+ ->json_has('/confirmation_token'); > %issuingimpossible = (); > %alerts = (); > %needsconfirmation = (); >@@ -447,8 +427,7 @@ subtest 'add checkout' => sub { > } > ); > my $unauth_password = 'thePassword000'; >- $patron->set_password( >- { password => $unauth_password, skip_validattion => 1 } ); >+ $patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); > my $unauth_userid = $patron->userid; > my $patron_id = $patron->borrowernumber; > >@@ -461,7 +440,7 @@ subtest 'add checkout' => sub { > my %needsconfirmation = (); > my %alerts = (); > my %messages = (); >- my $mocked_circ = Test::MockModule->new('C4::Circulation'); >+ my $mocked_circ = Test::MockModule->new('C4::Circulation'); > $mocked_circ->mock( > 'CanBookBeIssued', > sub { >@@ -469,95 +448,69 @@ subtest 'add checkout' => sub { > } > ); > >- $t->post_ok( >- "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => >- { item_id => $item1_id, patron_id => $patron_id } )->status_is(403) >- ->json_is( >+ $t->post_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => >+ { item_id => $item1_id, patron_id => $patron_id } )->status_is(403)->json_is( > { >- error => "Authorization failure. Missing required permission(s).", >- required_permissions => >- { circulate => "circulate_remaining_permissions" } >+ error => "Authorization failure. Missing required permission(s).", >+ required_permissions => { circulate => "circulate_remaining_permissions" } > } >- ); >+ ); > >- $t->post_ok( "//$userid:$password@/api/v1/checkouts" => json => >- { item_id => $item1_id, patron_id => $patron_id } )->status_is(201); >+ $t->post_ok( "//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, patron_id => $patron_id } ) >+ ->status_is(201); > > # Needs confirm > %needsconfirmation = ( confirm1 => 1, confirm2 => 'please' ); > $t->post_ok( > "//$userid:$password@/api/v1/checkouts" => json => { >- item_id => $item1_id, >- patron_id => $patron_id, >+ item_id => $item1_id, >+ patron_id => $patron_id, > } > )->status_is(412); > >- my $token = Koha::Token->new->generate_jwt( >- { >- id => $librarian->id . ":" >- . $item1_id >- . ":confirm1:confirm2" >- } >- ); >+ my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" } ); > $t->post_ok( > "//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => { >- item_id => $item1_id, >- patron_id => $patron_id >+ item_id => $item1_id, >+ patron_id => $patron_id > } >- )->status_is(201)->or(sub { diag $t->tx->res->body }); >+ )->status_is(201)->or( sub { diag $t->tx->res->body } ); > %needsconfirmation = (); > > subtest 'public add' => sub { > plan tests => 14; > > my $useridp = $patron->userid; >- $patron->set_password( >- { password => $password, skip_validation => 1 } ); >+ $patron->set_password( { password => $password, skip_validation => 1 } ); > > # Feature disabled > t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 0 ); > >- $t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => >- { item_id => $item1_id, patron_id => $patron_id } ) >- ->status_is(401)->json_is( >- { >- error => "Authentication failure." >- } >- ); >- > $t->post_ok( >- "//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" >- => json => { item_id => $item1_id, patron_id => $patron_id } ) >- ->status_is(405) >- ->json_is( >- { error => "Feature disabled", error_code => "FEATURE_DISABLED" } ); >+ "/api/v1/public/patrons/$patron_id/checkouts" => json => { item_id => $item1_id, patron_id => $patron_id } ) >+ ->status_is(401)->json_is( { error => "Authentication failure." } ); >+ >+ $t->post_ok( "//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" => json => >+ { item_id => $item1_id, patron_id => $patron_id } )->status_is(405) >+ ->json_is( { error => "Feature disabled", error_code => "FEATURE_DISABLED" } ); > > # Feature enabled > t::lib::Mocks::mock_preference( 'OpacTrustedCheckout', 1 ); > >- $t->post_ok( "/api/v1/public/patrons/$patron_id/checkouts" => json => >- { item_id => $item1_id, patron_id => $patron_id } ) >- ->status_is(401)->json_is( >- { >- error => "Authentication failure." >- } >- ); >- > $t->post_ok( >- "//$userid:$password@/api/v1/public/patrons/$patron_id/checkouts" >- => json => { item_id => $item1_id, patron_id => $patron_id } ) >- ->status_is(403)->json_is( >+ "/api/v1/public/patrons/$patron_id/checkouts" => json => { item_id => $item1_id, patron_id => $patron_id } ) >+ ->status_is(401)->json_is( { error => "Authentication failure." } ); >+ >+ $t->post_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/checkouts" => json => >+ { item_id => $item1_id, patron_id => $patron_id } )->status_is(403)->json_is( > { >- error => >- "Authorization failure. Missing required permission(s).", >+ error => "Authorization failure. Missing required permission(s).", > required_permissions => undef > } >- ); >+ ); > >- $t->post_ok( >- "//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" >- => json => { item_id => $item1_id, patron_id => $patron_id } ) >- ->status_is(201); >+ $t->post_ok( "//$useridp:$password@/api/v1/public/patrons/$patron_id/checkouts" => json => >+ { item_id => $item1_id, patron_id => $patron_id } )->status_is(201); > }; > > $schema->storage->txn_rollback; >-- >2.41.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 30979
:
139131
|
139132
|
139133
|
139134
|
141274
|
141275
|
141276
|
141277
|
141278
|
141279
|
141300
|
145264
|
145265
|
145266
|
145267
|
145268
|
145277
|
145280
|
145281
|
145282
|
145283
|
145284
|
145285
|
145620
|
145621
|
145622
|
145623
|
145624
|
145625
|
145626
|
145627
|
145628
|
145629
|
145630
|
150867
|
150868
|
150869
|
150870
|
150871
|
150872
|
150873
|
150874
|
150875
|
150876
|
150877
|
150878
|
150879
|
150880
|
150881
|
150882
|
150883
|
150884
|
150885
|
150886
|
150887
|
150888
|
150889
|
150967
|
150968
|
150969
|
150970
|
150971
|
150972
|
150973
|
150974
|
151254
|
151255
|
151256
|
151257
|
151258
|
151259
|
151260
|
151261
|
151358
|
151359
|
151360
|
151361
|
151362
|
151363
|
151364
|
151365
|
151368
|
151369
|
151370
|
151371
|
151372
|
151373
|
151374
|
151375
|
151376
|
152789
|
152790
|
152791
|
152792
|
152793
|
152794
|
152795
|
152796
|
152797
|
153459
|
153460
|
153461
|
153462
|
153463
|
153464
|
153465
|
153466
|
153467
|
153500
| 153501 |
153502
|
153503