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 <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Lari Taskula 2026-02-24 13:51:53 +02:00 committed by Jonathan Druart
parent dc15cc3a04
commit e32af26bca
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
1 changed files with 7 additions and 1 deletions

View File

@ -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' );