From dd3307dd19bb2b61b194ba7962035a6ceae64249 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 19 Mar 2015 10:47:09 +0100 Subject: Added unit test Tests added to make sure that removing an expire date when this is enforced is not allowed. --- apps/files_sharing/tests/api.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'apps') diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index 9256f9bcc85..371c94a8c88 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -1079,6 +1079,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'); -- cgit v1.2.3