Bugzilla – Attachment 103676 Details for
Bug 25045
Add a way to restrict anonymous access to public routes (OpacPublic behaviour)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25045: Unit tests
Bug-25045-Unit-tests.patch (text/plain), 2.22 KB, created by
Jonathan Druart
on 2020-04-24 12:54:29 UTC
(
hide
)
Description:
Bug 25045: Unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-04-24 12:54:29 UTC
Size:
2.22 KB
patch
obsolete
>From 4b0db676f803b376b9a6c32a6aac9cc5aa6f59ca Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 13 Apr 2020 11:40:44 -0300 >Subject: [PATCH] Bug 25045: Unit tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../api/v1/auth_authenticate_api_request.t | 35 ++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > >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 75348b90f5..de8578bfe0 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 => 2; >+use Test::More tests => 3; > use Test::Mojo; > > use Module::Load::Conditional qw(can_load); >@@ -141,6 +141,39 @@ subtest 'cookie-based tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'anonymous requests to public API' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+ my $password = 'AbcdEFG123'; >+ my $userid = 'tomasito'; >+ # Add a patron >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ $patron->set_password({ password => $password }); >+ # Add a biblio >+ my $biblio_id = $builder->build_sample_biblio()->biblionumber; >+ >+ # Enable the public API >+ t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); >+ # Disable anonymous requests on the public namespace >+ t::lib::Mocks::mock_preference( 'RESTPublicAnonymousRequests', 0 ); >+ >+ $t->get_ok("/api/v1/public/biblios/" . $biblio_id => { Accept => 'application/marc' }) >+ ->status_is( 401, 'Unauthorized anonymous attempt to access a resource' ); >+ >+ # Disable anonymous requests on the public namespace >+ t::lib::Mocks::mock_preference( 'RESTPublicAnonymousRequests', 1 ); >+ >+ $t->get_ok("/api/v1/public/biblios/" . $biblio_id => { Accept => 'application/marc' }) >+ ->status_is( 200, 'Successfull anonymous access to a resource' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_user_and_session { > > my $args = shift; >-- >2.20.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 25045
:
102846
|
102847
|
102848
|
102849
|
103651
|
103652
|
103653
|
103654
|
103655
|
103675
| 103676 |
103677
|
103678
|
103748
|
103749
|
103773
|
106080
|
106081