Files
TomandClaude Opus 5.5 2437880013
Build and deploy / build (push) Successful in 1m29s
Build and deploy / deploy (push) Successful in 21s
Add explanation rules for catches, editable over MCP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 11:46:22 +01:00

37 lines
1.5 KiB
C#

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);
}