Add explanation rules for catches, editable over MCP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4086fa3da3
commit
2437880013
37 files changed
+1867
-37
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using Flypaper.Core.Models;
|
||||
using Flypaper.Storage.Explanations;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests.Storage;
|
||||
|
||||
public sealed class ExplanationTextTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("GET 188.103.168.113/.git/HEAD", "/.git/HEAD")]
|
||||
[InlineData("GET anticarnist.de/", "/")]
|
||||
[InlineData("GET /", "/")]
|
||||
[InlineData("GET /x.php?a=1/2", "/x.php?a=1/2")]
|
||||
[InlineData("GET _/boaform/admin", "/boaform/admin")]
|
||||
[InlineData("GET example.com", "/")]
|
||||
[InlineData("POST example.com:8080/api?x=/y", "/api?x=/y")]
|
||||
[InlineData("raw", "raw")]
|
||||
[InlineData(null, null)]
|
||||
public void Extracts_the_path_without_method_and_host(string? target, string? expected) =>
|
||||
ExplanationText.Path(target).ShouldBe(expected);
|
||||
|
||||
[Theory]
|
||||
[InlineData(TrapOutcome.ClientAborted, 9400, "ClientAborted 9s")]
|
||||
[InlineData(TrapOutcome.Timeout, 60000, "Timeout 60s")]
|
||||
[InlineData(TrapOutcome.Completed, 999, "Completed 0s")]
|
||||
[InlineData(TrapOutcome.Rejected, 0, "Rejected")]
|
||||
public void Describes_outcome_and_whole_seconds(TrapOutcome outcome, long milliseconds, string expected) =>
|
||||
ExplanationText.Outcome(outcome, milliseconds).ShouldBe(expected);
|
||||
|
||||
[Theory]
|
||||
[InlineData("/wp-content/uploads/2024/05/x.php?v=3", "/wp-content/uploads/{n}/{n}/x.php")]
|
||||
[InlineData("/a/0123456789abcdef/b", "/a/{hex}/b")]
|
||||
[InlineData("/.env", "/.env")]
|
||||
public void Merges_paths_that_differ_only_in_numbers(string path, string expected) =>
|
||||
ExplanationText.PathShape(path).ShouldBe(expected);
|
||||
}
|
||||
Reference in new issue
Block a user