Unknown IPs get a small WordPress-looking page or icon and are not held; later requests are trapped as before. Switch: Flypaper__Drip__Lure. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System.Net;
|
|
using Flypaper.Core.Models;
|
|
using Flypaper.Storage.Entities;
|
|
using Flypaper.Storage.Queries;
|
|
using Flypaper.Tests.Mcp;
|
|
using Shouldly;
|
|
|
|
namespace Flypaper.Tests.Storage;
|
|
|
|
public sealed class KnownIpLookupTests : IDisposable
|
|
{
|
|
private readonly McpTestData _data = new();
|
|
|
|
[Fact]
|
|
public async Task Knows_only_ips_with_a_stored_catch()
|
|
{
|
|
using (var db = _data.Factory.CreateDbContext())
|
|
{
|
|
var started = McpTestData.Now.AddHours(-2);
|
|
db.TrapEvents.Add(TrapEventEntity.From(new TrapEvent(
|
|
Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("2001:db8::7"), "lure-page", started, started.AddSeconds(1), 100, TrapOutcome.Completed, "GET /", null)));
|
|
db.SaveChanges();
|
|
}
|
|
|
|
var lookup = new KnownIpLookup(_data.Factory);
|
|
|
|
(await lookup.HasSeenAsync(IPAddress.Parse("2001:db8::7"), default)).ShouldBeTrue();
|
|
(await lookup.HasSeenAsync(IPAddress.Parse("203.0.113.99"), default)).ShouldBeFalse();
|
|
}
|
|
|
|
public void Dispose() => _data.Dispose();
|
|
}
|