Bugzilla – Attachment 109358 Details for
Bug 26322
REST API plugin authorization is not checked anymore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26322: Regression tests
Bug-26322-Regression-tests.patch (text/plain), 3.02 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-08-31 12:37:20 UTC
(
hide
)
Description:
Bug 26322: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-08-31 12:37:20 UTC
Size:
3.02 KB
patch
obsolete
>From 6915cece964c89d86191be133038f3fa1bd8db6e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 31 Aug 2020 09:36:56 -0300 >Subject: [PATCH] Bug 26322: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../Koha/REST/Plugin/PluginRoutes.t | 36 +++++++++++++++---- > 1 file changed, 30 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t b/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t >index 27af737ab0..eeaff7f514 100644 >--- a/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t >+++ b/t/db_dependent/Koha/REST/Plugin/PluginRoutes.t >@@ -37,8 +37,10 @@ BEGIN { > > use Koha::Database; > use Koha::Plugins; >+use t::lib::TestBuilder; > >-my $schema = Koha::Database->new->schema; >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; > > subtest 'Bad plugins tests' => sub { > >@@ -118,9 +120,9 @@ subtest 'Disabled plugins tests' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'Anonymous access routes plugins tests' => sub { >+subtest 'Permissions and access to plugin routes tests' => sub { > >- plan tests => 9; >+ plan tests => 16; > > $schema->storage->txn_begin; > >@@ -150,9 +152,9 @@ subtest 'Anonymous access routes plugins tests' => sub { > > C4::Context->set_preference( 'RESTPublicAnonymousRequests', 0 ); > >- $t->get_ok('/api/v1/contrib/testplugin/public/patrons/bother') >- ->status_is(200, 'Plugin routes not affected by RESTPublicAnonymousRequests') >- ->json_is( { bothered => Mojo::JSON->true } ); >+ $t->get_ok('/api/v1/contrib/testplugin/public/patrons/bother') >+ ->status_is(200, 'Plugin routes not affected by RESTPublicAnonymousRequests') >+ ->json_is( { bothered => Mojo::JSON->true } ); > > C4::Context->set_preference( 'RESTPublicAnonymousRequests', 1 ); > >@@ -160,6 +162,28 @@ subtest 'Anonymous access routes plugins tests' => sub { > ->status_is(200, 'Plugin routes not affected by RESTPublicAnonymousRequests') > ->json_is( { bothered => Mojo::JSON->true } ); > >+ $t->get_ok('/api/v1/contrib/testplugin/patrons/bother') >+ ->status_is(401, 'Plugin routes honour permissions, anonymous accesss denied'); >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 2**3 } # borrowers flag = 4 >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ $t->get_ok("//$userid:$password@/api/v1/contrib/testplugin/patrons/bother") >+ ->status_is(401, 'Plugin routes honour permissions, wrong permissions, accesss denied'); >+ >+ $librarian->set({ flags => 2 ** 4 })->store->discard_changes; >+ >+ $t->get_ok("//$userid:$password@/api/v1/contrib/testplugin/patrons/bother") >+ ->status_is(200, 'Plugin routes honour permissions, right permissions, accesss granted') >+ ->json_is( { bothered => Mojo::JSON->true } ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.28.0
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 26322
:
109358
|
109366
|
109367
|
109428
|
109429
|
109512
|
109513
|
109517
|
109518
|
109539
|
109540
|
110519
|
110520