Files
coolify/tests/Feature/LogRedactionChannelTest.php
6b07f03107 feat(terminal): interactive console mode for containers (docker attach) (#11538)
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: rosslh <ross@rosshill.ca>
2026-10-14 14:32:02 +02:00

31 lines
1.2 KiB
PHP

<?php
use Illuminate\Log\LogManager;
use Monolog\Handler\TestHandler;
it('redacts secrets when Laravel creates a configured log channel', function (string $channel) {
config(['logging.redaction_enabled' => true, 'constants.coolify.self_hosted' => true]);
$configuration = config("logging.channels.{$channel}");
$configuration['driver'] = 'monolog';
$configuration['handler'] = TestHandler::class;
config([
"logging.channels.{$channel}" => $configuration,
'logging.channels.emergency.path' => '/dev/null',
]);
$logger = (new LogManager(app()))->channel($channel);
$handler = $logger->getLogger()->getHandlers()[0];
expect($handler)->toBeInstanceOf(TestHandler::class);
$logger->error('password=coolify-canary-channel-secret', [
'token' => 'coolify-canary-context-secret',
'user_email' => 'admin@example.com',
]);
$record = $handler->getRecords()[0];
expect($record->message)->toBe('password='.REDACTED);
expect($record->context['token'])->toBe(REDACTED);
expect($record->context['user_email'])->toBe($channel === 'audit' ? 'admin@example.com' : REDACTED);
})->with(['single', 'audit']);