From 3b3931d86b56b4108f01471bb052bcdbb5eae57e Mon Sep 17 00:00:00 2001 From: Oleksandr Piskun Date: Tue, 20 Oct 2026 13:55:38 +0000 Subject: [PATCH] fix(harp): send the route verb to HaRP Signed-off-by: Oleksandr Piskun --- lib/Service/HarpService.php | 1 + tests/php/Service/HarpServiceTest.php | 44 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/php/Service/HarpServiceTest.php diff --git a/lib/Service/HarpService.php b/lib/Service/HarpService.php index f473a8f0b..d4b366919 100644 --- a/lib/Service/HarpService.php +++ b/lib/Service/HarpService.php @@ -119,6 +119,7 @@ public function getHarpExApp(ExApp $exApp): array { 'routes' => array_map(function ($route) { return [ 'url' => $route['url'], + 'verb' => $route['verb'], 'access_level' => $route['access_level'], 'bruteforce_protection' => ExAppMapper::parseJsonList($route['bruteforce_protection'] ?? null), ]; diff --git a/tests/php/Service/HarpServiceTest.php b/tests/php/Service/HarpServiceTest.php new file mode 100644 index 000000000..aa7035577 --- /dev/null +++ b/tests/php/Service/HarpServiceTest.php @@ -0,0 +1,44 @@ +createMock(LoggerInterface::class), + $this->createMock(IConfig::class), + $this->createMock(ICertificateManager::class), + $this->createMock(ICrypto::class), + ); + // One URL with a public GET and an admin-only POST: HaRP needs the verbs to tell the two routes apart. + $exApp = new ExApp([ + 'appid' => 'test-deploy', + 'deploy_config' => [], + 'routes' => [ + ['url' => '^/settings$', 'verb' => 'GET', 'access_level' => 0, 'headers_to_exclude' => '[]', 'bruteforce_protection' => '[]'], + ['url' => '^/settings$', 'verb' => 'POST', 'access_level' => 2, 'headers_to_exclude' => '[]', 'bruteforce_protection' => '[401]'], + ], + ]); + + self::assertSame([ + ['url' => '^/settings$', 'verb' => 'GET', 'access_level' => 0, 'bruteforce_protection' => []], + ['url' => '^/settings$', 'verb' => 'POST', 'access_level' => 2, 'bruteforce_protection' => [401]], + ], $harpService->getHarpExApp($exApp)['routes']); + } +}