You are here

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

If attr directive is enabled but empty, it should be removed.

@covers ::reduceAttrSourceList

File

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

Class

CspOptimizationTest
Test optimization of CSP directives.

Namespace

Drupal\Tests\csp\Unit

Code

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