Bugzilla – Attachment 189004 Details for
Bug 40943
Store session_id in userenv
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40943: Fix Koha/BackgroundJob.t
Bug-40943-Fix-KohaBackgroundJobt.patch (text/plain), 3.03 KB, created by
Jonathan Druart
on 2025-11-04 08:26:44 UTC
(
hide
)
Description:
Bug 40943: Fix Koha/BackgroundJob.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-11-04 08:26:44 UTC
Size:
3.03 KB
patch
obsolete
>From 783fb7ea9d0b9c87403446a059a3ae1df017c585 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 4 Nov 2025 09:22:06 +0100 >Subject: [PATCH] Bug 40943: Fix Koha/BackgroundJob.t > >We should not log/leak session_id! > > Failed test 'Context set from userenv + interface' > at t/db_dependent/Koha/BackgroundJob.t line 132. > Structures begin differing at: > $got->{session_id} = undef > $expected->{session_id} = Does not exist > Looks like you failed 1 test of 10. > > Failed test 'enqueue() tests' > at t/db_dependent/Koha/BackgroundJob.t line 135. > > Failed test 'Userenv set from job context on process' > at t/db_dependent/Koha/BackgroundJob.t line 240. > Structures begin differing at: > $got->{session_id} = undef > $expected->{session_id} = Does not exist > Looks like you failed 1 test of 5. >--- > Koha/BackgroundJob.pm | 3 +++ > t/db_dependent/Koha/BackgroundJob.t | 10 ++++++++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > >diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm >index 8f44386c3e8..0ff204281d6 100644 >--- a/Koha/BackgroundJob.pm >+++ b/Koha/BackgroundJob.pm >@@ -125,6 +125,9 @@ sub enqueue { > my $job_queue = $params->{job_queue} // 'default'; > my $json = $self->json; > >+ # session_id must not be logged >+ delete $job_context->{session_id}; >+ > my $borrowernumber = ( C4::Context->userenv ) ? C4::Context->userenv->{number} : undef; > $job_context->{interface} = C4::Context->interface; > my $json_context = $json->encode($job_context); >diff --git a/t/db_dependent/Koha/BackgroundJob.t b/t/db_dependent/Koha/BackgroundJob.t >index 7caa2b64b28..42d87790d16 100755 >--- a/t/db_dependent/Koha/BackgroundJob.t >+++ b/t/db_dependent/Koha/BackgroundJob.t >@@ -119,7 +119,9 @@ subtest 'enqueue() tests' => sub { > shibboleth => undef, > desk_id => undef, > desk_name => undef, >- interface => $interface >+ interface => $interface, >+ >+ # session_id must not be logged! > }; > > $job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2, 3 ] } ); >@@ -218,6 +220,8 @@ subtest 'process tests' => sub { > shibboleth => undef, > desk_id => undef, > desk_name => undef, >+ >+ # session_id must not be logged! > }; > > my $background_job_module = Test::MockModule->new('Koha::BackgroundJob'); >@@ -237,7 +241,9 @@ subtest 'process tests' => sub { > is( C4::Context->interface, 'opac', "Interface set to opac prior to calling process" ); > > $job->process(); >- is_deeply( C4::Context->userenv, $job_context, "Userenv set from job context on process" ); >+ my $expected_context = C4::Context->userenv; >+ delete $expected_context->{session_id}; >+ is_deeply( $expected_context, $job_context, "Userenv set from job context on process" ); > is_deeply( C4::Context->interface, 'intranet', "Interface set from job context on process" ); > > # Manually add a job (->new->store) without context >-- >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 40943
:
187379
|
187380
|
187720
|
187721
|
187722
|
188188
|
188189
|
188190
|
189002
|
189003
| 189004 |
189145