diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-06-18 09:21:06 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-22 15:25:23 +0200 |
commit | d38a378b8cc8d13e6459ccb4cfbc8a8bbe1f8428 (patch) | |
tree | 703cc3a64712860e919913d33ea883405927de48 /tests | |
parent | a88b370dc84c4dfdcab7a128900829fbe8204ca7 (diff) | |
download | nextcloud-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.php | 39 |
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(''), + ); + } } |