You are here

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

If all values are removed from an attr source list it should be 'none'.

@covers ::reduceAttrSourceList

File

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

Class

CspOptimizationTest
Test optimization of CSP directives.

Namespace

Drupal\Tests\csp\Unit

Code

public function testReduceAttrSourceListEmpty() {
  $policy = new Csp();
  $policy
    ->setDirective('script-src', [
    Csp::POLICY_SELF,
    'https://example.com',
  ]);
  $policy
    ->setDirective('script-src-attr', [
    'https://example.com',
  ]);
  $this
    ->assertEquals("script-src 'self' https://example.com; script-src-attr 'none'", $policy
    ->getHeaderValue());
}