diff options
author | Andreas Fischer <bantu@owncloud.com> | 2013-09-04 19:26:30 +0400 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2013-09-24 01:58:54 +0400 |
commit | d3498153c3f5b14442fbdd17205c0afd5b6abfa4 (patch) | |
tree | 7c38c18853752b363015d9cf041efc7d5385af10 /tests | |
parent | d6c3b9488ec2bdc638ef867fcd9a4e2afef1293c (diff) |
Test whether a still-valid user share is still accessible.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index bce041a06f2..cf211817e3c 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -266,34 +266,57 @@ class Test_Share extends PHPUnit_Framework_TestCase { public function testShareWithUserExpirationExpired() { + $this->shareUserOneTestFileWithUserTwo(); + OC_User::setUserId($this->user1); $this->assertTrue( - OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ), - 'Failed asserting that user 1 successfully shared text.txt with user 2.' + OCP\Share::setExpirationDate('test', 'test.txt', '2000-01-01 00:00'), + 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' ); - $this->assertEquals( - array('test.txt'), - OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), - 'Failed asserting that test.txt is a shared file of user 1.' + + OC_User::setUserId($this->user2); + $this->assertFalse( + 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.' + ); + } + + public function testShareWithUserExpirationValid() + { + $this->shareUserOneTestFileWithUserTwo(); + + OC_User::setUserId($this->user1); + $this->assertTrue( + OCP\Share::setExpirationDate('test', 'test.txt', '2037-01-01 00:00'), + '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 has access to test.txt after initial sharing.' + 'Failed asserting that user 2 still has access to test.txt after expiration date has been set.' ); + } + protected function shareUserOneTestFileWithUserTwo() + { OC_User::setUserId($this->user1); $this->assertTrue( - OCP\Share::setExpirationDate('test', 'test.txt', '2000-01-01 00:00'), - 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.' + OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ), + 'Failed asserting that user 1 successfully shared text.txt with user 2.' + ); + $this->assertEquals( + array('test.txt'), + OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), + 'Failed asserting that test.txt is a shared file of user 1.' ); OC_User::setUserId($this->user2); - $this->assertFalse( + $this->assertEquals( + array('test.txt'), 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.' + 'Failed asserting that user 2 has access to test.txt after initial sharing.' ); } |