Bugzilla – Attachment 160358 Details for
Bug 32551
API requests don't carry language related information
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32551: Regression tests
Bug-32551-Regression-tests.patch (text/plain), 4.17 KB, created by
David Nind
on 2023-12-28 19:12:21 UTC
(
hide
)
Description:
Bug 32551: Regression tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-12-28 19:12:21 UTC
Size:
4.17 KB
patch
obsolete
>From c0513460d29a537f15096a972de52fa34873afc4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 28 Dec 2023 14:40:11 +0000 >Subject: [PATCH] Bug 32551: Regression tests > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../api/v1/auth_authenticate_api_request.t | 49 +++++++++++++------ > 1 file changed, 33 insertions(+), 16 deletions(-) > >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 10a61893e8..d4e8e97445 100755 >--- a/t/db_dependent/api/v1/auth_authenticate_api_request.t >+++ b/t/db_dependent/api/v1/auth_authenticate_api_request.t >@@ -44,7 +44,7 @@ t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); > subtest 'token-based tests' => sub { > > if ( can_load( modules => { 'Net::OAuth2::AuthorizationServer' => undef } ) ) { >- plan tests => 14; >+ plan tests => 15; > } > else { > plan skip_all => 'Net::OAuth2::AuthorizationServer not available'; >@@ -77,16 +77,23 @@ subtest 'token-based tests' => sub { > my $stash; > my $interface; > my $userenv; >+ my $language_env; > >- my $tx = $t->ua->build_tx(GET => '/api/v1/acquisitions/orders'); >+ my $accept_language = 'es-ES,es;q=0.9,en-US;q=0.8,en;q=0.7'; >+ >+ my $tx = $t->ua->build_tx( GET => '/api/v1/acquisitions/orders' ); > $tx->req->headers->authorization("Bearer $access_token"); > $tx->req->headers->header( 'x-koha-embed' => 'fund' ); >+ $tx->req->headers->accept_language($accept_language); > >- $t->app->hook(after_dispatch => sub { >- $stash = shift->stash; >- $interface = C4::Context->interface; >- $userenv = C4::Context->userenv; >- }); >+ $t->app->hook( >+ after_dispatch => sub { >+ $stash = shift->stash; >+ $interface = C4::Context->interface; >+ $userenv = C4::Context->userenv; >+ $language_env = $ENV{HTTP_ACCEPT_LANGUAGE}; >+ } >+ ); > > # With access token and permissions, it returns 200 > #$patron->flags(2**4)->store; >@@ -98,6 +105,7 @@ subtest 'token-based tests' => sub { > is( $user->borrowernumber, $patron->borrowernumber, 'The stashed user is the right one' ); > is( $userenv->{number}, $patron->borrowernumber, 'userenv set correctly' ); > is( $interface, 'api', "Interface correctly set to \'api\'" ); >+ is( $language_env, $accept_language, 'HTTP_ACCEPT_LANGUAGE correctly set in %ENV' ); > > my $embed = $stash->{'koha.embed'}; > ok( defined $embed, 'The embed hashref is generated and stashed' ); >@@ -108,25 +116,33 @@ subtest 'token-based tests' => sub { > > subtest 'cookie-based tests' => sub { > >- plan tests => 8; >+ plan tests => 9; > > $schema->storage->txn_begin; > > my ( $borrowernumber, $session_id ) = create_user_and_session({ authorized => 1 }); > >+ my $stash; >+ my $interface; >+ my $userenv; >+ my $language_env; >+ >+ my $accept_language = 'es-ES,es;q=0.9,en-US;q=0.8,en;q=0.7'; >+ > $tx = $t->ua->build_tx( GET => "/api/v1/patrons" ); > $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); > $tx->req->env( { REMOTE_ADDR => $remote_address } ); >+ $tx->req->headers->accept_language($accept_language); > >- my $stash; >- my $interface; >- my $userenv; >+ $t->app->hook( >+ after_dispatch => sub { >+ $stash = shift->stash; >+ $interface = C4::Context->interface; >+ $userenv = C4::Context->userenv; >+ $language_env = $ENV{HTTP_ACCEPT_LANGUAGE}; > >- $t->app->hook(after_dispatch => sub { >- $stash = shift->stash; >- $interface = C4::Context->interface; >- $userenv = C4::Context->userenv; >- }); >+ } >+ ); > > $t->request_ok($tx)->status_is(200); > >@@ -136,6 +152,7 @@ subtest 'cookie-based tests' => sub { > is( $user->borrowernumber, $borrowernumber, 'The stashed user is the right one' ); > is( $userenv->{number}, $borrowernumber, 'userenv set correctly' ); > is( $interface, 'api', "Interface correctly set to \'api\'" ); >+ is( $language_env, $accept_language, 'HTTP_ACCEPT_LANGUAGE correctly set in %ENV' ); > > subtest 'logged-out tests' => sub { > plan tests => 3; >-- >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 32551
:
160354
|
160355
|
160358
|
160359
|
160585
|
160586