2015-02-09 18:30:01 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2015 Lukas Reschke lukas@owncloud.com
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2016-05-18 19:40:34 +03:00
|
|
|
namespace Test\AppFramework\Http;
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ContentSecurityPolicyTest
|
|
|
|
*
|
|
|
|
* @package OC\AppFramework\Http
|
|
|
|
*/
|
|
|
|
class ContentSecurityPolicyTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
/** @var ContentSecurityPolicy */
|
|
|
|
private $contentSecurityPolicy;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2015-02-09 18:30:01 +03:00
|
|
|
parent::setUp();
|
|
|
|
$this->contentSecurityPolicy = new ContentSecurityPolicy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDefault() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$defaultPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
$this->assertSame($defaultPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyScriptDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' www.owncloud.com;style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyScriptDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' www.owncloud.com www.owncloud.org;style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowScriptDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowScriptDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' www.owncloud.com;style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowScriptDomainMultipleStacked() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowScriptDomain('www.owncloud.org')->disallowScriptDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyScriptAllowInline() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' 'unsafe-inline';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->allowInlineScript(true);
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyScriptAllowInlineWithDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' www.owncloud.com 'unsafe-inline';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedScriptDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->allowInlineScript(true);
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyScriptDisallowInlineAndEval() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->allowInlineScript(false);
|
2015-02-16 14:30:21 +03:00
|
|
|
$this->contentSecurityPolicy->allowEvalScript(false);
|
2015-02-09 18:30:01 +03:00
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyStyleDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyStyleDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' www.owncloud.com www.owncloud.org 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowStyleDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowStyleDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowStyleDomainMultipleStacked() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowStyleDomain('www.owncloud.org')->disallowStyleDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyStyleAllowInline() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->allowInlineStyle(true);
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyStyleAllowInlineWithDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' www.owncloud.com 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedStyleDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyStyleDisallowInline() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->allowInlineStyle(false);
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyImageDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob: www.owncloud.com;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyImageDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob: www.owncloud.com www.owncloud.org;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowImageDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowImageDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob: www.owncloud.com;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowImageDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedImageDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowImageDomain('www.owncloud.org')->disallowImageDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyFontDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data: www.owncloud.com;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyFontDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data: www.owncloud.com www.owncloud.org;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowFontDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFontDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data: www.owncloud.com;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFontDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFontDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFontDomain('www.owncloud.org')->disallowFontDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyConnectDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self' www.owncloud.com;media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyConnectDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self' www.owncloud.com www.owncloud.org;media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowConnectDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowConnectDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self' www.owncloud.com;media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowConnectDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedConnectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowConnectDomain('www.owncloud.org')->disallowConnectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyMediaDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self' www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyMediaDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self' www.owncloud.com www.owncloud.org;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowMediaDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowMediaDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self' www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowMediaDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedMediaDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowMediaDomain('www.owncloud.org')->disallowMediaDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetPolicyObjectDomainValid() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';object-src www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyObjectDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';object-src www.owncloud.com www.owncloud.org;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowObjectDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowObjectDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';object-src www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowObjectDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedObjectDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowObjectDomain('www.owncloud.org')->disallowObjectDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-09 18:30:01 +03:00
|
|
|
public function testGetAllowedFrameDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-src www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyFrameDomainValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-src www.owncloud.com www.owncloud.org;frame-ancestors 'self';form-action 'self'";
|
2015-02-09 18:30:01 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-05-20 12:44:37 +03:00
|
|
|
public function testGetPolicyDisallowFrameDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFrameDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-src www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFrameDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFrameDomain('www.owncloud.org')->disallowFrameDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
2015-02-26 14:54:15 +03:00
|
|
|
public function testGetAllowedChildSrcDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';child-src child.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-02-26 14:54:15 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyChildSrcValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';child-src child.owncloud.com child.owncloud.org;frame-ancestors 'self';form-action 'self'";
|
2015-02-26 14:54:15 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('child.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
2015-05-20 12:44:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowChildSrcDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowChildSrcDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';child-src www.owncloud.com;frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowChildSrcDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2015-05-20 12:44:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.org')->disallowChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
2015-02-26 14:54:15 +03:00
|
|
|
}
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetAllowedFrameAncestorDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self' sub.nextcloud.com;form-action 'self'";
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameAncestorDomain('sub.nextcloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyFrameAncestorValidMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self' sub.nextcloud.com foo.nextcloud.com;form-action 'self'";
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameAncestorDomain('sub.nextcloud.com');
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameAncestorDomain('foo.nextcloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFrameAncestorDomain() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameAncestorDomain('www.nextcloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFrameAncestorDomain('www.nextcloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFrameAncestorDomainMultiple() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self' www.nextcloud.com;form-action 'self'";
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedFrameAncestorDomain('www.nextcloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowFrameAncestorDomain('www.nextcloud.org');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPolicyDisallowFrameAncestorDomainMultipleStakes() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2017-06-19 14:55:46 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->addAllowedChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->contentSecurityPolicy->disallowChildSrcDomain('www.owncloud.org')->disallowChildSrcDomain('www.owncloud.com');
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
2018-09-03 16:28:37 +03:00
|
|
|
|
|
|
|
public function testGetPolicyUnsafeEval() {
|
2019-07-31 10:03:33 +03:00
|
|
|
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
|
2018-09-03 16:28:37 +03:00
|
|
|
|
|
|
|
$this->contentSecurityPolicy->allowEvalScript(true);
|
|
|
|
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
|
|
|
|
}
|
2015-02-09 18:30:01 +03:00
|
|
|
}
|