Bugzilla – Attachment 120113 Details for
Bug 27760
Add handling for x-koha-override
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27760: Make authenticate_api_request call stash_overrides
Bug-27760-Make-authenticateapirequest-call-stashov.patch (text/plain), 2.98 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-04-23 15:22:25 UTC
(
hide
)
Description:
Bug 27760: Make authenticate_api_request call stash_overrides
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-04-23 15:22:25 UTC
Size:
2.98 KB
patch
obsolete
>From 5f4903c3d18f28416b90bd07e1a82f4adb4a1286 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 25 Feb 2021 09:43:11 -0300 >Subject: [PATCH] Bug 27760: Make authenticate_api_request call stash_overrides > >By making this method call the helper, we make sure the overrides >hashref is available to any controller to make us of it. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t \ > t/Koha/REST/Plugin/Query.t >=> SUCCESS: Tests pass! The helper works as expected and the >authenticate_api_request method invokes it! >3. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/V1/Auth.pm | 2 + > .../api/v1/auth_authenticate_api_request.t | 40 ++++++++++++++++++- > 2 files changed, 41 insertions(+), 1 deletion(-) > >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index 3b5ab4c9a22..ea29bd69291 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -155,6 +155,8 @@ sub authenticate_api_request { > my $spec = $c->openapi->spec || $c->match->endpoint->pattern->defaults->{'openapi.op_spec'}; > > $c->stash_embed({ spec => $spec }); >+ $c->stash_overrides(); >+ > my $cookie_auth = 0; > > my $authorization = $spec->{'x-koha-authorization'}; >diff --git a/t/db_dependent/api/v1/auth_authenticate_api_request.t b/t/db_dependent/api/v1/auth_authenticate_api_request.t >index dddf93ca4a6..016aa9866d5 100755 >--- a/t/db_dependent/api/v1/auth_authenticate_api_request.t >+++ b/t/db_dependent/api/v1/auth_authenticate_api_request.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::Mojo; > > use Module::Load::Conditional qw(can_load); >@@ -258,6 +258,44 @@ subtest 'x-koha-library tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'x-koha-override stash tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ }); >+ my $password = 'thePassword123'; >+ $patron->set_password({ password => $password, skip_validation => 1 }); >+ my $userid = $patron->userid; >+ >+ my $item = $builder->build_sample_item(); >+ >+ my $hold_data = { >+ patron_id => $patron->id, >+ biblio_id => $item->biblionumber, >+ item_id => $item->id, >+ pickup_library_id => $patron->branchcode, >+ }; >+ >+ my $stash; >+ >+ $t->app->hook(after_dispatch => sub { >+ $stash = shift->stash; >+ }); >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds" => { 'x-koha-override' => "any" } => json => $hold_data ); >+ >+ my $overrides = $stash->{'koha.overrides'}; >+ is( ref($overrides), 'HASH', 'arrayref returned' ); >+ ok( $overrides->{'any'}, "The value 'any' is found" ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_user_and_session { > > my $args = shift; >-- >2.31.1
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 27760
:
117308
|
117309
|
117326
|
117327
|
117342
|
117343
|
117344
|
118108
|
118110
|
120112
| 120113 |
120114
|
120115