Mark small countries on the map, fit latest catches table, show missing host
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e2ff3f7ee
commit
31cef44bf3
15 files changed
+475
-27
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using System.Net;
|
||||
using Flypaper.Core;
|
||||
using Flypaper.Core.Abstractions;
|
||||
using Flypaper.Core.Models;
|
||||
using Flypaper.Http;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NSubstitute;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Http;
|
||||
|
||||
public sealed class TargetNormalizationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("_", "GET /boaform/admin/formLogin")]
|
||||
[InlineData("", "GET /boaform/admin/formLogin")]
|
||||
[InlineData("example.com", "GET example.com/boaform/admin/formLogin")]
|
||||
[InlineData("203.0.113.7:8080", "GET 203.0.113.7:8080/boaform/admin/formLogin")]
|
||||
public async Task Stores_missing_or_placeholder_host_as_empty(string host, string expectedTarget)
|
||||
{
|
||||
var sink = Substitute.For<ITrapEventSink>();
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?> { ["Flypaper:MaxConnections"] = "0" })
|
||||
.Build();
|
||||
var services = new ServiceCollection()
|
||||
.AddLogging()
|
||||
.AddSingleton(sink)
|
||||
.AddFlypaperCore(configuration)
|
||||
.AddFlypaperHttp(configuration)
|
||||
.BuildServiceProvider();
|
||||
|
||||
var app = new ApplicationBuilder(services);
|
||||
app.UseFlypaper();
|
||||
app.Run(_ => Task.CompletedTask);
|
||||
|
||||
var context = new DefaultHttpContext { RequestServices = services };
|
||||
context.Connection.RemoteIpAddress = IPAddress.Parse("203.0.113.9");
|
||||
context.Connection.LocalPort = 8080;
|
||||
context.Request.Method = "GET";
|
||||
context.Request.Host = new HostString(host);
|
||||
context.Request.Path = "/boaform/admin/formLogin";
|
||||
|
||||
await app.Build()(context);
|
||||
|
||||
sink.Received(1).Publish(Arg.Is<TrapEvent>(e => e.Target == expectedTarget));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user