Bugzilla – Attachment 140691 Details for
Bug 29744
Harmonize psgi/plack detection methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29744: (QA follow-up) Add underscore test, move to OO
Bug-29744-QA-follow-up-Add-underscore-test-move-to.patch (text/plain), 3.10 KB, created by
Marcel de Rooy
on 2022-09-16 07:54:06 UTC
(
hide
)
Description:
Bug 29744: (QA follow-up) Add underscore test, move to OO
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-09-16 07:54:06 UTC
Size:
3.10 KB
patch
obsolete
>From 63205ccdbc49b53f3b1c5f239b981328deddc823 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 16 Sep 2022 07:07:00 +0000 >Subject: [PATCH] Bug 29744: (QA follow-up) Add underscore test, move to OO >Content-Type: text/plain; charset=utf-8 > >The underscore test comes from bug 31468. >Context methods should actually be OO. > >Test plan: >Run t/Context.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Context.pm | 8 ++++++-- > t/Context.t | 33 ++++++++++++++++++++++++++++++++- > 2 files changed, 38 insertions(+), 3 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 823f8cb89c..8cd7681e6c 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1007,7 +1007,10 @@ this is a PSGI app or a CGI app, and implementing code as appropriate. > > =cut > >-sub psgi_env { any { /(^psgi\.|^plack\.)/i } keys %ENV }; >+sub psgi_env { >+ my ( $self ) = @_; >+ return any { /^(psgi|plack)[._]/i } keys %ENV; >+} > > =head3 is_internal_PSGI_request > >@@ -1019,8 +1022,9 @@ app > > #NOTE: This is not a very robust method but it's the best we have so far > sub is_internal_PSGI_request { >+ my ( $self ) = @_; > my $is_internal = 0; >- if ( (__PACKAGE__->psgi_env) && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ){ >+ if( $self->psgi_env && ( $ENV{REQUEST_URI} !~ /^(\/intranet|\/opac)/ ) ) { > $is_internal = 1; > } > return $is_internal; >diff --git a/t/Context.t b/t/Context.t >index f3e15a56c1..1e351157d8 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use DBI; >-use Test::More tests => 32; >+use Test::More tests => 33; > use Test::MockModule; > use Test::Warn; > use YAML::XS; >@@ -145,3 +145,34 @@ is( C4::Context->interface( 'CRON' ), 'cron', 'interface cron uc' ); > $ENV{HTTPS} = 'ON'; > is( C4::Context->https_enabled, 1, "ON HTTPS env returns 1"); > } >+ >+subtest 'psgi_env and is_internal_PSGI_request' => sub { >+ plan tests => 11; >+ >+ local %ENV = ( no_plack => 1 ); >+ is( C4::Context->psgi_env, q{}, 'no_plack' ); >+ $ENV{plackishere} = 1; >+ is( C4::Context->psgi_env, q{}, 'plackishere is wrong' ); >+ $ENV{'plack.ishere'} = 1; >+ is( C4::Context->psgi_env, 1, 'plack.ishere' ); >+ delete $ENV{'plack.ishere'}; >+ is( C4::Context->psgi_env, q{}, 'plack.ishere was here' ); >+ $ENV{'plack_ishere'} = 1; >+ is( C4::Context->psgi_env, 1, 'plack_ishere' ); >+ delete $ENV{'plack_ishere'}; >+ $ENV{'psgi_whatever'} = 1; >+ is( C4::Context->psgi_env, 1, 'psgi_whatever' ); >+ delete $ENV{'psgi_whatever'}; >+ $ENV{'psgi.whatever'} = 1; >+ is( C4::Context->psgi_env, 1, 'psgi.whatever' ); >+ delete $ENV{'psgi.whatever'}; >+ $ENV{'PSGI.UPPERCASE'} = 1; >+ is( C4::Context->psgi_env, 1, 'PSGI uppercase' ); >+ >+ $ENV{'REQUEST_URI'} = '/intranet/whatever'; >+ is( C4::Context->is_internal_PSGI_request, 0, 'intranet not considered internal in regex' ); >+ $ENV{'REQUEST_URI'} = '/api/v1/tralala'; >+ is( C4::Context->is_internal_PSGI_request, 1, 'api considered internal in regex' ); >+ delete $ENV{'PSGI.UPPERCASE'}; >+ is( C4::Context->is_internal_PSGI_request, 0, 'api but no longer PSGI' ); >+}; >-- >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 29744
:
132299
|
132975
|
133429
|
133430
|
140689
|
140690
| 140691 |
140692
|
140922