summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-06-18 09:21:06 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-06-22 15:25:23 +0200
commitd38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428 (patch)
tree703cc3a64712860e919913d33ea883405927de48 /tests
parenta88b370dc84c4dfdcab7a128900829fbe8204ca7 (diff)
downloadnextcloud-server-d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428.tar.gz
nextcloud-server-d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428.zip
make sure that we split username and server address at the first '@' from the right to allow usernames containing '@'
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/helper.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/lib/share/helper.php b/tests/lib/share/helper.php
index 0385263fd91..0dfb85856c2 100644
--- a/tests/lib/share/helper.php
+++ b/tests/lib/share/helper.php
@@ -100,4 +100,43 @@ class Test_Share_Helper extends \Test\TestCase {
public function testFixRemoteURLInShareWith($remote, $expected) {
$this->assertSame($expected, \OC\Share\Helper::fixRemoteURLInShareWith($remote));
}
+
+ /**
+ * @dataProvider dataTestSplitUserRemoteSuccess
+ *
+ * @param string $id
+ * @param string $expectedUser
+ * @param string $expectedRemote
+ */
+ public function testSplitUserRemoteSuccess($id, $expectedUser, $expectedRemote) {
+ list($user, $remote) = \OC\Share\Helper::splitUserRemote($id);
+ $this->assertSame($expectedUser, $user);
+ $this->assertSame($expectedRemote, $remote);
+ }
+
+ public function dataTestSplitUserRemoteSuccess() {
+ return array(
+ array('user@server', 'user', 'server'),
+ array('user@name@server', 'user@name', 'server')
+ );
+ }
+
+ /**
+ * @dataProvider dataTestSplitUserRemoteError
+ *
+ * @param string $id
+ * @expectedException \OC\Share\Exceptions\InvalidFederatedCloudIdException
+ */
+ public function testSplitUserRemoteError($id) {
+ \OC\Share\Helper::splitUserRemote($id);
+ }
+
+ public function dataTestSplitUserRemoteError() {
+ return array(
+ array('user@'),
+ array('@server'),
+ array('user'),
+ array(''),
+ );
+ }
}