Bugzilla – Attachment 117343 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 auhtenticate_api_request call stash_overrides
Bug-27760-Make-auhtenticateapirequest-call-stashov.patch (text/plain), 3.00 KB, created by
Kyle M Hall (khall)
on 2021-02-25 15:30:37 UTC
(
hide
)
Description:
Bug 27760: Make auhtenticate_api_request call stash_overrides
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-02-25 15:30:37 UTC
Size:
3.00 KB
patch
obsolete
>From 3a474e412737b5c10a249186b64b3ad589e7f46c 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 auhtenticate_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 a28fb5920c..226ab751ee 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -154,6 +154,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 5bb68d2570..dce489a934 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 => 3; >+use Test::More tests => 4; > use Test::Mojo; > > use Module::Load::Conditional qw(can_load); >@@ -192,6 +192,44 @@ subtest 'anonymous requests to public API' => 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.24.1 (Apple Git-126)
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