From 66d4f0e4c0b062a4a0d9e4946dfa673e155c338c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 1 Dec 2024 22:22:38 +0100 Subject: [PATCH 1/2] chore(absence): Add capability for absence api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- apps/dav/lib/Capabilities.php | 7 +++- apps/dav/openapi.json | 3 ++ .../NotificationProviderManagerTest.php | 3 ++ apps/dav/tests/unit/CapabilitiesTest.php | 33 +++++++++++++++++-- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index b0f63f80f2daf..36d56d4a822e1 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -7,15 +7,17 @@ use OCP\Capabilities\ICapability; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; class Capabilities implements ICapability { public function __construct( private IConfig $config, + private IAvailabilityCoordinator $coordinator, ) { } /** - * @return array{dav: array{chunking: string, bulkupload?: string}} + * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool}} */ public function getCapabilities() { $capabilities = [ @@ -26,6 +28,9 @@ public function getCapabilities() { if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { $capabilities['dav']['bulkupload'] = '1.0'; } + if ($this->coordinator->isEnabled()) { + $capabilities['dav']['absence-supported'] = true; + } return $capabilities; } } diff --git a/apps/dav/openapi.json b/apps/dav/openapi.json index 7045a7f9b274c..e212796304d42 100644 --- a/apps/dav/openapi.json +++ b/apps/dav/openapi.json @@ -37,6 +37,9 @@ }, "bulkupload": { "type": "string" + }, + "absence-supported": { + "type": "boolean" } } } diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index 6c46a2aed2d50..6d0e62f505b52 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -17,6 +17,9 @@ use OCP\AppFramework\QueryException; use Test\TestCase; +/** + * @group DB + */ class NotificationProviderManagerTest extends TestCase { /** @var NotificationProviderManager|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/dav/tests/unit/CapabilitiesTest.php b/apps/dav/tests/unit/CapabilitiesTest.php index acdfb4a244324..4a2d7e8dba692 100644 --- a/apps/dav/tests/unit/CapabilitiesTest.php +++ b/apps/dav/tests/unit/CapabilitiesTest.php @@ -7,6 +7,7 @@ use OCA\DAV\Capabilities; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; use Test\TestCase; /** @@ -19,7 +20,11 @@ public function testGetCapabilities(): void { ->method('getSystemValueBool') ->with('bulkupload.enabled', $this->isType('bool')) ->willReturn(false); - $capabilities = new Capabilities($config); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(false); + $capabilities = new Capabilities($config, $coordinator); $expected = [ 'dav' => [ 'chunking' => '1.0', @@ -34,7 +39,11 @@ public function testGetCapabilitiesWithBulkUpload(): void { ->method('getSystemValueBool') ->with('bulkupload.enabled', $this->isType('bool')) ->willReturn(true); - $capabilities = new Capabilities($config); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(false); + $capabilities = new Capabilities($config, $coordinator); $expected = [ 'dav' => [ 'chunking' => '1.0', @@ -43,4 +52,24 @@ public function testGetCapabilitiesWithBulkUpload(): void { ]; $this->assertSame($expected, $capabilities->getCapabilities()); } + + public function testGetCapabilitiesWithAbsence(): void { + $config = $this->createMock(IConfig::class); + $config->expects($this->once()) + ->method('getSystemValueBool') + ->with('bulkupload.enabled', $this->isType('bool')) + ->willReturn(false); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(true); + $capabilities = new Capabilities($config, $coordinator); + $expected = [ + 'dav' => [ + 'chunking' => '1.0', + 'absence-supported' => true, + ], + ]; + $this->assertSame($expected, $capabilities->getCapabilities()); + } } From 303a21fc9d1c702b452d71b39cf21deecaedaef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 1 Dec 2024 22:23:51 +0100 Subject: [PATCH 2/2] chore(absence): Add capability for absence replacement support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- apps/dav/lib/Capabilities.php | 3 ++- apps/dav/openapi.json | 3 +++ apps/dav/tests/unit/CapabilitiesTest.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index 36d56d4a822e1..ab4e53fce3717 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -17,7 +17,7 @@ public function __construct( } /** - * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool}} + * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}} */ public function getCapabilities() { $capabilities = [ @@ -30,6 +30,7 @@ public function getCapabilities() { } if ($this->coordinator->isEnabled()) { $capabilities['dav']['absence-supported'] = true; + $capabilities['dav']['absence-replacement'] = true; } return $capabilities; } diff --git a/apps/dav/openapi.json b/apps/dav/openapi.json index e212796304d42..cb7dc82c0396e 100644 --- a/apps/dav/openapi.json +++ b/apps/dav/openapi.json @@ -40,6 +40,9 @@ }, "absence-supported": { "type": "boolean" + }, + "absence-replacement": { + "type": "boolean" } } } diff --git a/apps/dav/tests/unit/CapabilitiesTest.php b/apps/dav/tests/unit/CapabilitiesTest.php index 4a2d7e8dba692..e99f7b8da5f77 100644 --- a/apps/dav/tests/unit/CapabilitiesTest.php +++ b/apps/dav/tests/unit/CapabilitiesTest.php @@ -68,6 +68,7 @@ public function testGetCapabilitiesWithAbsence(): void { 'dav' => [ 'chunking' => '1.0', 'absence-supported' => true, + 'absence-replacement' => true, ], ]; $this->assertSame($expected, $capabilities->getCapabilities());