summaryrefslogtreecommitdiffstats
path: root/tests/lib/share
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-03-11 14:38:41 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-03-11 14:38:41 +0100
commitdbade1936206256f55f89c3f865be4046b8fb546 (patch)
tree40d0a30811d17d5e3ae26fe9348ac404eff0673d /tests/lib/share
parentad97ceb787ed859e01305d350acce2739d36be53 (diff)
parentb180724cd083d82cb8468c637e1a30e8f0ec993d (diff)
downloadnextcloud-server-dbade1936206256f55f89c3f865be4046b8fb546.tar.gz
nextcloud-server-dbade1936206256f55f89c3f865be4046b8fb546.zip
Merge pull request #13839 from owncloud/issue/13678-improve-remote-domain-detection-in-sharedropdown
Better finding the remote URL from user input in share dropdown
Diffstat (limited to 'tests/lib/share')
-rw-r--r--tests/lib/share/helper.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index 7a546410aea..0385263fd91 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -49,4 +49,55 @@ class Test_Share_Helper extends \Test\TestCase {
$result = \OC\Share\Helper::calculateExpireDate($defaultExpireSettings, $creationTime, $userExpireDate);
$this->assertSame($expected, $result);
}
+
+ public function fixRemoteURLInShareWithData() {
+ $userPrefix = ['test@', 'na/me@'];
+ $protocols = ['', 'http://', 'https://'];
+ $remotes = [
+ 'localhost',
+ 'test:foobar@localhost',
+ 'local.host',
+ 'dev.local.host',
+ 'dev.local.host/path',
+ '127.0.0.1',
+ '::1',
+ '::192.0.2.128',
+ ];
+
+ $testCases = [
+ ['test', 'test'],
+ ['na/me', 'na/me'],
+ ['na/me/', 'na/me'],
+ ['na/index.php', 'na/index.php'],
+ ['http://localhost', 'http://localhost'],
+ ['http://localhost/', 'http://localhost'],
+ ['http://localhost/index.php', 'http://localhost/index.php'],
+ ['http://localhost/index.php/s/token', 'http://localhost/index.php/s/token'],
+ ['http://test:foobar@localhost', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/index.php', 'http://test:foobar@localhost'],
+ ['http://test:foobar@localhost/index.php/s/token', 'http://test:foobar@localhost'],
+ ];
+
+ foreach ($userPrefix as $user) {
+ foreach ($remotes as $remote) {
+ foreach ($protocols as $protocol) {
+ $baseUrl = $user . $protocol . $remote;
+
+ $testCases[] = [$baseUrl, $baseUrl];
+ $testCases[] = [$baseUrl . '/', $baseUrl];
+ $testCases[] = [$baseUrl . '/index.php', $baseUrl];
+ $testCases[] = [$baseUrl . '/index.php/s/token', $baseUrl];
+ }
+ }
+ }
+ return $testCases;
+ }
+
+ /**
+ * @dataProvider fixRemoteURLInShareWithData
+ */
+ public function testFixRemoteURLInShareWith($remote, $expected) {
+ $this->assertSame($expected, \OC\Share\Helper::fixRemoteURLInShareWith($remote));
+ }
}