From 1240258d0d63bf464d6ec243985cffd22a562dbc Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 27 Oct 2025 21:56:30 +0200 Subject: [PATCH] Bug 38365: Test nonce generation in Output.t To test: 1. prove t/db_dependent/Output.t --- t/db_dependent/Output.t | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Output.t b/t/db_dependent/Output.t index d3af1bd1781..1af9b309268 100755 --- a/t/db_dependent/Output.t +++ b/t/db_dependent/Output.t @@ -224,7 +224,6 @@ subtest 'Content-Security-Policy tests' => sub { 'content_security_policy', { 'opac' => { csp_mode => 'report-only', csp_header_value => $expected_csp_header_value } } ); - $expected_csp_header_value =~ s/_CSP_NONCE_//g; my $query = CGI->new(); @@ -242,6 +241,9 @@ subtest 'Content-Security-Policy tests' => sub { } ); + my $cache = Koha::Cache::Memory::Lite->get_instance; + my $nonce = $cache->get_from_cache("csp_nonce"); + $expected_csp_header_value =~ s/_CSP_NONCE_/nonce-$nonce/g; C4::Output::output_html_with_http_headers( $query, $cookie, $template->output ); $stdout =~ /(Content-Security-Policy[A-Za-z\-]*): (.*)\r/im; @@ -280,7 +282,6 @@ subtest 'Content-Security-Policy tests' => sub { 'content_security_policy', { 'opac' => { csp_mode => 'enabled', csp_header_value => $expected_csp_header_value } } ); - $expected_csp_header_value =~ s/_CSP_NONCE_//g; my $query = CGI->new(); @@ -298,6 +299,10 @@ subtest 'Content-Security-Policy tests' => sub { } ); + my $cache = Koha::Cache::Memory::Lite->get_instance; + my $nonce = $cache->get_from_cache("csp_nonce"); + $expected_csp_header_value =~ s/_CSP_NONCE_/nonce-$nonce/g; + C4::Output::output_html_with_http_headers( $query, $cookie, $template->output ); $stdout =~ /(Content-Security-Policy[A-Za-z\-]*): (.*)\r/im; -- 2.34.1