Remove trap paths and known hosts: catch everything on the trap port
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9f2b0443c
commit
9a56fc5b48
31 files changed
+335
-462
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using Flypaper.Http;
|
||||
using Flypaper.Tests.Fakes;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Http;
|
||||
|
||||
public sealed class RemovedSettingsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Warns_about_each_removed_setting_that_is_still_set()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["Flypaper:Http:KnownHosts:0"] = "example.com",
|
||||
["Flypaper:Http:TrapPaths:0"] = "/.env",
|
||||
["Flypaper:Http:TrustedProxies:0"] = "172.19.0.0/16"
|
||||
})
|
||||
.Build();
|
||||
var logger = new ListLogger();
|
||||
|
||||
FlypaperHttpExtensions.WarnAboutRemovedSettings(configuration, logger);
|
||||
|
||||
logger.Entries.Count.ShouldBe(2);
|
||||
logger.Entries.ShouldAllBe(e => e.Level == LogLevel.Warning);
|
||||
logger.Entries.ShouldContain(e => e.Message.Contains("Flypaper__Http__KnownHosts"));
|
||||
logger.Entries.ShouldContain(e => e.Message.Contains("Flypaper__Http__TrapPaths"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Stays_silent_without_removed_settings()
|
||||
{
|
||||
var logger = new ListLogger();
|
||||
|
||||
FlypaperHttpExtensions.WarnAboutRemovedSettings(new ConfigurationBuilder().Build(), logger);
|
||||
|
||||
logger.Entries.ShouldBeEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user