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
This commit is contained in:
Roeland Jago Douma 2016-02-26 11:38:06 +01:00
parent 62d7885c3b
commit bfcdf40a64
2 changed files with 17 additions and 1 deletions

View File

@ -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';
}
/**

View File

@ -746,12 +746,27 @@ 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() {
$share = $this->manager->newShare();