Bugzilla – Attachment 126120 Details for
Bug 28948
Add a /public counterpart for the libraries REST endpoints
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28948: Make is_public stashed on public routes
Bug-28948-Make-ispublic-stashed-on-public-routes.patch (text/plain), 2.54 KB, created by
Kyle M Hall (khall)
on 2021-10-12 18:45:29 UTC
(
hide
)
Description:
Bug 28948: Make is_public stashed on public routes
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-10-12 18:45:29 UTC
Size:
2.54 KB
patch
obsolete
>From d757f59b33b5cf0ad6eb361fea5f60928df9a346 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 7 Jan 2021 12:36:42 -0300 >Subject: [PATCH] Bug 28948: Make is_public stashed on public routes > >This patch makes the API authentication code stash the 'is_public' value >when public routes are hit. > >This will be particularly useful to have $c->objects->search generically >pass this info down to the ->to_api method. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t >=> SUCCESS: Tests pass! When a public route is reached, the controller >has the 'is_public' value stashed >3. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/V1/Auth.pm | 3 +++ > .../api/v1/auth_authenticate_api_request.t | 24 ++++++++++++++++++- > 2 files changed, 26 insertions(+), 1 deletion(-) > >diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm >index 2361aae361f..7422787ac9e 100644 >--- a/Koha/REST/V1/Auth.pm >+++ b/Koha/REST/V1/Auth.pm >@@ -149,6 +149,9 @@ sub authenticate_api_request { > > my $user; > >+ $c->stash( 'is_public' => 1 ) >+ if $params->{is_public}; >+ > # The following supports retrieval of spec with Mojolicious::Plugin::OpenAPI@1.17 and later (first one) > # and older versions (second one). > # TODO: remove the latter 'openapi.op_spec' if minimum version is bumped to at least 1.17. >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 ef7edede95f..10a61893e8b 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 => 5; >+use Test::More tests => 6; > use Test::Mojo; > > use Module::Load::Conditional qw(can_load); >@@ -296,6 +296,28 @@ subtest 'x-koha-override stash tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'public routes have "is_public" info stashed' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $stash; >+ $t->app->hook( >+ after_dispatch => sub { >+ $stash = shift->stash; >+ } >+ ); >+ >+ $t->get_ok('/api/v1/public/biblios/1'); >+ >+ my $is_public = $stash->{is_public}; >+ >+ ok( $is_public, 'Correctly stashed the fact it is a public route' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_user_and_session { > > my $args = shift; >-- >2.30.2
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 28948
:
124479
|
124480
|
124481
|
124482
|
124483
|
124749
|
124911
|
124914
|
125901
|
125902
|
125903
|
125904
|
125905
|
125906
|
125907
|
125908
|
125911
|
125912
|
126111
|
126112
|
126113
|
126114
|
126115
|
126116
|
126117
|
126118
|
126119
| 126120 |
126121
|
126122
|
126123
|
126124
|
126125
|
126126
|
127054
|
127055