Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-09-14 19:56:55 +0400
committerAndreas Fischer <bantu@owncloud.com>2013-10-09 15:25:38 +0400
commit6c683baccb3a75a171553ddb91930c216ab5d540 (patch)
tree1904230105deae08082037cc2c3e3da6c5160331 /tests
parentde7861928f473ec136c394b72ddf6c372ba28cec (diff)
Tests whether expired/valid link share is still accessible.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share/share.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index e02b0e4354d..8e9eef65d32 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -535,4 +535,52 @@ class Test_Share extends PHPUnit_Framework_TestCase {
'Failed asserting that user 3 still has access to test.txt after expiration date has been set.'
);
}
+
+ protected function getShareByValidToken($token) {
+ $row = OCP\Share::getShareByToken($token);
+ $this->assertInternalType(
+ 'array',
+ $row,
+ "Failed asserting that a share for token $token exists."
+ );
+ return $row;
+ }
+
+ public function testShareItemWithLink() {
+ OC_User::setUserId($this->user1);
+ $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ);
+ $this->assertInternalType(
+ 'string',
+ $token,
+ 'Failed asserting that user 1 successfully shared text.txt as link with token.'
+ );
+
+ // testGetShareByTokenNoExpiration
+ $row = $this->getShareByValidToken($token);
+ $this->assertEmpty(
+ $row['expiration'],
+ 'Failed asserting that the returned row does not have an expiration date.'
+ );
+
+ // testGetShareByTokenExpirationValid
+ $this->assertTrue(
+ OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInFuture),
+ 'Failed asserting that user 1 successfully set a future expiration date for the test.txt share.'
+ );
+ $row = $this->getShareByValidToken($token);
+ $this->assertNotEmpty(
+ $row['expiration'],
+ 'Failed asserting that the returned row has an expiration date.'
+ );
+
+ // testGetShareByTokenExpirationExpired
+ $this->assertTrue(
+ OCP\Share::setExpirationDate('test', 'test.txt', $this->dateInPast),
+ 'Failed asserting that user 1 successfully set a past expiration date for the test.txt share.'
+ );
+ $this->assertFalse(
+ OCP\Share::getShareByToken($token),
+ 'Failed asserting that an expired share could not be found.'
+ );
+ }
}