X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FContentSecurityPolicyTest.php;h=5d6c0677bd7f6ee44507e45cab631805ed1d7286;hb=b5f06bbd12193e3f4dfa00342f882de8afb72c52;hp=a758f990c920aa044a0d9c8d82e064b64c46c2e0;hpb=3b0ff76e9563039f45ad34b01b81576142e150c3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/ContentSecurityPolicyTest.php b/tests/phpunit/includes/ContentSecurityPolicyTest.php index a758f990c9..5d6c0677bd 100644 --- a/tests/phpunit/includes/ContentSecurityPolicyTest.php +++ b/tests/phpunit/includes/ContentSecurityPolicyTest.php @@ -13,6 +13,10 @@ class ContentSecurityPolicyTest extends MediaWikiTestCase { 'wgAllowExternalImagesFrom' => [], 'wgAllowImageTag' => false, 'wgEnableImageWhitelist' => false, + 'wgLoadScript' => false, + 'wgExtensionAssetsPath' => false, + 'wgStylePath' => false, + 'wgResourceBasePath' => null, 'wgCrossSiteAJAXdomains' => [ 'sister-site.somewhere.com', '*.wikipedia.org', @@ -47,6 +51,29 @@ class ContentSecurityPolicyTest extends MediaWikiTestCase { return parent::setUp(); } + /** + * @covers ContentSecurityPolicy::getAdditionalSelfUrls + */ + public function testGetAdditionalSelfUrlsRespectsUrlSettings() { + $this->setMwGlobals( 'wgLoadScript', 'https://wgLoadScript.example.org/load.php' ); + $this->setMwGlobals( 'wgExtensionAssetsPath', + 'https://wgExtensionAssetsPath.example.org/assets/' ); + $this->setMwGlobals( 'wgStylePath', 'https://wgStylePath.example.org/style/' ); + $this->setMwGlobals( 'wgResourceBasePath', 'https://wgResourceBasePath.example.org/resources/' ); + + $this->assertEquals( + [ + 'https://upload.wikimedia.org', + 'https://commons.wikimedia.org', + 'https://wgLoadScript.example.org', + 'https://wgExtensionAssetsPath.example.org', + 'https://wgStylePath.example.org', + 'https://wgResourceBasePath.example.org', + ], + array_values( $this->csp->getAdditionalSelfUrls() ) + ); + } + /** * @dataProvider providerFalsePositiveBrowser * @covers ContentSecurityPolicy::falsePositiveBrowser