feat: add fnOS packaging, storage workflows and release pipeline
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using dy.net.storage;
|
||||
using dy.net.Tests.TestInfrastructure;
|
||||
|
||||
namespace dy.net.Tests;
|
||||
|
||||
public class SafeLocalMigrationFileTests
|
||||
{
|
||||
[Fact]
|
||||
public void TryResolve_AllowsRegularFileInsideConfiguredRoot()
|
||||
{
|
||||
using var temporary = new TemporaryDirectory();
|
||||
var root = Path.Combine(temporary.Path, "media");
|
||||
Directory.CreateDirectory(root);
|
||||
var file = Path.Combine(root, "video.mp4");
|
||||
File.WriteAllText(file, "media");
|
||||
|
||||
Assert.True(SafeLocalMigrationFile.TryResolve(file, new[] { root }, out var resolved, out var error), error);
|
||||
Assert.Equal(Path.GetFullPath(file), resolved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_RejectsFileOutsideConfiguredRoot()
|
||||
{
|
||||
using var temporary = new TemporaryDirectory();
|
||||
var root = Path.Combine(temporary.Path, "media");
|
||||
Directory.CreateDirectory(root);
|
||||
var outside = Path.Combine(temporary.Path, "outside.mp4");
|
||||
File.WriteAllText(outside, "media");
|
||||
|
||||
Assert.False(SafeLocalMigrationFile.TryResolve(outside, new[] { root }, out _, out var error));
|
||||
Assert.Contains("根目录", error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_RejectsSymbolicLink()
|
||||
{
|
||||
using var temporary = new TemporaryDirectory();
|
||||
var root = Path.Combine(temporary.Path, "media");
|
||||
Directory.CreateDirectory(root);
|
||||
var target = Path.Combine(root, "target.mp4");
|
||||
var link = Path.Combine(root, "link.mp4");
|
||||
File.WriteAllText(target, "media");
|
||||
File.CreateSymbolicLink(link, target);
|
||||
|
||||
Assert.False(SafeLocalMigrationFile.TryResolve(link, new[] { root }, out _, out var error));
|
||||
Assert.Contains("符号链接", error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryResolve_RejectsConfiguredRootThatIsSymbolicLink()
|
||||
{
|
||||
using var temporary = new TemporaryDirectory();
|
||||
var actualRoot = Path.Combine(temporary.Path, "actual-media");
|
||||
var linkedRoot = Path.Combine(temporary.Path, "linked-media");
|
||||
Directory.CreateDirectory(actualRoot);
|
||||
Directory.CreateSymbolicLink(linkedRoot, actualRoot);
|
||||
var file = Path.Combine(linkedRoot, "video.mp4");
|
||||
File.WriteAllText(file, "media");
|
||||
|
||||
Assert.False(SafeLocalMigrationFile.TryResolve(file, new[] { linkedRoot }, out _, out var error));
|
||||
Assert.Contains("符号链接", error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user