summaryrefslogtreecommitdiffstats
path: root/tests/lib/share
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-06-18 11:46:37 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-06-22 15:25:23 +0200
commit2b7e5f841a016e8682d560643dce4797758a44c3 (patch)
treebc7216a8a82fe0986bae5ec9fecf33acbfe73275 /tests/lib/share
parentd38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428 (diff)
downloadnextcloud-server-2b7e5f841a016e8682d560643dce4797758a44c3.tar.gz
nextcloud-server-2b7e5f841a016e8682d560643dce4797758a44c3.zip
Merge spliteUserRemote with fixRemoteUrlInShareWith
Diffstat (limited to 'tests/lib/share')
-rw-r--r--tests/lib/share/helper.php80
1 files changed, 31 insertions, 49 deletions
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index 0dfb85856c2..c91d0bdde30 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -50,44 +50,31 @@ class Test_Share_Helper extends \Test\TestCase {
$this->assertSame($expected, $result);
}
- public function fixRemoteURLInShareWithData() {
- $userPrefix = ['test@', 'na/me@'];
+ public function dataTestSplitUserRemote() {
+ $userPrefix = ['user@name', 'username'];
$protocols = ['', 'http://', 'https://'];
$remotes = [
'localhost',
- 'test:foobar@localhost',
'local.host',
'dev.local.host',
'dev.local.host/path',
+ 'dev.local.host/at@inpath',
'127.0.0.1',
'::1',
'::192.0.2.128',
+ '::192.0.2.128/at@inpath',
];
- $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'],
- ];
-
+ $testCases = [];
foreach ($userPrefix as $user) {
foreach ($remotes as $remote) {
foreach ($protocols as $protocol) {
- $baseUrl = $user . $protocol . $remote;
+ $baseUrl = $user . '@' . $protocol . $remote;
- $testCases[] = [$baseUrl, $baseUrl];
- $testCases[] = [$baseUrl . '/', $baseUrl];
- $testCases[] = [$baseUrl . '/index.php', $baseUrl];
- $testCases[] = [$baseUrl . '/index.php/s/token', $baseUrl];
+ $testCases[] = [$baseUrl, $user, $protocol . $remote];
+ $testCases[] = [$baseUrl . '/', $user, $protocol . $remote];
+ $testCases[] = [$baseUrl . '/index.php', $user, $protocol . $remote];
+ $testCases[] = [$baseUrl . '/index.php/s/token', $user, $protocol . $remote];
}
}
}
@@ -95,29 +82,33 @@ class Test_Share_Helper extends \Test\TestCase {
}
/**
- * @dataProvider fixRemoteURLInShareWithData
- */
- public function testFixRemoteURLInShareWith($remote, $expected) {
- $this->assertSame($expected, \OC\Share\Helper::fixRemoteURLInShareWith($remote));
- }
-
- /**
- * @dataProvider dataTestSplitUserRemoteSuccess
+ * @dataProvider dataTestSplitUserRemote
*
- * @param string $id
+ * @param string $remote
* @param string $expectedUser
- * @param string $expectedRemote
+ * @param string $expectedUrl
*/
- public function testSplitUserRemoteSuccess($id, $expectedUser, $expectedRemote) {
- list($user, $remote) = \OC\Share\Helper::splitUserRemote($id);
- $this->assertSame($expectedUser, $user);
- $this->assertSame($expectedRemote, $remote);
+ public function testSplitUserRemote($remote, $expectedUser, $expectedUrl) {
+ list($remoteUser, $remoteUrl) = \OC\Share\Helper::splitUserRemote($remote);
+ $this->assertSame($expectedUser, $remoteUser);
+ $this->assertSame($expectedUrl, $remoteUrl);
}
- public function dataTestSplitUserRemoteSuccess() {
+ public function dataTestSplitUserRemoteError() {
return array(
- array('user@server', 'user', 'server'),
- array('user@name@server', 'user@name', 'server')
+ // Invalid path
+ array('user@'),
+
+ // Invalid user
+ array('@server'),
+ array('us/er@server'),
+ array('us:er@server'),
+
+ // Invalid splitting
+ array('user'),
+ array(''),
+ array('us/erserver'),
+ array('us:erserver'),
);
}
@@ -130,13 +121,4 @@ class Test_Share_Helper extends \Test\TestCase {
public function testSplitUserRemoteError($id) {
\OC\Share\Helper::splitUserRemote($id);
}
-
- public function dataTestSplitUserRemoteError() {
- return array(
- array('user@'),
- array('@server'),
- array('user'),
- array(''),
- );
- }
}