diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 17:08:18 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-25 17:08:18 -0400 |
commit | 30b58f56771aa54304069d40a62070c06f5308fc (patch) | |
tree | e0bb2bba21c561f96d27bb9cfc09d714aa21d332 /tests/lib/share | |
parent | 4d17ed2f71c8cbb0d34c039aa7953b2427ce5c78 (diff) | |
parent | f25ccaff59c135d7f1f22196bf266916ef131b35 (diff) | |
download | nextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.tar.gz nextcloud-server-30b58f56771aa54304069d40a62070c06f5308fc.zip |
Merge branch 'master' into share_api
Conflicts:
apps/calendar/js/loader.js
apps/contacts/index.php
apps/contacts/js/loader.js
apps/files/js/files.js
apps/files_sharing/sharedstorage.php
lib/filesystemview.php
Diffstat (limited to 'tests/lib/share')
-rw-r--r-- | tests/lib/share/backend.php | 66 | ||||
-rw-r--r-- | tests/lib/share/share.php | 161 |
2 files changed, 227 insertions, 0 deletions
diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php new file mode 100644 index 00000000000..4f2fcce235e --- /dev/null +++ b/tests/lib/share/backend.php @@ -0,0 +1,66 @@ +<?php +/** +* ownCloud +* +* @author Michael Gapczynski +* @copyright 2012 Michael Gapczynski mtgap@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +abstract class Test_Share_Backend extends UnitTestCase { + + protected $userBackend; + protected $user1; + protected $user2; + protected $groupBackend; + protected $group; + protected $itemType; + protected $item; + + public function setUp() { + OC_User::clearBackends(); + OC_User::useBackend('dummy'); + $this->user1 = uniqid('user_'); + $this->user2 = uniqid('user_'); + OC_User::createUser($this->user1, 'pass1'); + OC_User::createUser($this->user2, 'pass2'); + OC_Group::clearBackends(); + OC_Group::useBackend(new OC_Group_Dummy); + $this->group = uniqid('group_'); + OC_Group::createGroup($this->group); + } + + public function testShareWithUserNonExistentItem() { + $this->assertFalse(OCP\Share::share($this->itemType, uniqid('foobar_'), OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithUserItem() { + $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithGroupNonExistentItem() { + $this->assertFalse(OCP\Share::share($this->itemType, uniqid('foobar_'), OCP\Share::SHARETYPE_GROUP, $this->group, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithGroupItem() { + $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_GROUP, $this->group, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithUserAlreadySharedWith() { + $this->assertTrue(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); + $this->assertFalse(OCP\Share::share($this->itemType, $this->item, OCP\Share::SHARETYPE_USER, $this->user2, OCP\Share::PERMISSION_READ)); + } + +} diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php new file mode 100644 index 00000000000..eca2c9bc58a --- /dev/null +++ b/tests/lib/share/share.php @@ -0,0 +1,161 @@ +<?php +/** +* ownCloud +* +* @author Michael Gapczynski +* @copyright 2012 Michael Gapczynski mtgap@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +class Test_Share_Base extends UnitTestCase { + + protected $itemType; + protected $userBackend; + protected $user1; + protected $user2; + protected $groupBackend; + protected $group1; + protected $group2; + + + public function setUp() { + OC_User::clearBackends(); + OC_User::useBackend('dummy'); + $this->user1 = uniqid('user_'); + $this->user2 = uniqid('user_'); + OC_User::createUser($this->user1, 'pass1'); + OC_User::createUser($this->user2, 'pass2'); + OC_Group::clearBackends(); + OC_Group::useBackend(new OC_Group_Dummy); + $this->group1 = uniqid('group_'); + $this->group2 = uniqid('group_'); + OC_Group::createGroup($this->group1); + OC_Group::createGroup($this->group2); + } + + public function testShareInvalidShareType() { + $this->assertFalse(OCP\Share::share('file', 'test.txt', 'foobar', $this->user1, OCP\Share::PERMISSION_READ)); + } + + public function testShareInvalidItemType() { + $this->assertFalse(OCP\Share::share('foobar', 'test.txt', OCP\Share::SHARETYPE_USER, $this->user1, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithSelf() { + OC_User::setUserId($this->user1); + $this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_USER, $this->user1, OCP\Share::PERMISSION_READ)); + } + + public function testShareWithNonExistentUser() { + $this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_USER, 'foobar', OCP\Share::PERMISSION_READ)); + } + + public function testShareWithUserOwnerNotPartOfGroup() { + + } + + public function testShareWithUserAlreadySharedWith() { + + } + + public function testShareWithNonExistentGroup() { + $this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_GROUP, 'foobar', OCP\Share::PERMISSION_READ)); + } + + public function testShareWithGroupOwnerNotPartOfGroup() { + + } + + + public function testShareWithGroupItem() { + + } + + public function testUnshareInvalidShareType() { + + } + + public function testUnshareNonExistentItem() { + + } + + public function testUnshareFromUserItem() { + + } + + public function testUnshareFromGroupItem() { + + } + + + + + + // Test owner not in same group (false) + + + + // Test non-existant item type + + // Test valid item + + // Test existing shared item (false) + + // Test unsharing item + + // Test setting permissions + + // Test setting permissions not as owner (false) + + // Test setting target + + // Test setting target as owner (false) + + // Spam reshares + + + + // Test non-existant group + + + // Test owner not part of group + + // Test existing shared item with group + + // Test valid item, valid name for all users + + // Test unsharing item + + // Test item with name conflicts + + // Test unsharing item + + // Test setting permissions + + // Test setting target no name conflicts + + // Test setting target with conflicts + + // Spam reshares + + + + + + public function testPrivateLink() { + + } + +} |