AppSecretFile: pin the deprecation at Warning level, say trailing newlines
Soul pass on 25b9cc16: the warning level was unpinned (a Trace demotion passed) and the docs said one newline where the code trims all.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
25b9cc1683
commit
280d843aeb
4 changed files with 24 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ public sealed class HeimdallAppSecretFileTests : IDisposable
|
|||
[InlineData("")]
|
||||
[InlineData("\n")]
|
||||
[InlineData("\r\n")]
|
||||
public void The_file_is_the_secret_with_only_the_trailing_newline_trimmed(string ending)
|
||||
public void The_file_is_the_secret_with_only_trailing_newlines_trimmed(string ending)
|
||||
{
|
||||
var options = Resolve(appSecretFile: Write(FileSecret + ending));
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public sealed class HeimdallAppSecretFileTests : IDisposable
|
|||
var options = Resolve(EnvSecret, Write(FileSecret + "\n"));
|
||||
|
||||
Assert.Equal(FileSecret, options.AppSecret);
|
||||
Assert.Contains(_logs.Lines, line => line.Contains("deprecated"));
|
||||
Assert.Contains(_logs.WarningLines, line => line.Contains("deprecated"));
|
||||
AssertNoSecretLogged();
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ public sealed class HeimdallAppSecretFileTests : IDisposable
|
|||
var options = Resolve(EnvSecret);
|
||||
|
||||
Assert.Equal(EnvSecret, options.AppSecret);
|
||||
Assert.Single(_logs.Lines, line => line.Contains("deprecated") && line.Contains("Heimdall:AppSecretFile"));
|
||||
Assert.Single(_logs.WarningLines, line => line.Contains("deprecated") && line.Contains("Heimdall:AppSecretFile"));
|
||||
AssertNoSecretLogged();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,19 @@ namespace Bifrost.Web.Tests.Support;
|
|||
public sealed class CapturingLoggerProvider : ILoggerProvider
|
||||
{
|
||||
private readonly List<string> _lines = [];
|
||||
private readonly List<string> _warnings = [];
|
||||
|
||||
/// <summary>Lines logged at Warning or above, to pin that an operator-facing notice reaches the journal.</summary>
|
||||
public IReadOnlyList<string> WarningLines
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lines)
|
||||
{
|
||||
return _warnings.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> Lines
|
||||
{
|
||||
|
|
@ -38,7 +51,12 @@ public sealed class CapturingLoggerProvider : ILoggerProvider
|
|||
{
|
||||
lock (owner._lines)
|
||||
{
|
||||
owner._lines.Add(formatter(state, exception) + (exception is null ? string.Empty : "\n" + exception));
|
||||
var line = formatter(state, exception) + (exception is null ? string.Empty : "\n" + exception);
|
||||
owner._lines.Add(line);
|
||||
if (logLevel >= LogLevel.Warning)
|
||||
{
|
||||
owner._warnings.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue