You are here

public function CspOptimizationTest::testReduceAttrSourceListNonce in Content-Security-Policy 8

Nonces cannot be applied to attributes.

@covers ::reduceAttrSourceList

File

tests/src/Unit/CspOptimizationTest.php, line 456

Class

CspOptimizationTest
Test optimization of CSP directives.

Namespace

Drupal\Tests\csp\Unit

Code

public function testReduceAttrSourceListNonce() {
  $policy = new Csp();
  $policy
    ->setDirective('script-src-attr', [
    Csp::POLICY_SELF,
    "'nonce-qskCbxYHEcwf3tBVzkngCA'",
  ]);
  $this
    ->assertEquals("script-src-attr 'self'", $policy
    ->getHeaderValue());
}