feat: acquire legacy settings from approved network source
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Launcher.Next.Application;
|
||||
using Xunit;
|
||||
|
||||
namespace Launcher.Next.Tests;
|
||||
|
||||
public sealed class LegacyNetworkConfigurationTests
|
||||
{
|
||||
[Fact]
|
||||
public void ApprovedSettingsEndpoint_IsExactUncFile()
|
||||
{
|
||||
Assert.Equal(@"\\phimproject.com\common\BIM\save\All_Serv_Install\Settings.xml", LegacyNetworkConfiguration.ApprovedSettingsEndpoint);
|
||||
Assert.StartsWith(@"\\", LegacyNetworkConfiguration.ApprovedSettingsEndpoint, StringComparison.Ordinal);
|
||||
Assert.EndsWith("Settings.xml", LegacyNetworkConfiguration.ApprovedSettingsEndpoint, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"N:\BIM", @"\\phimproject.com\common\BIM")]
|
||||
[InlineData(@"N:\BIM\save\Apps\Plant3D\DriveA", @"\\phimproject.com\common\BIM\save\Apps\Plant3D\DriveA")]
|
||||
public void ApprovedNDriveAlias_ResolvesOnlyBimNamespace(string original, string expected)
|
||||
=> Assert.Equal(expected, LegacyNetworkConfiguration.ResolveApprovedAlias(original));
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"N:\Other\payload.dll")]
|
||||
[InlineData(@"Q:\BIM\save\Apps")]
|
||||
[InlineData("relative\\Settings.xml")]
|
||||
public void UnknownLegacyAliases_AreRejected(string path)
|
||||
=> Assert.Equal("LEGACY_NETWORK_ALIAS_NOT_APPROVED", Assert.Throws<InvalidOperationException>(() => LegacyNetworkConfiguration.ResolveApprovedAlias(path)).Message);
|
||||
|
||||
[Fact]
|
||||
public void UnapprovedEndpoint_IsRejectedBeforeAnyNetworkAccess()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "launcher-network-" + Guid.NewGuid().ToString("N"));
|
||||
try
|
||||
{
|
||||
Assert.Equal("LEGACY_SETTINGS_ENDPOINT_NOT_APPROVED", Assert.Throws<InvalidOperationException>(() => LegacyNetworkConfiguration.AcquireApprovedSnapshot(@"\\example.invalid\Settings.xml", root)).Message);
|
||||
}
|
||||
finally { if (Directory.Exists(root)) Directory.Delete(root, true); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user