diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-11-11 19:36:04 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-11-16 13:19:51 +0000 |
commit | 94648f1ecdc567b3ed2a09299d69c487c65811c4 (patch) | |
tree | 7709fd2b7797fe3ddb303a685474cd40e5e35b47 /tests | |
parent | 24f067bdaf8fe8316282b4ee71a2155462e24572 (diff) | |
download | nextcloud-server-94648f1ecdc567b3ed2a09299d69c487c65811c4.tar.gz nextcloud-server-94648f1ecdc567b3ed2a09299d69c487c65811c4.zip |
Add unit tests to enforce a relaxed default share expiration date
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 19232504eb2..aa3f1e93ff0 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -830,6 +830,27 @@ class ManagerTest extends \Test\TestCase { $this->assertEquals($expected, $share->getExpirationDate()); } + public function testValidateExpirationDateEnforceRelaxedDefaultButNotSetNewShare() { + $share = $this->manager->newShare(); + + $this->config->method('getAppValue') + ->willReturnMap([ + ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], + ['core', 'shareapi_expire_after_n_days', '7', '3'], + ['core', 'shareapi_default_expire_date', 'no', 'yes'], + ['core', 'link_defaultExpDays', 3, '1'], + ]); + + $expected = new \DateTime(); + $expected->setTime(0,0,0); + $expected->add(new \DateInterval('P1D')); + + self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); + + $this->assertNotNull($share->getExpirationDate()); + $this->assertEquals($expected, $share->getExpirationDate()); + } + public function testValidateExpirationDateEnforceTooFarIntoFuture() { $future = new \DateTime(); $future->add(new \DateInterval('P7D')); |