summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-03-11 10:27:33 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-03-12 10:45:37 +0000
commit58fe9812cc1c5881227c6a8a3e232cf9a40ac86c (patch)
tree1a785816ab009d2d15702707133ee9b980030e73 /apps/dav
parentdffa31d4f0278dce172688992abf4ba811726138 (diff)
downloadnextcloud-server-58fe9812cc1c5881227c6a8a3e232cf9a40ac86c.tar.gz
nextcloud-server-58fe9812cc1c5881227c6a8a3e232cf9a40ac86c.zip
tests(dav): Add unit test for no calendars/subscription limit
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php b/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php
index a63b74e00dc..f79b53965b9 100644
--- a/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php
@@ -163,4 +163,42 @@ class RateLimitingPluginTest extends TestCase {
$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('getAppValue')
+ ->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');
+ }
+
}