Add link labyrinth, static robots.txt and robots bait paths
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b7027e2a72
commit
a25072e6fb
29 files changed
+774
-34
No files matched your search
@@ -6,7 +6,7 @@ namespace Flypaper.Tests.Core;
|
||||
|
||||
public sealed class HoldMethodParserTests
|
||||
{
|
||||
private static readonly HoldMethodInput Valid = new("Alternating", "50", "1000", "1", "64", "2048", true, "01:00:00");
|
||||
private static readonly HoldMethodInput Valid = new("Alternating", "50", "1000", "1", "64", "2048", true, "80", "/Backup-2024, /admin-old/x", "01:00:00");
|
||||
|
||||
[Fact]
|
||||
public void Parses_valid_input()
|
||||
@@ -20,6 +20,8 @@ public sealed class HoldMethodParserTests
|
||||
settings.MaxChunkSize.ShouldBe(64);
|
||||
settings.HeadStartSize.ShouldBe(2048);
|
||||
settings.MatchPath.ShouldBeTrue();
|
||||
settings.LinkSpacing.ShouldBe(80);
|
||||
settings.BaitPaths.ShouldBe("/backup-2024/,/admin-old/x/");
|
||||
settings.MaxHoldDuration.ShouldBe(TimeSpan.FromHours(1));
|
||||
settings.ToConfiguration().Keys.ShouldBe(SettingKeys.HoldMethod, ignoreOrder: true);
|
||||
}
|
||||
@@ -71,6 +73,34 @@ public sealed class HoldMethodParserTests
|
||||
public void Rejects_head_start_out_of_range(string value) =>
|
||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { HeadStartSize = value }).Errors.Keys.ShouldBe([nameof(HoldMethodInput.HeadStartSize)]);
|
||||
|
||||
[Theory]
|
||||
[InlineData("0")]
|
||||
[InlineData("4096")]
|
||||
public void Accepts_link_spacing_bounds(string value) =>
|
||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { LinkSpacing = value }).Settings.ShouldNotBeNull();
|
||||
|
||||
[Theory]
|
||||
[InlineData("-1")]
|
||||
[InlineData("4097")]
|
||||
[InlineData("")]
|
||||
public void Rejects_link_spacing_out_of_range(string value) =>
|
||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { LinkSpacing = value }).Errors.Keys.ShouldBe([nameof(HoldMethodInput.LinkSpacing)]);
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("/a/,/b/")]
|
||||
public void Accepts_bait_paths(string value) =>
|
||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { BaitPaths = value }).Settings.ShouldNotBeNull();
|
||||
|
||||
[Theory]
|
||||
[InlineData("backup")]
|
||||
[InlineData("/robots.txt")]
|
||||
[InlineData("/wiki/old/")]
|
||||
[InlineData("/a b<>/")]
|
||||
[InlineData("/a/,/b/,/c/,/d/,/e/,/f/,/g/,/h/,/i/")]
|
||||
public void Rejects_invalid_bait_paths(string value) =>
|
||||
RuntimeSettingsParser.ParseHoldMethod(Valid with { BaitPaths = value }).Errors.Keys.ShouldBe([nameof(HoldMethodInput.BaitPaths)]);
|
||||
|
||||
[Theory]
|
||||
[InlineData("10")]
|
||||
[InlineData("00:00:00")]
|
||||
|
||||
Reference in new issue
Block a user