@@ -, +, @@ $ kshell k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t --- Koha/REST/V1/Auth.pm | 3 +++ .../api/v1/auth_authenticate_api_request.t | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) --- a/Koha/REST/V1/Auth.pm +++ a/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. --- a/t/db_dependent/api/v1/auth_authenticate_api_request.t +++ a/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; --