Skip to content

Commit 2fd5773

Browse files
authored
Merge pull request #1903 from OpenConext/feature/1902-health-endpoint-doesnt-work
Reinstate monitor endpoints
2 parents c9b7aa2 + 63966ce commit 2fd5773

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

config/routes.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ engineblock_api_controllers:
1515
domain: ".*"
1616
defaults:
1717
domain: "%domain%"
18+
19+
open_conext_monitor:
20+
resource: "@OpenConextMonitorBundle/Resources/config/routing.yml"
21+
prefix: /

src/OpenConext/EngineBlockBundle/EventListener/AuthenticationStateInitializer.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use OpenConext\EngineBlockBundle\Controller\AuthenticationLoopThrottlingController;
2424
use Symfony\Component\HttpFoundation\RequestStack;
2525
use Symfony\Component\HttpFoundation\Session\Session;
26-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
26+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
2727

2828
final class AuthenticationStateInitializer
2929
{
@@ -37,9 +37,14 @@ public function __construct(RequestStack $requestStack)
3737
$this->session = $requestStack->getSession();
3838
}
3939

40-
public function onKernelController(\Symfony\Component\HttpKernel\Event\ControllerEvent $event)
40+
public function onKernelController(ControllerEvent $event): void
4141
{
42-
if (!$event->getController()[0] instanceof AuthenticationLoopThrottlingController) {
42+
$controller = $event->getController();
43+
if (is_array($controller)) {
44+
$controller = $controller[0];
45+
}
46+
47+
if (!$controller instanceof AuthenticationLoopThrottlingController) {
4348
return;
4449
}
4550

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2026 SURFnet B.V.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
namespace OpenConext\EngineBlockBundle\Tests;
20+
21+
use PHPUnit\Framework\Attributes\Group;
22+
use PHPUnit\Framework\Attributes\Test;
23+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
24+
use Symfony\Component\HttpFoundation\Response;
25+
26+
final class MonitorControllerTest extends WebTestCase
27+
{
28+
#[Test]
29+
#[Group('Monitor')]
30+
public function internal_info_returns_json()
31+
{
32+
$client = self::createClient();
33+
$client->request('GET', 'https://engine.dev.openconext.local/internal/info');
34+
35+
$response = $client->getResponse();
36+
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
37+
$this->assertJson($response->getContent());
38+
}
39+
40+
#[Test]
41+
#[Group('Monitor')]
42+
public function internal_health_returns_json()
43+
{
44+
$client = self::createClient();
45+
$client->request('GET', 'https://engine.dev.openconext.local/internal/health');
46+
47+
$response = $client->getResponse();
48+
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
49+
$this->assertJson($response->getContent());
50+
51+
$json = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR);
52+
$this->assertSame(['status' => 'UP'], $json);
53+
}
54+
}

0 commit comments

Comments
 (0)