Bugzilla – Attachment 140922 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) Only consider PLACK_ENV for underscore
Bug-29744-QA-follow-up-Only-consider-PLACKENV-for-.patch (text/plain), 3.55 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-09-23 15:08:35 UTC
(
hide
)
Description:
Bug 29744: (QA follow-up) Only consider PLACK_ENV for underscore
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-09-23 15:08:35 UTC
Size:
3.55 KB
patch
obsolete
>From e50948516169fd803159fc902f24e6aea0980bdf Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 23 Sep 2022 12:04:54 -0300 >Subject: [PATCH] Bug 29744: (QA follow-up) Only consider PLACK_ENV for > underscore > >When run under certain circumstances (in jenkins, for example) some ENV >variables are set for convenience, like PLACK_WORKERS and >PLACK_MAX_REQUESTS and is causing some tests to fail (notably, shib >ones). > >This patch makes the regex only consider PLACK_ENV when testing for the >underscore case. > >Tests are updated accordingly, and they are also rewritten to test for >boolean values instead of empty string, or zero or one, etc. The >implementation shouldn't matter as long as the boolean evaluation is >correct and it is clearer for devs what to expect. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Context.pm | 2 +- > t/Context.t | 27 ++++++++++++++------------- > 2 files changed, 15 insertions(+), 14 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 8cd7681e6c2..df04c7ab669 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1009,7 +1009,7 @@ this is a PSGI app or a CGI app, and implementing code as appropriate. > > sub psgi_env { > my ( $self ) = @_; >- return any { /^(psgi|plack)[._]/i } keys %ENV; >+ return any { /^(psgi\.|plack\.|PLACK_ENV$)/i } keys %ENV; > } > > =head3 is_internal_PSGI_request >diff --git a/t/Context.t b/t/Context.t >index 1e351157d85..cf4a4b6036e 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -147,32 +147,33 @@ is( C4::Context->interface( 'CRON' ), 'cron', 'interface cron uc' ); > } > > 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' ); >+ ok( !C4::Context->psgi_env, 'no_plack' ); > $ENV{plackishere} = 1; >- is( C4::Context->psgi_env, q{}, 'plackishere is wrong' ); >+ ok( !C4::Context->psgi_env, 'plackishere is wrong' ); > $ENV{'plack.ishere'} = 1; >- is( C4::Context->psgi_env, 1, 'plack.ishere' ); >+ ok( C4::Context->psgi_env, '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'}; >+ ok( !C4::Context->psgi_env, 'plack.ishere was here' ); >+ $ENV{'plack_env'} = 1; >+ ok( C4::Context->psgi_env, 'plack_env' ); >+ delete $ENV{'plack_env'}; > $ENV{'psgi_whatever'} = 1; >- is( C4::Context->psgi_env, 1, 'psgi_whatever' ); >+ ok( !C4::Context->psgi_env, 'psgi_whatever' ); > delete $ENV{'psgi_whatever'}; > $ENV{'psgi.whatever'} = 1; >- is( C4::Context->psgi_env, 1, 'psgi.whatever' ); >+ ok( C4::Context->psgi_env, 'psgi.whatever' ); > delete $ENV{'psgi.whatever'}; > $ENV{'PSGI.UPPERCASE'} = 1; >- is( C4::Context->psgi_env, 1, 'PSGI uppercase' ); >+ ok( C4::Context->psgi_env, 'PSGI uppercase' ); > > $ENV{'REQUEST_URI'} = '/intranet/whatever'; >- is( C4::Context->is_internal_PSGI_request, 0, 'intranet not considered internal in regex' ); >+ ok( !C4::Context->is_internal_PSGI_request, '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' ); >+ ok( C4::Context->is_internal_PSGI_request, 'api considered internal in regex' ); > delete $ENV{'PSGI.UPPERCASE'}; >- is( C4::Context->is_internal_PSGI_request, 0, 'api but no longer PSGI' ); >+ ok( !C4::Context->is_internal_PSGI_request, 'api but no longer PSGI' ); > }; >-- >2.34.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 29744
:
132299
|
132975
|
133429
|
133430
|
140689
|
140690
|
140691
|
140692
| 140922