Skip to content

Commit e319057

Browse files
Merge pull request #45955 from nextcloud/backport/45228/stable28
[stable28] fix(settings): define a 'heartbeat' route, so SecurityHeaders can handle redirected root
2 parents 2427700 + 82f9c66 commit e319057

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
@@ -172,3 +172,5 @@
172172
// Routing
173173
$this->create('core_ajax_update', '/core/ajax/update.php')
174174
->actionInclude('core/ajax/update.php');
175+
176+
$this->create('heartbeat', '/heartbeat')->get();

tests/lib/Route/RouterTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
* @package Test\Route
4040
*/
4141
class RouterTest extends TestCase {
42-
public function testGenerateConsecutively(): void {
42+
private Router $router;
43+
protected function setUp(): void {
44+
parent::setUp();
4345
/** @var LoggerInterface $logger */
4446
$logger = $this->createMock(LoggerInterface::class);
4547
$logger->method('info')
@@ -48,20 +50,27 @@ function (string $message, array $data) {
4850
$this->fail('Unexpected info log: '.(string)($data['exception'] ?? $message));
4951
}
5052
);
51-
$router = new Router(
53+
$this->router = new Router(
5254
$logger,
5355
$this->createMock(IRequest::class),
5456
$this->createMock(IConfig::class),
5557
$this->createMock(IEventLogger::class),
5658
$this->createMock(ContainerInterface::class),
5759
);
60+
}
61+
62+
public function testHeartbeat(): void {
63+
$this->assertEquals('/index.php/heartbeat', $this->router->generate('heartbeat'));
64+
}
65+
66+
public function testGenerateConsecutively(): void {
5867

59-
$this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index'));
68+
$this->assertEquals('/index.php/apps/files/', $this->router->generate('files.view.index'));
6069

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

6473
// test caching
65-
$this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index'));
74+
$this->assertEquals('/index.php/apps/files/', $this->router->generate('files.view.index'));
6675
}
6776
}

0 commit comments

Comments
 (0)