You are here

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

Network sources should be removed for attribute directives.

@covers ::reduceAttrSourceList

File

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

Class

CspOptimizationTest
Test optimization of CSP directives.

Namespace

Drupal\Tests\csp\Unit

Code

public function testReduceAttrSourceListNetworkSource() {
  $policy = new Csp();
  $policy
    ->setDirective('script-src-attr', [
    Csp::POLICY_UNSAFE_INLINE,
    'https:',
    'wss:',
    'example.com',
    'https://example.com',
    'ws://connect.example.org',
    'ftp:',
    'data:',
  ]);
  $this
    ->assertEquals("script-src-attr 'unsafe-inline'", $policy
    ->getHeaderValue());
}