From 1e8238b9e4cced5376668dc690486abd0f551642 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 11 Mar 2024 10:27:33 +0100 Subject: [PATCH] test(dav): Add unit test for no calendars/subscription limit Signed-off-by: Christoph Wurst --- .../Security/RateLimitingPluginTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php b/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php index 1bb81ee4d3d8f..8c0539819d3b4 100644 --- a/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php @@ -163,4 +163,42 @@ public function testCalendarLimitReached(): void { $this->plugin->beforeBind('calendars/foo/cal'); } + public function testNoCalendarsSubscriptsLimit(): void { + $user = $this->createMock(IUser::class); + $this->userManager->expects(self::once()) + ->method('get') + ->with($this->userId) + ->willReturn($user); + $user->method('getUID')->willReturn('user123'); + $this->config + ->method('getValueInt') + ->with('dav') + ->willReturnCallback(function ($app, $key, $default) { + switch ($key) { + case 'maximumCalendarsSubscriptions': + return -1; + default: + return $default; + } + }); + $this->limiter->expects(self::once()) + ->method('registerUserRequest') + ->with( + 'caldav-create-calendar', + 10, + 3600, + $user, + ); + $this->caldavBackend->expects(self::never()) + ->method('getCalendarsForUserCount') + ->with('principals/users/user123') + ->willReturn(27); + $this->caldavBackend->expects(self::never()) + ->method('getSubscriptionsForUserCount') + ->with('principals/users/user123') + ->willReturn(3); + + $this->plugin->beforeBind('calendars/foo/cal'); + } + }