diff options
author | SebastianKrupinski <krupinskis05@gmail.com> | 2024-07-04 18:56:27 -0400 |
---|---|---|
committer | SebastianKrupinski <krupinskis05@gmail.com> | 2024-07-10 15:07:06 -0400 |
commit | bb603b23f3d066ec743ede279cd9c8d7af9ae0ae (patch) | |
tree | 8395068035bcd16be578b9a663138c6e72c6710c /apps/dav/tests | |
parent | 974fd522e43ade8163f8a3bd7fb9fae9cfc4518a (diff) | |
download | nextcloud-server-bb603b23f3d066ec743ede279cd9c8d7af9ae0ae.tar.gz nextcloud-server-bb603b23f3d066ec743ede279cd9c8d7af9ae0ae.zip |
fix(caldav): limit vevent size
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Validation/CalDavValidatePluginTest.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Validation/CalDavValidatePluginTest.php b/apps/dav/tests/unit/CalDAV/Validation/CalDavValidatePluginTest.php new file mode 100644 index 00000000000..384ddec2804 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/Validation/CalDavValidatePluginTest.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +/* + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCA\DAV\Tests\unit\CalDAV\Validation; + +use OCA\DAV\CalDAV\Validation\CalDavValidatePlugin; +use OCP\IConfig; +use PHPUnit\Framework\MockObject\MockObject; +use Sabre\DAV\Exception\Forbidden; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; +use Test\TestCase; + +class CalDavValidatePluginTest extends TestCase { + + private CalDavValidatePlugin $plugin; + private IConfig|MockObject $config; + private RequestInterface|MockObject $request; + private ResponseInterface|MockObject $response; + + protected function setUp(): void { + parent::setUp(); + // construct mock objects + $this->config = $this->createMock(IConfig::class); + $this->request = $this->createMock(RequestInterface::class); + $this->response = $this->createMock(ResponseInterface::class); + $this->plugin = new CalDavValidatePlugin( + $this->config, + ); + } + + public function testPutSizeLessThenLimit(): void { + + // construct method responses + $this->config + ->method('getAppValue') + ->with('dav', 'event_size_limit', '10485760') + ->willReturn(10485760); + $this->request + ->method('getRawServerValue') + ->with('CONTENT_LENGTH') + ->willReturn('1024'); + // test condition + $this->assertTrue( + $this->plugin->beforePut($this->request, $this->response) + ); + + } + + public function testPutSizeMoreThenLimit(): void { + + // construct method responses + $this->config + ->method('getAppValue') + ->with('dav', 'event_size_limit', '10485760') + ->willReturn(10485760); + $this->request + ->method('getRawServerValue') + ->with('CONTENT_LENGTH') + ->willReturn('16242880'); + $this->expectException(Forbidden::class); + // test condition + $this->plugin->beforePut($this->request, $this->response); + + } + +} |