summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-03-11 10:27:33 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2024-03-11 10:46:48 +0100
commit44ab814685fb8cc3db824c12a3f81ac3e5dc5195 (patch)
tree8ee3ee1ba71c7f5aaa517b388261d840c3c90a39 /apps
parentb0b965cfb5448d810ef06920569ad761e3041f05 (diff)
downloadnextcloud-server-44ab814685fb8cc3db824c12a3f81ac3e5dc5195.tar.gz
nextcloud-server-44ab814685fb8cc3db824c12a3f81ac3e5dc5195.zip
tests(dav): Add unit test for no calendars/subscription limit
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps')
-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');
+ }
+
}