Skip to content

Commit

Permalink
test(dav): Add unit test for no calendars/subscription limit
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Mar 12, 2024
1 parent c423973 commit 1e8238b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions apps/dav/tests/unit/CalDAV/Security/RateLimitingPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}

0 comments on commit 1e8238b

Please sign in to comment.