Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The ExApp proxy also applies a stricter route that matches the path as an ExApp may read it, as HaRP 0.4.8 does. #1182
- The ExApp proxy returns an ExApp's redirect to the browser instead of following it, as HaRP does. #1195
- `occ app_api:app:unregister --rm-data` also removes the volume of a Kubernetes ExApp whose deployment is already gone. #1130
- ExApps use the changed settings of their deploy daemon, such as a new HaRP shared key, right away instead of cached old ones. #1205

## [34.0.0]

Expand Down
1 change: 1 addition & 0 deletions lib/Service/DaemonConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public function updateDaemonConfig(DaemonConfig $daemonConfig, DaemonConfig $pre
$this->logger->error('Failed to update DaemonConfig. Error: ' . $e->getMessage(), ['exception' => $e]);
return null;
}
$this->exAppService->resetExAppsCache();
$changedSettings = $this->getChangedSettings($previousDaemonConfig, $daemonConfig);
if ($changedSettings !== []) {
$parameters = [
Expand Down
7 changes: 7 additions & 0 deletions lib/Service/ExAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ public function getExApps(): array {
}
}

/**
* Drop the cached list of ExApps, which also holds the settings of their deploy daemons
*/
public function resetExAppsCache(): void {
$this->cache?->remove('/ex_apps');
}

public function registerExAppRoutes(ExApp $exApp, array $routes): ?ExApp {
try {
$this->exAppMapper->registerExAppRoutes($exApp, $routes);
Expand Down
15 changes: 13 additions & 2 deletions tests/php/Service/DaemonConfigServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ public function testValidateNewSecretDoesNotWarnAboutAGeneratedSecret(): void {
self::assertNull($result);
}

private function createServiceWithMapper(DaemonConfigMapper $mapper): DaemonConfigService {
private function createServiceWithMapper(DaemonConfigMapper $mapper, ?ExAppService $exAppService = null): DaemonConfigService {
$crypto = $this->createMock(ICrypto::class);
$crypto->method('encrypt')->willReturnCallback(static fn (string $value): string => 'encrypted:' . $value);
// Ciphertexts in these tests are `encrypted:<iv>:<secret>`, so the same secret can have different ciphertexts
$crypto->method('decrypt')->willReturnCallback(static fn (string $value): string => explode(':', $value, 3)[2] ?? $value);
return new DaemonConfigService(
$this->createMock(LoggerInterface::class),
$mapper,
$this->createMock(ExAppService::class),
$exAppService ?? $this->createMock(ExAppService::class),
$crypto,
$this->auditLogger,
);
Expand Down Expand Up @@ -447,6 +447,17 @@ public function testUpdateDaemonConfigDoesNotLogADatabaseError(): void {
self::assertNull($this->createServiceWithMapper($mapper)->updateDaemonConfig($daemonConfig, clone $daemonConfig));
}

public function testUpdateDaemonConfigResetsTheExAppsCache(): void {
$mapper = $this->createMock(DaemonConfigMapper::class);
$mapper->method('update')->willReturnArgument(0);
$exAppService = $this->createMock(ExAppService::class);
$exAppService->expects(self::once())->method('resetExAppsCache');
$daemonConfig = new DaemonConfig(['name' => 'harp_proxy', 'deploy_config' => ['haproxy_password' => 'encrypted:iv2:new_secret']]);
$previous = new DaemonConfig(['name' => 'harp_proxy', 'deploy_config' => ['haproxy_password' => 'encrypted:iv1:old_secret']]);

$this->createServiceWithMapper($mapper, $exAppService)->updateDaemonConfig($daemonConfig, $previous);
}

public static function defaultDaemonProvider(): array {
return [
'set' => ['harp_proxy', 'AppAPI setting %s was changed to %s', ['key' => 'default_daemon_config', 'value' => 'harp_proxy']],
Expand Down
Loading