From 776ea9f71ad267ac35f6f62fa0b443b4ab4e1b9d Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 24 Feb 2026 13:51:53 +0200 Subject: [PATCH] Bug 38365: (follow-up) Move default Content-Security-Policy value into Perl module, add tests To test: 1. prove t/Koha/ContentSecurityPolicy.t Signed-off-by: David Cook --- t/Koha/ContentSecurityPolicy.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/Koha/ContentSecurityPolicy.t b/t/Koha/ContentSecurityPolicy.t index ef7ce71589a..35adbe28116 100755 --- a/t/Koha/ContentSecurityPolicy.t +++ b/t/Koha/ContentSecurityPolicy.t @@ -117,13 +117,19 @@ subtest 'header_name tests' => sub { }; subtest 'header_value tests' => sub { - plan tests => 3; + plan tests => 4; t::lib::Mocks::mock_config( $conf_csp_section, {} ); C4::Context->interface('opac'); my $csp = Koha::ContentSecurityPolicy->new; + t::lib::Mocks::mock_config( $conf_csp_section, { opac => { csp_header_value => '' } } ); + like( + $csp->header_value, qr/^default-src 'self';.*_CSP_NONCE_/, + 'csp_header_value is retrieved from ContentSecurityPolicy.pm' + ); + t::lib::Mocks::mock_config( $conf_csp_section, { opac => { csp_header_value => 'some value' } } ); is( $csp->header_value, 'some value', 'csp_header_value is retrieved from koha-conf.xml' ); -- 2.39.5