diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-06-11 09:42:03 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-06-11 18:44:14 +0000 |
commit | a794f15b1f81f5fa848a64ac40e777274f657d98 (patch) | |
tree | 1e080808e7481d9eccdd185f00f464d03d02487f /apps/dav/tests | |
parent | f211e9a767f64f3e86d4b3dcb11230cb9cc9cbfc (diff) | |
download | nextcloud-server-a794f15b1f81f5fa848a64ac40e777274f657d98.tar.gz nextcloud-server-a794f15b1f81f5fa848a64ac40e777274f657d98.zip |
fix(caldav): event links in shared calendar notifications
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php index 253e1628229..33fbc7a7432 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php @@ -108,7 +108,9 @@ class EventTest extends TestCase { * @param bool $calendarAppEnabled */ public function testGenerateObjectParameter(int $id, string $name, ?array $link, bool $calendarAppEnabled = true): void { + $affectedUser = 'otheruser'; if ($link) { + $affectedUser = $link['owner']; $generatedLink = [ 'view' => 'dayGridMonth', 'timeRange' => 'now', @@ -141,7 +143,40 @@ class EventTest extends TestCase { if ($link && $calendarAppEnabled) { $result['link'] = 'fullLink'; } - $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter])); + $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter, $affectedUser])); + } + + public function testGenerateObjectParameterWithSharedCalendar(): void { + $link = [ + 'object_uri' => 'someuuid.ics', + 'calendar_uri' => 'personal', + 'owner' => 'sharer' + ]; + $generatedLink = [ + 'view' => 'dayGridMonth', + 'timeRange' => 'now', + 'mode' => 'sidebar', + 'objectId' => base64_encode('/remote.php/dav/calendars/sharee/' . $link['calendar_uri'] . '_shared_by_sharer/' . $link['object_uri']), + 'recurrenceId' => 'next' + ]; + $this->appManager->expects($this->once()) + ->method('isEnabledForUser') + ->with('calendar') + ->willReturn(true); + $this->url->expects($this->once()) + ->method('getWebroot'); + $this->url->expects($this->once()) + ->method('linkToRouteAbsolute') + ->with('calendar.view.indexview.timerange.edit', $generatedLink) + ->willReturn('fullLink'); + $objectParameter = ['id' => 42, 'name' => 'calendar', 'link' => $link]; + $result = [ + 'type' => 'calendar-event', + 'id' => 42, + 'name' => 'calendar', + 'link' => 'fullLink', + ]; + $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter, 'sharee'])); } public function dataGenerateObjectParameterThrows() { @@ -160,6 +195,6 @@ class EventTest extends TestCase { public function testGenerateObjectParameterThrows($eventData, string $exception = InvalidArgumentException::class): void { $this->expectException($exception); - $this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData]); + $this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData, 'no_user']); } } |