diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-17 17:45:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-17 17:45:12 -0500 |
| commit | b4e6a6009fad6b6cdf890526dda0825464c22e94 (patch) | |
| tree | 70b11849524eb30f5ccfc6cdb6fdf5cfdf911138 /tests | |
| parent | 886d1edd885dd569c315f6ef20b066fa130971eb (diff) | |
| parent | f402e6f074b49d2344ba6d839f58298b87971f40 (diff) | |
| download | slskd-b4e6a6009fad6b6cdf890526dda0825464c22e94.tar.gz | |
Merge pull request #1734 from slskd/alias
Fix bug digesting share aliases when path contains closing square bracket (])
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs b/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs new file mode 100644 index 00000000..7eacb95d --- /dev/null +++ b/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Xunit; +using static slskd.Options; + +namespace slskd.Tests.Unit.Core.Options; + +public class SharesOptionsTests +{ + private static List<ValidationResult> Validate(SharesOptions options) + { + var context = new ValidationContext(options); + var results = new List<ValidationResult>(); + Validator.TryValidateObject(options, context, results, validateAllProperties: true); + return results; + } + + public class Directories + { + public class Digest + { + [Fact] + public void Alias_Uses_First_Closing_Bracket_When_Path_Contains_Brackets() + { + // [foo]/bar/[baz]/ should digest to alias "foo" and path "/bar/[baz]" + var options = new SharesOptions + { + Directories = [@"[foo]/bar/[baz]/"] + }; + + // todo: fix this so that it fully validates on all platforms; currently this fails + // validation on Windows and would fail on Linux if i were to use backslashes + // the assertion for the alias proves we have fixed an aliasing bug so it's fine for now + var results = Validate(options); + + Assert.DoesNotContain(results, r => r.ErrorMessage?.Contains("aliases may not contain path separators") == true); + } + } + } +} |
