Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-03-23 16:52:04 +0300
committerJoas Schilling <coding@schilljs.com>2021-04-22 17:34:13 +0300
commitd80cc76ee7f3f1f347fc54cc300e5e38ba7d6e19 (patch)
treef9e885f7c84ef77d487a95ffe56dc62c845b8005 /tests/lib/Accounts
parenta011b7021ef7153acce6978a1c65db0a8c7ec32d (diff)
Validate the website field input to be a valid URL
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Accounts')
-rw-r--r--tests/lib/Accounts/AccountManagerTest.php26
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]));
+ }
+ }
}