summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-09-04 17:15:08 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-09-12 23:43:20 +0200
commit05c970095d3e5fdce711aa92df7b79c027368ff6 (patch)
treec995b45ff115f3fe92781e378054e01af59a204a /tests
parentc7ca86799b2608609ead7ecd2d84d0bbd47c6548 (diff)
downloadnextcloud-server-05c970095d3e5fdce711aa92df7b79c027368ff6.tar.gz
nextcloud-server-05c970095d3e5fdce711aa92df7b79c027368ff6.zip
Test whether an expired user share is still accessible.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/share.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index e7d441a7e78..bce041a06f2 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -264,6 +264,39 @@ class Test_Share extends PHPUnit_Framework_TestCase {
$this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
}
+ public function testShareWithUserExpirationExpired()
+ {
+ 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.'
+ );
+ $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->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.'
+ );
+
+ 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.'
+ );
+
+ 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 testShareWithGroup() {
// Invalid shares
$message = 'Sharing test.txt failed, because the group foobar does not exist';