From 1358b0078ab60efe341db0d7768ad9cdfe4e2bea Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 4 Sep 2013 17:26:30 +0200 Subject: [PATCH] Test whether a still-valid user share is still accessible. --- tests/lib/share/share.php | 47 +++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index bce041a06f..cf211817e3 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -265,6 +265,41 @@ class Test_Share extends PHPUnit_Framework_TestCase { } public function testShareWithUserExpirationExpired() + { + $this->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.' + ); + + 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 still has access to test.txt after expiration date has been set.' + ); + } + + protected function shareUserOneTestFileWithUserTwo() { OC_User::setUserId($this->user1); $this->assertTrue( @@ -283,18 +318,6 @@ class Test_Share extends PHPUnit_Framework_TestCase { 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() {