Bugzilla – Attachment 119931 Details for
Bug 28157
Add the ability to set a library from which an API request pretends to come from
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28157: Regression tests
Bug-28157-Regression-tests.patch (text/plain), 3.12 KB, created by
David Nind
on 2021-04-20 19:14:08 UTC
(
hide
)
Description:
Bug 28157: Regression tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-04-20 19:14:08 UTC
Size:
3.12 KB
patch
obsolete
>From a2ed6fe21dad7ed0e20e1de6eaef45e07cf44ba8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 20 Apr 2021 14:23:30 -0300 >Subject: [PATCH] Bug 28157: Regression tests > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../api/v1/auth_authenticate_api_request.t | 68 +++++++++++++++++++++- > 1 file changed, 67 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 5bb68d2570..dddf93ca4a 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,72 @@ subtest 'anonymous requests to public API' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'x-koha-library tests' => sub { >+ >+ plan tests => 10; >+ >+ $schema->storage->txn_begin; >+ >+ my $stash; >+ my $userenv; >+ >+ $t->app->hook(after_dispatch => sub { >+ $stash = shift->stash; >+ $userenv = C4::Context->userenv; >+ }); >+ >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ my $superlibrarian = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ }); >+ my $password = 'thePassword123'; >+ $superlibrarian->set_password({ password => $password, skip_validation => 1 }); >+ my $superlibrarian_userid = $superlibrarian->userid; >+ >+ my $unprivileged = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { flags => undef } >+ }); >+ $unprivileged->set_password({ password => $password, skip_validation => 1 }); >+ my $unprivileged_userid = $unprivileged->userid; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ ## Independent branches tests >+ t::lib::Mocks::mock_preference('IndependentBranches', 1); >+ >+ $t->get_ok( >+ "//$unprivileged_userid:$password@/api/v1/cities", >+ { 'x-koha-library' => $unprivileged->branchcode } >+ ); >+ >+ is( $userenv->{branch}, $unprivileged->branchcode, 'branch set correctly' ); >+ >+ $t->get_ok( "//$unprivileged_userid:$password@/api/v1/cities" => >+ { 'x-koha-library' => $library->id } )->status_is(403) >+ ->json_is( >+ '/error' => 'Unauthorized attempt to set library to ' . $library->id ); >+ >+ $t->get_ok( "//$superlibrarian_userid:$password@/api/v1/cities" => >+ { 'x-koha-library' => $library->id } )->status_is(200); >+ >+ is( $userenv->{branch}, $library->id, 'branch set correctly' ); >+ >+ ## !Independent branches tests >+ t::lib::Mocks::mock_preference('IndependentBranches', 1); >+ $t->get_ok( >+ "//$unprivileged_userid:$password@/api/v1/cities", >+ { 'x-koha-library' => $unprivileged->branchcode } >+ ); >+ $t->get_ok( >+ "//$unprivileged_userid:$password@/api/v1/cities", >+ { 'x-koha-library' => $library->id } >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_user_and_session { > > my $args = shift; >-- >2.11.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 28157
:
119925
|
119926
|
119927
|
119930
| 119931 |
119932
|
119959