]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add unit tests to enforce a relaxed default share expiration date
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Wed, 11 Nov 2020 18:36:04 +0000 (19:36 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 16 Nov 2020 13:16:48 +0000 (13:16 +0000)
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
tests/lib/Share20/ManagerTest.php

index d148bd0d1c7283ec8d44818c069b0636e0793853..ee5b8bc68bf202048af25f1765067348e646ef94 100644 (file)
@@ -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'));