Add data management, randomized HTML drip and public README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3671019e60
commit
f5d8ca7484
46 files changed
+1601
-172
No files matched your search
@@ -7,11 +7,12 @@ public sealed class RuntimeSettingsParserTests
|
||||
{
|
||||
private static readonly RuntimeSettingsInput Valid = new(
|
||||
"/.env\n/wp-admin/*\r\n /xmlrpc.php \n/.env",
|
||||
"00:00:05",
|
||||
"200",
|
||||
"5",
|
||||
"00:30:00",
|
||||
"example.com\n*.example.org");
|
||||
"example.com\n*.example.org",
|
||||
"90",
|
||||
true);
|
||||
|
||||
[Fact]
|
||||
public void Parses_valid_input_and_normalizes_lists()
|
||||
@@ -22,10 +23,35 @@ public sealed class RuntimeSettingsParserTests
|
||||
var settings = result.Settings.ShouldNotBeNull();
|
||||
settings.TrapPaths.ShouldBe(["/.env", "/wp-admin/*", "/xmlrpc.php"]);
|
||||
settings.ExtraKnownHosts.ShouldBe(["example.com", "*.example.org"]);
|
||||
settings.DripInterval.ShouldBe(TimeSpan.FromSeconds(5));
|
||||
settings.MaxConnections.ShouldBe(200);
|
||||
settings.MaxConnectionsPerIp.ShouldBe(5);
|
||||
settings.MaxHoldDuration.ShouldBe(TimeSpan.FromMinutes(30));
|
||||
settings.RetentionDays.ShouldBe(90);
|
||||
settings.IgnorePrivateNetworks.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0", 0)]
|
||||
[InlineData("365", 365)]
|
||||
[InlineData("3650", 3650)]
|
||||
public void Accepts_retention_days_including_unlimited(string value, int expected) =>
|
||||
RuntimeSettingsParser.Parse(Valid with { RetentionDays = value }).Settings.ShouldNotBeNull().RetentionDays.ShouldBe(expected);
|
||||
|
||||
[Theory]
|
||||
[InlineData("-1")]
|
||||
[InlineData("3651")]
|
||||
[InlineData("x")]
|
||||
[InlineData("")]
|
||||
public void Rejects_invalid_retention_days(string value) =>
|
||||
RuntimeSettingsParser.Parse(Valid with { RetentionDays = value }).Errors.Keys.ShouldBe([nameof(RuntimeSettingsInput.RetentionDays)]);
|
||||
|
||||
[Fact]
|
||||
public void Keeps_private_network_choice()
|
||||
{
|
||||
var settings = RuntimeSettingsParser.Parse(Valid with { IgnorePrivateNetworks = false }).Settings.ShouldNotBeNull();
|
||||
|
||||
settings.IgnorePrivateNetworks.ShouldBeFalse();
|
||||
settings.ToConfiguration()[SettingKeys.IgnorePrivateNetworks].ShouldBe("false");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -65,12 +91,12 @@ public sealed class RuntimeSettingsParserTests
|
||||
[InlineData("abc")]
|
||||
[InlineData("")]
|
||||
[InlineData("00:00:00")]
|
||||
[InlineData("02:00:00")]
|
||||
public void Rejects_invalid_drip_intervals(string value)
|
||||
[InlineData("8.00:00:00")]
|
||||
public void Rejects_invalid_hold_durations(string value)
|
||||
{
|
||||
var result = RuntimeSettingsParser.Parse(Valid with { DripInterval = value });
|
||||
var result = RuntimeSettingsParser.Parse(Valid with { MaxHoldDuration = value });
|
||||
|
||||
result.Errors.ShouldContainKey(nameof(RuntimeSettingsInput.DripInterval));
|
||||
result.Errors.ShouldContainKey(nameof(RuntimeSettingsInput.MaxHoldDuration));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
Reference in new issue
Block a user