summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-03-19 10:07:17 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2015-03-20 09:30:39 +0100
commit9d0ea7fa11ec81bca602b1bd08f1de4e2aa6d58c (patch)
tree422da6f773bccca00af104ebe6887bf46eeb91e9 /apps/files_sharing/tests
parent4774d648bdba77c96604b29dbbc89a7736b56a8c (diff)
downloadnextcloud-server-9d0ea7fa11ec81bca602b1bd08f1de4e2aa6d58c.tar.gz
nextcloud-server-9d0ea7fa11ec81bca602b1bd08f1de4e2aa6d58c.zip
Backport of #15025
When the expiration date is enforced respect this - Make sure that we do not allow removing of the expiration date when this is enforced in the settings. - Added unit test
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/api.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php
index 278e7130199..232fcf28cd3 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -1008,6 +1008,24 @@ class Test_Files_Sharing_Api extends TestCase {
$this->assertTrue(is_array($updatedLinkShare));
$this->assertEquals($dateWithinRange->format('Y-m-d') . ' 00:00:00', $updatedLinkShare['expiration']);
+
+ // Try to remove expire date
+ $params = array();
+ $params['id'] = $linkShare['id'];
+ $params['_put'] = ['expireDate' => ''];
+
+ $result = \OCA\Files_Sharing\API\Local::updateShare($params);
+
+ $this->assertFalse($result->succeeded());
+
+ $items = \OCP\Share::getItemShared('file', $linkShare['file_source']);
+
+ $updatedLinkShare = reset($items);
+
+ // date shouldn't be changed
+ $this->assertTrue(is_array($updatedLinkShare));
+ $this->assertEquals($dateWithinRange->format('Y-m-d') . ' 00:00:00', $updatedLinkShare['expiration']);
+
// cleanup
$config->setAppValue('core', 'shareapi_default_expire_date', 'no');
$config->setAppValue('core', 'shareapi_enforce_expire_date', 'no');