diff options
Diffstat (limited to 'apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php')
-rw-r--r-- | apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php b/apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php index 5318955e421..e51546c1cf1 100644 --- a/apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php +++ b/apps/settings/tests/SetupChecks/CheckServerResponseTraitTest.php @@ -51,16 +51,27 @@ class CheckServerResponseTraitTest extends TestCase { /** * @dataProvider dataNormalizeUrl */ - public function testNormalizeUrl(string $url, string $webRoot, bool $removeWebRoot, string $expected): void { - $this->assertEquals($expected, $this->trait->normalizeUrl($url, $webRoot, $removeWebRoot)); + public function testNormalizeUrl(string $url, bool $isRootRequest, string $expected): void { + $this->assertEquals($expected, $this->trait->normalizeUrl($url, $isRootRequest)); } public static function dataNormalizeUrl(): array { return [ - 'valid and nothing to change' => ['http://example.com/root', '/root', false, 'http://example.com/root'], - 'trailing slash' => ['http://example.com/root/', '/root', false, 'http://example.com/root'], - 'remove web root' => ['http://example.com/root/', '/root', true, 'http://example.com'], - 'remove web root but empty' => ['http://example.com', '', true, 'http://example.com'], + // untouched web-root + 'valid and nothing to change' => ['http://example.com/root', false, 'http://example.com/root'], + 'valid with port and nothing to change' => ['http://example.com:8081/root', false, 'http://example.com:8081/root'], + 'trailing slash' => ['http://example.com/root/', false, 'http://example.com/root'], + 'deep web root' => ['http://example.com/deep/webroot', false, 'http://example.com/deep/webroot'], + // removal of the web-root + 'remove web root' => ['http://example.com/root/', true, 'http://example.com'], + 'remove web root but empty' => ['http://example.com', true, 'http://example.com'], + 'remove deep web root' => ['http://example.com/deep/webroot', true, 'http://example.com'], + 'remove web root with port' => ['http://example.com:8081/root', true, 'http://example.com:8081'], + 'remove web root with port but empty' => ['http://example.com:8081', true, 'http://example.com:8081'], + 'remove web root from IP' => ['https://127.0.0.1/root', true, 'https://127.0.0.1'], + 'remove web root from IP with port' => ['https://127.0.0.1:8080/root', true, 'https://127.0.0.1:8080'], + 'remove web root from IPv6' => ['https://[ff02::1]/root', true, 'https://[ff02::1]'], + 'remove web root from IPv6 with port' => ['https://[ff02::1]:8080/root', true, 'https://[ff02::1]:8080'], ]; } @@ -69,7 +80,7 @@ class CheckServerResponseTraitTest extends TestCase { */ public function testGetTestUrls( string $url, - bool $removeWebRoot, + bool $isRootRequest, string $cliUrl, string $webRoot, array $trustedDomains, @@ -93,10 +104,13 @@ class CheckServerResponseTraitTest extends TestCase { ->method('getBaseUrl') ->willReturn(self::BASE_URL . $webRoot); - $result = $this->trait->getTestUrls($url, $removeWebRoot); + $result = $this->trait->getTestUrls($url, $isRootRequest); $this->assertEquals($expected, $result); } + /** + * @return array<string, list{string, bool, string, string, list<string>, list<string>}> + */ public static function dataGetTestUrls(): array { return [ 'same cli and base URL' => [ @@ -193,21 +207,6 @@ class CheckServerResponseTraitTest extends TestCase { 'http://192.168.100.1/.well-known/caldav', ] ], - // example if the URL is generated by the URL generator - 'remove web-root and web root in url' => [ - '/nextcloud/.well-known/caldav', true, 'https://example.com', '/nextcloud', ['nextcloud.local', 'example.com', '192.168.100.1'], [ - // from cli url (note that the CLI url has NO web root) - 'https://example.com/.well-known/caldav', - // from base url - 'https://nextcloud.local/.well-known/caldav', - // http variant from trusted domains - 'http://nextcloud.local/.well-known/caldav', - 'http://example.com/.well-known/caldav', - // trusted domains with web-root - 'https://192.168.100.1/.well-known/caldav', - 'http://192.168.100.1/.well-known/caldav', - ] - ], ]; } |