Merge pull request #44118 from nextcloud/backport/44117/stable28

[stable28] tests(dav): Add unit test for no calendars/subscription limit
This commit is contained in:
Ferdinand Thiessen 2024-03-11 16:31:26 +01:00 committed by GitHub
commit 57410d20f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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');
}
}