diff options
author | Joas Schilling <coding@schilljs.com> | 2021-10-26 13:26:46 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-10-28 10:24:16 +0200 |
commit | c42f5bc5f666290b99a1662b9048d3163bee0be9 (patch) | |
tree | 52a7152703a8df66acada84adb223845d4389917 /tests | |
parent | d231d2618de78b87cbc3916109652f0432fee607 (diff) | |
download | nextcloud-server-c42f5bc5f666290b99a1662b9048d3163bee0be9.tar.gz nextcloud-server-c42f5bc5f666290b99a1662b9048d3163bee0be9.zip |
Add an OCP for trusted domain helper
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Security/TrustedDomainHelperTest.php | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php index aedc4cb6a17..3fedf8964c5 100644 --- a/tests/lib/Security/TrustedDomainHelperTest.php +++ b/tests/lib/Security/TrustedDomainHelperTest.php @@ -33,15 +33,29 @@ class TrustedDomainHelperTest extends \Test\TestCase { * @param string $testDomain * @param bool $result */ + public function testIsTrustedUrl($trustedDomains, $testDomain, $result) { + $this->config->method('getSystemValue') + ->willReturnMap([ + ['overwritehost', '', ''], + ['trusted_domains', [], $trustedDomains], + ]); + + $trustedDomainHelper = new TrustedDomainHelper($this->config); + $this->assertEquals($result, $trustedDomainHelper->isTrustedUrl('https://' . $testDomain . '/index.php/something')); + } + + /** + * @dataProvider trustedDomainDataProvider + * @param string $trustedDomains + * @param string $testDomain + * @param bool $result + */ public function testIsTrustedDomain($trustedDomains, $testDomain, $result) { - $this->config->expects($this->at(0)) - ->method('getSystemValue') - ->with('overwritehost') - ->willReturn(''); - $this->config->expects($this->at(1)) - ->method('getSystemValue') - ->with('trusted_domains') - ->willReturn($trustedDomains); + $this->config->method('getSystemValue') + ->willReturnMap([ + ['overwritehost', '', ''], + ['trusted_domains', [], $trustedDomains], + ]); $trustedDomainHelper = new TrustedDomainHelper($this->config); $this->assertEquals($result, $trustedDomainHelper->isTrustedDomain($testDomain)); @@ -122,8 +136,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { } public function testIsTrustedDomainOverwriteHost() { - $this->config->expects($this->at(0)) - ->method('getSystemValue') + $this->config->method('getSystemValue') ->with('overwritehost') ->willReturn('myproxyhost'); |