Skip to content

Commit c3354e9

Browse files
Merge pull request #45228 from smokris/heartbeat-route
fix(settings): define a 'heartbeat' route, so SecurityHeaders can handle redirected root
2 parents 4e840fb + 5d74445 commit c3354e9

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

core/routes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
// Routing
1414
$this->create('core_ajax_update', '/core/ajax/update.php')
1515
->actionInclude('core/ajax/update.php');
16+
17+
$this->create('heartbeat', '/heartbeat')->get();

tests/lib/Route/RouterTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
* @package Test\Route
2626
*/
2727
class RouterTest extends TestCase {
28-
public function testGenerateConsecutively(): void {
28+
private Router $router;
29+
protected function setUp(): void {
30+
parent::setUp();
2931
/** @var LoggerInterface $logger */
3032
$logger = $this->createMock(LoggerInterface::class);
3133
$logger->method('info')
@@ -34,21 +36,28 @@ function (string $message, array $data) {
3436
$this->fail('Unexpected info log: '.(string)($data['exception'] ?? $message));
3537
}
3638
);
37-
$router = new Router(
39+
$this->router = new Router(
3840
$logger,
3941
$this->createMock(IRequest::class),
4042
$this->createMock(IConfig::class),
4143
$this->createMock(IEventLogger::class),
4244
$this->createMock(ContainerInterface::class),
4345
$this->createMock(IAppManager::class),
4446
);
47+
}
48+
49+
public function testHeartbeat(): void {
50+
$this->assertEquals('/index.php/heartbeat', $this->router->generate('heartbeat'));
51+
}
52+
53+
public function testGenerateConsecutively(): void {
4554

46-
$this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index'));
55+
$this->assertEquals('/index.php/apps/files/', $this->router->generate('files.view.index'));
4756

4857
// the OCS route is the prefixed one for the AppFramework - see /ocs/v1.php for routing details
49-
$this->assertEquals('/index.php/ocsapp/apps/dav/api/v1/direct', $router->generate('ocs.dav.direct.getUrl'));
58+
$this->assertEquals('/index.php/ocsapp/apps/dav/api/v1/direct', $this->router->generate('ocs.dav.direct.getUrl'));
5059

5160
// test caching
52-
$this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index'));
61+
$this->assertEquals('/index.php/apps/files/', $this->router->generate('files.view.index'));
5362
}
5463
}

0 commit comments

Comments
 (0)