using DodoSSH.Client.App.Platform; using DodoSSH.Client.Session; namespace DodoSSH.Client.App.Tests; /// /// DeviceKeyNames: which hardware key a profile's device unlock is sealed to. /// /// /// The stores themselves cannot be exercised here — every call past the probe raises a Windows Hello or /// Touch ID dialog — so the rule that keeps two installations off one key is tested on its own. It is the /// whole of what stops signing out of the nightly deleting the key the release build unlocks with. /// public sealed class DeviceKeyNamesTests { private const string Legacy = "DodoSSH.DeviceKey.v1"; [Fact] public void TheDefaultProfile_KeepsTheNameEveryExistingInstallIsSealedTo() => DeviceKeyNames.For(ClientPaths.Default, Legacy).ShouldBe(Legacy); [Fact] public void TheNightlyProfile_HasAKeyOfItsOwn() { var nightly = DeviceKeyNames.For(ClientPaths.ForChannel("nightly"), Legacy); nightly.ShouldNotBe(Legacy); nightly.ShouldStartWith(Legacy + "."); } [Fact] public void TwoProfilesWhoseFoldersShareAName_HaveDifferentKeys() { var first = new ClientPaths(Path.Combine(Path.GetTempPath(), "one", "DodoSSH")); var second = new ClientPaths(Path.Combine(Path.GetTempPath(), "two", "DodoSSH")); DeviceKeyNames.For(first, Legacy).ShouldNotBe(DeviceKeyNames.For(second, Legacy)); } [Fact] public void OneProfile_AlwaysNamesTheSameKey() { var directory = Path.Combine(Path.GetTempPath(), "portable", "DodoSSH"); DeviceKeyNames.For(new ClientPaths(directory), Legacy) .ShouldBe(DeviceKeyNames.For(new ClientPaths(directory + Path.DirectorySeparatorChar), Legacy)); } }