Bugzilla – Attachment 152789 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: Unit tests
Bug-30979-Unit-tests.patch (text/plain), 6.26 KB, created by
Martin Renvoize (ashimema)
on 2023-06-28 12:41:57 UTC
(
hide
)
Description:
Bug 30979: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-06-28 12:41:57 UTC
Size:
6.26 KB
patch
obsolete
>From b031376c09f3ad71f10c1217112a114d42c5cc31 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 10 May 2023 11:24:17 +0100 >Subject: [PATCH] Bug 30979: Unit tests > >--- > t/db_dependent/api/v1/checkouts.t | 132 +++++++++++++++++++++++++++++- > 1 file changed, 130 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t >index 2e749aa874..5fb3de660e 100755 >--- a/t/db_dependent/api/v1/checkouts.t >+++ b/t/db_dependent/api/v1/checkouts.t >@@ -238,7 +238,7 @@ $schema->storage->txn_rollback; > > subtest 'get_availability' => sub { > >- plan tests => 28; >+ plan tests => 29; > > $schema->storage->txn_begin; > my $librarian = $builder->build_object( >@@ -340,13 +340,88 @@ subtest 'get_availability' => sub { > ), > 'Correct token' > ); >+ %needsconfirmation = (); >+ >+ subtest 'public 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'); >+ >+ # 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'); >+ %needsconfirmation = (); >+ >+ # Remove personal information from public endpoint >+ %issuingimpossible = ( >+ issued_borrowernumber => 'private', >+ issued_cardnumber => 'private', >+ issued_firstname => 'private', >+ issued_surname => 'private', >+ resborrowernumber => 'private', >+ resbranchcode => 'private', >+ rescardnumber => 'private', >+ reserve_id => 'private', >+ resfirstname => 'private', >+ resreservedate => 'private', >+ ressurname => 'private', >+ item_notforloan => 'private' >+ ); >+ %alerts = ( >+ issued_borrowernumber => 'private', >+ issued_cardnumber => 'private', >+ issued_firstname => 'private', >+ issued_surname => 'private', >+ resborrowernumber => 'private', >+ resbranchcode => 'private', >+ rescardnumber => 'private', >+ reserve_id => 'private', >+ resfirstname => 'private', >+ resreservedate => 'private', >+ ressurname => 'private', >+ item_notforloan => 'private' >+ ); >+ >+ %needsconfirmation = ( >+ issued_borrowernumber => 'private', >+ issued_cardnumber => 'private', >+ issued_firstname => 'private', >+ issued_surname => 'private', >+ resborrowernumber => 'private', >+ resbranchcode => 'private', >+ rescardnumber => 'private', >+ reserve_id => 'private', >+ resfirstname => 'private', >+ resreservedate => 'private', >+ 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'); >+ %issuingimpossible = (); >+ %alerts = (); >+ %needsconfirmation = (); >+ }; > > $schema->storage->txn_rollback; > }; > > subtest 'add checkout' => sub { > >- plan tests => 9; >+ plan tests => 10; > > $schema->storage->txn_begin; > my $librarian = $builder->build_object( >@@ -426,5 +501,58 @@ subtest 'add checkout' => sub { > )->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 } ); >+ >+ # 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" } ); >+ >+ # 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( >+ { >+ 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); >+ }; >+ > $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