diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-23 14:52:04 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-04-22 16:34:13 +0200 |
commit | d80cc76ee7f3f1f347fc54cc300e5e38ba7d6e19 (patch) | |
tree | f9e885f7c84ef77d487a95ffe56dc62c845b8005 /tests | |
parent | a011b7021ef7153acce6978a1c65db0a8c7ec32d (diff) | |
download | nextcloud-server-d80cc76ee7f3f1f347fc54cc300e5e38ba7d6e19.tar.gz nextcloud-server-d80cc76ee7f3f1f347fc54cc300e5e38ba7d6e19.zip |
Validate the website field input to be a valid URL
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Accounts/AccountManagerTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index 27ebed69793..687ae29ff7b 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -455,4 +455,30 @@ class AccountManagerTest extends TestCase { self::assertEquals($phoneNumber, self::invokePrivate($instance, 'parsePhoneNumber', [$phoneInput])); } } + + public function dataParseWebsite(): array { + return [ + ['https://nextcloud.com', 'https://nextcloud.com'], + ['http://nextcloud.com', 'http://nextcloud.com'], + ['ftp://nextcloud.com', null], + ['//nextcloud.com/', null], + ['https:///?query', null], + ]; + } + + /** + * @dataProvider dataParseWebsite + * @param string $websiteInput + * @param string|null $websiteOutput + */ + public function testParseWebsite(string $websiteInput, ?string $websiteOutput): void { + $instance = $this->getInstance(); + + if ($websiteOutput === null) { + $this->expectException(\InvalidArgumentException::class); + self::invokePrivate($instance, 'parseWebsite', [$websiteInput]); + } else { + self::assertEquals($websiteOutput, self::invokePrivate($instance, 'parseWebsite', [$websiteInput])); + } + } } |