Restructure solution into folders and fix persistence issues
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37987a394a
commit
7c39cb5562
62 files changed
+219
-151
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using Flypaper.Http;
|
||||
using Flypaper.Http.Matching;
|
||||
using Flypaper.Tests.Fakes;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Http;
|
||||
|
||||
public sealed class TrapMatcherTests
|
||||
{
|
||||
private readonly TrapMatcher _matcher = new(TestOptions.Monitor(new HttpTrapOptions
|
||||
{
|
||||
KnownHosts = ["example.com", "*.example.org"],
|
||||
TrapPaths = ["/.env", "/.git/*", "/wp-login.php"]
|
||||
}));
|
||||
|
||||
[Theory]
|
||||
[InlineData("example.com", "/")]
|
||||
[InlineData("EXAMPLE.com", "/index.html")]
|
||||
[InlineData("app.example.org", "/api/items")]
|
||||
[InlineData("example.com", "/.envelope")]
|
||||
[InlineData("example.com", "/.git")]
|
||||
public void Lets_normal_requests_pass(string host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.None);
|
||||
|
||||
[Theory]
|
||||
[InlineData("example.com", "/.env")]
|
||||
[InlineData("example.com", "/.ENV")]
|
||||
[InlineData("example.com", "/.env/")]
|
||||
[InlineData("example.com", "/.git/config")]
|
||||
[InlineData("app.example.org", "/wp-login.php")]
|
||||
public void Traps_configured_paths(string host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.TrapPath);
|
||||
|
||||
[Theory]
|
||||
[InlineData("unknown.net", "/")]
|
||||
[InlineData("203.0.113.7", "/")]
|
||||
[InlineData("example.org", "/")]
|
||||
[InlineData("", "/")]
|
||||
[InlineData(null, "/")]
|
||||
public void Traps_unknown_hosts(string? host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.UnknownHost);
|
||||
}
|
||||
Reference in new issue
Block a user