42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using w4c_workflows.Services;
|
|
using Xunit;
|
|
|
|
namespace w4c_workflows.Tests;
|
|
|
|
public class WorkflowRepoStoreTests
|
|
{
|
|
[Theory]
|
|
[InlineData("workflows")]
|
|
[InlineData("wiz4apps")]
|
|
[InlineData("my.repo_1-test")]
|
|
public void Accepts_single_safe_repo_names(string input)
|
|
{
|
|
Assert.True(WorkflowRepoStore.TryNormalizeName(input, out var normalized));
|
|
Assert.Equal(input, normalized);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData(".")]
|
|
[InlineData("..")]
|
|
[InlineData("other-owner/repo")]
|
|
[InlineData("../escape")]
|
|
[InlineData("a\\b")]
|
|
[InlineData("repo name")]
|
|
[InlineData("repo\nname")]
|
|
public void Rejects_traversal_owner_prefix_and_unsafe_names(string? input)
|
|
{
|
|
Assert.False(WorkflowRepoStore.TryNormalizeName(input, out var normalized));
|
|
Assert.Equal(string.Empty, normalized);
|
|
}
|
|
|
|
[Fact]
|
|
public void Rejects_names_longer_than_120_chars()
|
|
{
|
|
Assert.False(WorkflowRepoStore.TryNormalizeName(new string('a', 121), out _));
|
|
Assert.True(WorkflowRepoStore.TryNormalizeName(new string('a', 120), out _));
|
|
}
|
|
}
|