diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-04-03 14:19:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 14:19:41 +0200 |
commit | c5339fa336329ea8c0a6e7d6ba3f02cb69e226b6 (patch) | |
tree | 69f0a2f56a0960e0d047256a347d1113f8a95565 /tests/lib | |
parent | 1000b463a1fd235fb5f90f85a48ad747e4614a74 (diff) | |
parent | 454281af03fb0e917f0135cd6ce51fec5024a0b4 (diff) | |
download | nextcloud-server-c5339fa336329ea8c0a6e7d6ba3f02cb69e226b6.tar.gz nextcloud-server-c5339fa336329ea8c0a6e7d6ba3f02cb69e226b6.zip |
Merge pull request #37542 from nextcloud/bugfix/noid/allow-to-opt-out-of-ratelimit-for-testing
feat(security): Allow to opt-out of ratelimit protection, e.g. for te…
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php | 9 |
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 ); |