Skip to content

Commit 221b20f

Browse files
mark-unwinpaulbalandan
authored andcommitted
fix: Add missing unit test for script-src-elem.
Signed-off-by: Mark Unwin <[email protected]>
1 parent cee9ac5 commit 221b20f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/system/HTTP/ContentSecurityPolicyTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,21 @@ public function testScriptSrc(): void
374374
$this->assertContains("script-src 'self' cdn.cloudy.com", $this->getCspDirectives($header));
375375
}
376376

377+
#[PreserveGlobalState(false)]
378+
#[RunInSeparateProcess]
379+
public function testScriptSrcElem(): void
380+
{
381+
$this->prepare();
382+
$this->csp->addScriptSrcElem('cdn.cloudy.com');
383+
$this->csp->addScriptSrcElem('them.com', true);
384+
$result = $this->work();
385+
386+
$result = $this->getHeaderEmitted('Content-Security-Policy-Report-Only');
387+
$this->assertStringContainsString('script-src-elem them.com;', (string) $result);
388+
$result = $this->getHeaderEmitted('Content-Security-Policy');
389+
$this->assertStringContainsString("script-src-elem 'self' cdn.cloudy.com;", (string) $result);
390+
}
391+
377392
#[PreserveGlobalState(false)]
378393
#[RunInSeparateProcess]
379394
public function testStyleSrc(): void

0 commit comments

Comments
 (0)