aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
diff options
context:
space:
mode:
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2024-01-09 00:46:26 +0100
committerBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2024-01-09 17:28:11 +0100
commitcc3a2c351a2db4c30a2f0dc1bde73ba024e88602 (patch)
tree74e8512c4e6eec33b812296dfa90899037daad33 /apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
parentd72db91785174ad19b0057264506f24cfc03494c (diff)
downloadnextcloud-server-cc3a2c351a2db4c30a2f0dc1bde73ba024e88602.tar.gz
nextcloud-server-cc3a2c351a2db4c30a2f0dc1bde73ba024e88602.zip
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 <benjamin.gaussorgues@nextcloud.com>
Diffstat (limited to 'apps/files_sharing/tests/Controller/ShareAPIControllerTest.php')
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php16
1 files changed, 15 insertions, 1 deletions
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();