diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-09-23 10:27:35 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-09-25 13:06:05 +0200 |
commit | 9a373cb5bbe2cc56ba96f1a6dff298912f4d88e7 (patch) | |
tree | 2825e1a192b36e3b6a93425dd04b32571bd02bef /tests/lib/share | |
parent | bf73665a35470432ae939a70eb91ecf9f8933240 (diff) | |
download | nextcloud-server-9a373cb5bbe2cc56ba96f1a6dff298912f4d88e7.tar.gz nextcloud-server-9a373cb5bbe2cc56ba96f1a6dff298912f4d88e7.zip |
Do not blindy copy expiration date on reshare
If a file/folder is reshared we should not blindly copy the expiration
date of the parent share. User/Group shares do not have expiration dates
currently, and thus this is always set to null.
Fixes #19119
* Added testcase
Diffstat (limited to 'tests/lib/share')
-rw-r--r-- | tests/lib/share/share.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index ef0d9822085..58a76470afa 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -1567,6 +1567,43 @@ class Test_Share extends \Test\TestCase { $this->setHttpHelper($oldHttpHelper); } + /** + * Test case for #19119 + */ + public function testReshareWithLinkDefaultExpirationDate() { + $config = \OC::$server->getConfig(); + $config->setAppValue('core', 'shareapi_default_expire_date', 'yes'); + $config->setAppValue('core', 'shareapi_expire_after_n_days', '2'); + + // Expiration date + $expireAt = time() + 2 * 24*60*60; + $date = new DateTime(); + $date->setTimestamp($expireAt); + $date->setTime(0, 0, 0); + + //Share a file from user 1 to user 2 + $this->shareUserTestFileWithUser($this->user1, $this->user2); + + //User 2 shares as link + OC_User::setUserId($this->user2); + $result = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ); + $this->assertTrue(is_string($result)); + + //Check if expire date is correct + $result = OCP\Share::getItemShared('test', 'test.txt'); + $this->assertCount(1, $result); + $result = reset($result); + $this->assertNotEmpty($result['expiration']); + $expireDate = new DateTime($result['expiration']); + $this->assertEquals($date, $expireDate); + + //Unshare + $this->assertTrue(OCP\Share::unshareAll('test', 'test.txt')); + + //Reset config + $config->deleteAppValue('core', 'shareapi_default_expire_date'); + $config->deleteAppValue('core', 'shareapi_expire_after_n_days'); + } } class DummyShareClass extends \OC\Share\Share { |