summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-04-03 07:23:34 +0200
committerJoas Schilling <coding@schilljs.com>2023-04-03 09:06:45 +0200
commit454281af03fb0e917f0135cd6ce51fec5024a0b4 (patch)
tree74aa24a99725bd1fe7d40b9b48674840517fd20d /tests
parentb5da85df3a83da23d13437d13486ceabc738fc24 (diff)
downloadnextcloud-server-454281af03fb0e917f0135cd6ce51fec5024a0b4.tar.gz
nextcloud-server-454281af03fb0e917f0135cd6ce51fec5024a0b4.zip
feat(security): Allow to opt-out of ratelimit protection, e.g. for testing on CI
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
index e7cb4a93a29..a48b1211587 100644
--- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
+++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
@@ -28,9 +28,12 @@ use OC\Security\RateLimiting\Backend\MemoryCacheBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\ICache;
use OCP\ICacheFactory;
+use OCP\IConfig;
use Test\TestCase;
class MemoryCacheBackendTest extends TestCase {
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ private $config;
/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
private $cacheFactory;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
@@ -43,6 +46,7 @@ class MemoryCacheBackendTest extends TestCase {
protected function setUp(): void {
parent::setUp();
+ $this->config = $this->createMock(IConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->cache = $this->createMock(ICache::class);
@@ -53,7 +57,12 @@ class MemoryCacheBackendTest extends TestCase {
->with('OC\Security\RateLimiting\Backend\MemoryCacheBackend')
->willReturn($this->cache);
+ $this->config->method('getSystemValueBool')
+ ->with('ratelimit.protection.enabled')
+ ->willReturn(true);
+
$this->memoryCache = new MemoryCacheBackend(
+ $this->config,
$this->cacheFactory,
$this->timeFactory
);