28 lines
680 B
C#
28 lines
680 B
C#
using MyAgent.Storage;
|
|
using Xunit;
|
|
|
|
namespace MyAgent.Tests.Storage;
|
|
|
|
public sealed class SafePathSegmentTests
|
|
{
|
|
[Theory]
|
|
[InlineData(".")]
|
|
[InlineData("..")]
|
|
[InlineData("../other")]
|
|
[InlineData("group/name")]
|
|
[InlineData("group\\name")]
|
|
public void Normalize_RejectsPathTraversal(string value)
|
|
{
|
|
Assert.Throws<ArgumentException>(() => SafePathSegment.Normalize(value, "groupId"));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("915449089")]
|
|
[InlineData("demo-group")]
|
|
[InlineData("user_1")]
|
|
public void Normalize_AcceptsStableIdentifiers(string value)
|
|
{
|
|
Assert.Equal(value, SafePathSegment.Normalize(value, "id"));
|
|
}
|
|
}
|