Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/lib/Search/EventsSearchProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected function getDavUrlForCalendarObject(
[,, $principalId] = explode('/', $principalUri, 3);

return $this->urlGenerator->linkTo('', 'remote.php') . '/dav/calendars/'
. $principalId . '/'
. rawurlencode($principalId) . '/'
. $calendarUri . '/'
. $calendarObjectUri;
}
Expand Down
22 changes: 19 additions & 3 deletions apps/dav/tests/unit/Search/EventsSearchProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\VObject\Reader;
use Test\TestCase;
Expand Down Expand Up @@ -399,7 +400,18 @@ public function testSearch(): void {
$this->assertFalse($result2Data['rounded']);
}

public function testGetDeepLinkToCalendarApp(): void {
public static function provideDeepLinkData(): array {
return [
['principals/users/john.doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M='],
['principals/users/John Doe', 'bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvSm9obiUyMERvZS9mb28vYmFyLmljcw=='],
];
}

#[DataProvider('provideDeepLinkData')]
public function testGetDeepLinkToCalendarApp(
string $principalUri,
string $expectedBase64DavUrl,
): void {
$this->urlGenerator->expects($this->once())
->method('linkTo')
->with('', 'remote.php')
Expand All @@ -410,10 +422,14 @@ public function testGetDeepLinkToCalendarApp(): void {
->willReturn('link-to-route-calendar/');
$this->urlGenerator->expects($this->once())
->method('getAbsoluteURL')
->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
->with("link-to-route-calendar/edit/$expectedBase64DavUrl")
->willReturn('absolute-url-to-route');

$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', ['principals/users/john.doe', 'foo', 'bar.ics']);
$actual = self::invokePrivate($this->provider, 'getDeepLinkToCalendarApp', [
$principalUri,
'foo',
'bar.ics',
]);

$this->assertEquals('absolute-url-to-route', $actual);
}
Expand Down
Loading