diff options
author | Björn Schießle <schiessle@owncloud.com> | 2014-06-06 19:24:15 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2014-06-06 19:24:15 +0200 |
commit | 3da47db33cd9a676a1f5b51a8c8ed1abe617ce3e (patch) | |
tree | fb349c85f68d736aed93ff9bf9167199879aa1bb /tests | |
parent | dfe6bd61bf315693dd447cda0f66d5a4c23128f1 (diff) | |
parent | 9c00f5ddb61507f7bd02a79e2a62339b45b20c0b (diff) | |
download | nextcloud-server-3da47db33cd9a676a1f5b51a8c8ed1abe617ce3e.tar.gz nextcloud-server-3da47db33cd9a676a1f5b51a8c8ed1abe617ce3e.zip |
Merge pull request #8927 from owncloud/expire_only_link_shares
only expire link shares
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 77 |
1 files changed, 18 insertions, 59 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 95983ee70e6..5920b44a8e0 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -151,6 +151,12 @@ class Test_Share extends PHPUnit_Framework_TestCase { ); } + protected function shareUserTestFileAsLink() { + OC_User::setUserId($this->user1); + $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ); + $this->assertTrue(is_string($result)); + } + /** * @param string $sharer * @param string $receiver @@ -316,36 +322,35 @@ class Test_Share extends PHPUnit_Framework_TestCase { } public function testShareWithUserExpirationExpired() { + OC_User::setUserId($this->user1); $this->shareUserOneTestFileWithUserTwo(); + $this->shareUserTestFileAsLink(); - OC_User::setUserId($this->user1); $this->assertTrue( OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast), 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' ); - OC_User::setUserId($this->user2); - $this->assertSame(array(), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 2 no longer has access to test.txt after expiration.' - ); + $shares = OCP\Share::getItemsShared('test'); + $this->assertSame(1, count($shares)); + $share = reset($shares); + $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']); } public function testShareWithUserExpirationValid() { + OC_User::setUserId($this->user1); $this->shareUserOneTestFileWithUserTwo(); + $this->shareUserTestFileAsLink(); + - OC_User::setUserId($this->user1); $this->assertTrue( OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture), 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' ); - OC_User::setUserId($this->user2); - $this->assertEquals( - array('test.txt'), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 2 still has access to test.txt after expiration date has been set.' - ); + $shares = OCP\Share::getItemsShared('test'); + $this->assertSame(2, count($shares)); + } protected function shareUserOneTestFileWithGroupOne() { @@ -516,52 +521,6 @@ class Test_Share extends PHPUnit_Framework_TestCase { $this->assertEquals(array(), OCP\Share::getItemsShared('test')); } - public function testShareWithGroupExpirationExpired() { - $this->shareUserOneTestFileWithGroupOne(); - - OC_User::setUserId($this->user1); - $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast), - 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' - ); - - OC_User::setUserId($this->user2); - $this->assertSame(array(), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 2 no longer has access to test.txt after expiration.' - ); - - OC_User::setUserId($this->user3); - $this->assertSame(array(), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 3 no longer has access to test.txt after expiration.' - ); - } - - public function testShareWithGroupExpirationValid() { - $this->shareUserOneTestFileWithGroupOne(); - - OC_User::setUserId($this->user1); - $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture), - 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' - ); - - OC_User::setUserId($this->user2); - $this->assertEquals( - array('test.txt'), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 2 still has access to test.txt after expiration date has been set.' - ); - - OC_User::setUserId($this->user3); - $this->assertEquals( - array('test.txt'), - OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that user 3 still has access to test.txt after expiration date has been set.' - ); - } - /** * @param boolean|string $token */ |