diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-26 11:38:06 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-26 11:38:06 +0100 |
commit | bfcdf40a64fd3217803c59c4e2057fc573407595 (patch) | |
tree | 0a8a4277ed58552910fb8026cc6b9d4f7be046f0 | |
parent | 62d7885c3b13d7d2acf33f80e91016a82cc8a7c0 (diff) | |
download | nextcloud-server-bfcdf40a64fd3217803c59c4e2057fc573407595.tar.gz nextcloud-server-bfcdf40a64fd3217803c59c4e2057fc573407595.zip |
Expiration date can only be enforced if default is enabled
If the default expiration date is not enebaled it can not be enforced.
* Added unit tests
-rw-r--r-- | lib/private/share20/manager.php | 3 | ||||
-rw-r--r-- | tests/lib/share20/managertest.php | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 6932360a7e9..df125ea6fc1 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -1079,7 +1079,8 @@ class Manager implements IManager { * @return bool */ public function shareApiLinkDefaultExpireDateEnforced() { - return $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; + return $this->shareApiLinkDefaultExpireDate() && + $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; } /** diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index 2c40bf65c2c..d388d56ce3d 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -746,10 +746,25 @@ class ManagerTest extends \Test\TestCase { $this->config->method('getAppValue') ->will($this->returnValueMap([ + ['core', 'shareapi_default_expire_date', 'no', 'yes'], + ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], + ])); + + $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); + } + + public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() { + $share = $this->manager->newShare(); + $share->setProviderId('foo')->setId('bar'); + + $this->config->method('getAppValue') + ->will($this->returnValueMap([ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ])); $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]); + + $this->assertNull($share->getExpirationDate()); } public function testvalidateExpirationDateEnforceButNotSetNewShare() { |