Skip to content

Commit 57410d2

Browse files
authored
Merge pull request #44118 from nextcloud/backport/44117/stable28
[stable28] tests(dav): Add unit test for no calendars/subscription limit
2 parents 6608b7d + 44ab814 commit 57410d2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,42 @@ public function testCalendarLimitReached(): void {
163163
$this->plugin->beforeBind('calendars/foo/cal');
164164
}
165165

166+
public function testNoCalendarsSubscriptsLimit(): void {
167+
$user = $this->createMock(IUser::class);
168+
$this->userManager->expects(self::once())
169+
->method('get')
170+
->with($this->userId)
171+
->willReturn($user);
172+
$user->method('getUID')->willReturn('user123');
173+
$this->config
174+
->method('getAppValue')
175+
->with('dav')
176+
->willReturnCallback(function ($app, $key, $default) {
177+
switch ($key) {
178+
case 'maximumCalendarsSubscriptions':
179+
return -1;
180+
default:
181+
return $default;
182+
}
183+
});
184+
$this->limiter->expects(self::once())
185+
->method('registerUserRequest')
186+
->with(
187+
'caldav-create-calendar',
188+
10,
189+
3600,
190+
$user,
191+
);
192+
$this->caldavBackend->expects(self::never())
193+
->method('getCalendarsForUserCount')
194+
->with('principals/users/user123')
195+
->willReturn(27);
196+
$this->caldavBackend->expects(self::never())
197+
->method('getSubscriptionsForUserCount')
198+
->with('principals/users/user123')
199+
->willReturn(3);
200+
201+
$this->plugin->beforeBind('calendars/foo/cal');
202+
}
203+
166204
}

0 commit comments

Comments
 (0)