diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppConfigTest.php | 24 | ||||
-rw-r--r-- | tests/lib/Security/Ip/BruteforceAllowListTest.php | 4 |
2 files changed, 26 insertions, 2 deletions
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index 4c579bc4f09..03405bf96ca 100644 --- a/tests/lib/AppConfigTest.php +++ b/tests/lib/AppConfigTest.php @@ -47,6 +47,13 @@ class AppConfigTest extends TestCase { 'deletethis' => ['deletethis', 'deletethis'], 'key' => ['key', 'value'] ], + 'searchtest' => [ + 'search_key1' => ['search_key1', 'key1', IAppConfig::VALUE_STRING], + 'search_key2' => ['search_key2', 'key2', IAppConfig::VALUE_STRING], + 'search_key3' => ['search_key3', 'key3', IAppConfig::VALUE_STRING], + 'searchnot_key4' => ['searchnot_key4', 'key4', IAppConfig::VALUE_STRING], + 'search_key5_lazy' => ['search_key5_lazy', 'key5', IAppConfig::VALUE_STRING, true], + ], 'someapp' => [ 'key' => ['key', 'value'], 'otherkey' => ['otherkey', 'othervalue'] @@ -1454,6 +1461,23 @@ class AppConfigTest extends TestCase { $this->assertConfigValueNotEquals('testapp', $key, $secret); } + public function testSearchKeyNoLazyLoading(): void { + $appConfig = $this->generateAppConfig(); + $appConfig->searchKeys('searchtest', 'search_'); + $status = $appConfig->statusCache(); + $this->assertFalse($status['lazyLoaded'], 'searchKeys() loaded lazy config'); + } + + public function testSearchKeyFast(): void { + $appConfig = $this->generateAppConfig(); + $this->assertEquals(['search_key1', 'search_key2', 'search_key3'], $appConfig->searchKeys('searchtest', 'search_')); + } + + public function testSearchKeyLazy(): void { + $appConfig = $this->generateAppConfig(); + $this->assertEquals(['search_key5_lazy'], $appConfig->searchKeys('searchtest', 'search_', true)); + } + protected function loadConfigValueFromDatabase(string $app, string $key): string|false { $sql = $this->connection->getQueryBuilder(); $sql->select('configvalue') diff --git a/tests/lib/Security/Ip/BruteforceAllowListTest.php b/tests/lib/Security/Ip/BruteforceAllowListTest.php index 0cffc128d64..1454b779c1b 100644 --- a/tests/lib/Security/Ip/BruteforceAllowListTest.php +++ b/tests/lib/Security/Ip/BruteforceAllowListTest.php @@ -138,8 +138,8 @@ class BruteforceAllowListTest extends TestCase { array $allowList, bool $isAllowListed, ): void { - $this->appConfig->method('getKeys') - ->with($this->equalTo('bruteForce')) + $this->appConfig->method('searchKeys') + ->with($this->equalTo('bruteForce'), $this->equalTo('whitelist_')) ->willReturn(array_keys($allowList)); $this->appConfig->method('getValueString') |