From cc3a2c351a2db4c30a2f0dc1bde73ba024e88602 Mon Sep 17 00:00:00 2001 From: Benjamin Gaussorgues Date: Tue, 9 Jan 2024 00:46:26 +0100 Subject: fix(share): use user timezone to parse share expiration date If an user in UTC+1 try to create a share at 00:00, it's day D for him, but D-1 for the server (UTC). This fix aims to apply the correct offset Signed-off-by: Benjamin Gaussorgues --- .../tests/Controller/ShareAPIControllerTest.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/tests/Controller/ShareAPIControllerTest.php') diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index bfc6a97bd86..822212ae86f 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -47,6 +47,7 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\Storage; use OCP\IConfig; +use OCP\IDateTimeZone; use OCP\IGroup; use OCP\IGroupManager; use OCP\IL10N; @@ -117,6 +118,9 @@ class ShareAPIControllerTest extends TestCase { /** @var IPreview|\PHPUnit\Framework\MockObject\MockObject */ private $previewManager; + /** @var IDateTimeZone|\PHPUnit\Framework\MockObject\MockObject */ + private $dateTimeZone; + protected function setUp(): void { $this->shareManager = $this->createMock(IManager::class); $this->shareManager @@ -147,6 +151,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturnCallback(function ($fileInfo) { return $fileInfo->getMimeType() === 'mimeWithPreview'; }); + $this->dateTimeZone = $this->createMock(IDateTimeZone::class); $this->ocs = new ShareAPIController( $this->appName, @@ -162,7 +167,8 @@ class ShareAPIControllerTest extends TestCase { $this->appManager, $this->serverContainer, $this->userStatusManager, - $this->previewManager + $this->previewManager, + $this->dateTimeZone, ); } @@ -186,6 +192,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); } @@ -783,6 +790,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['canAccessShare']) ->getMock(); @@ -1407,6 +1415,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); @@ -1746,6 +1755,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); @@ -1840,6 +1850,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); @@ -2249,6 +2260,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); @@ -2315,6 +2327,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); @@ -2554,6 +2567,7 @@ class ShareAPIControllerTest extends TestCase { $this->serverContainer, $this->userStatusManager, $this->previewManager, + $this->dateTimeZone, ])->setMethods(['formatShare']) ->getMock(); -- cgit v1.2.3