public function CoreCspSubscriberTest::testCkeditorScriptNoDirectives in Content-Security-Policy 8
CKEditor shouldn't alter the policy if no directives are enabled.
@covers ::onCspPolicyAlter
File
- tests/
src/ Unit/ EventSubscriber/ CoreCspSubscriberTest.php, line 106
Class
- CoreCspSubscriberTest
- @coversDefaultClass \Drupal\csp\EventSubscriber\CoreCspSubscriber @group csp
Namespace
Drupal\Tests\csp\Unit\EventSubscriberCode
public function testCkeditorScriptNoDirectives() {
$policy = new Csp();
$this->response
->method('getAttachments')
->willReturn([
'library' => [
'core/ckeditor',
],
]);
$alterEvent = new PolicyAlterEvent($policy, $this->response);
$this->coreCspSubscriber
->onCspPolicyAlter($alterEvent);
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src'));
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src-attr'));
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src-elem'));
}