Public Access
65 lines
2.4 KiB
C#
65 lines
2.4 KiB
C#
using DodoSSH.Client.Shell.ViewModels;
|
|
|
|
namespace DodoSSH.Client.App.Tests;
|
|
|
|
/// <summary>
|
|
/// That unlocking with the device key is described in the words of the platform it runs on.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The unlock card offered "USE WINDOWS HELLO" on a Mac and the settings page told a Linux machine it needed a
|
|
/// Windows keystore. Each platform's wording is checked for every other platform's names, because that is the
|
|
/// mistake: a sentence borrowed from the one platform the feature was written on first.
|
|
/// </remarks>
|
|
public sealed class DeviceUnlockWordingTests
|
|
{
|
|
public static TheoryData<string> Platforms => ["Windows", "Mac", "Linux", "Android"];
|
|
|
|
[Theory]
|
|
[MemberData(nameof(Platforms))]
|
|
public void EachPlatform_NamesOnlyItsOwnGesture(string platform)
|
|
{
|
|
var wording = For(platform);
|
|
|
|
var foreign = new Dictionary<string, string[]>(StringComparer.Ordinal)
|
|
{
|
|
["Windows"] = ["Touch ID", "Secure Enclave", "fingerprint", "PIN"],
|
|
["Mac"] = ["Windows", "TPM", "fingerprint", "PIN"],
|
|
["Linux"] = ["Windows", "Touch ID", "Secure Enclave", "fingerprint"],
|
|
["Android"] = ["Windows", "TPM", "Touch ID", "Secure Enclave"],
|
|
}[platform];
|
|
|
|
string[] said =
|
|
[wording.Name, wording.Button, wording.Wait, wording.Offer, wording.Registered, wording.Unavailable, wording.Tip];
|
|
|
|
foreach (var sentence in said)
|
|
{
|
|
sentence.ShouldNotBeNullOrWhiteSpace();
|
|
|
|
foreach (var name in foreign)
|
|
{
|
|
sentence.ShouldNotContain(name, Case.Sensitive, $"{platform}: \"{sentence}\"");
|
|
}
|
|
}
|
|
|
|
wording.Button.ShouldBe(wording.Button.ToUpperInvariant(), "every button on these screens is in capitals");
|
|
}
|
|
|
|
[Fact]
|
|
public void TheWordingInUse_IsThisMachines()
|
|
{
|
|
var expected = OperatingSystem.IsMacOS() ? DeviceUnlockWording.Mac
|
|
: OperatingSystem.IsLinux() ? DeviceUnlockWording.Linux
|
|
: DeviceUnlockWording.Windows;
|
|
|
|
DeviceUnlockWording.ForThisPlatform.ShouldBeSameAs(expected);
|
|
}
|
|
|
|
private static DeviceUnlockWording For(string platform) => platform switch
|
|
{
|
|
"Windows" => DeviceUnlockWording.Windows,
|
|
"Mac" => DeviceUnlockWording.Mac,
|
|
"Linux" => DeviceUnlockWording.Linux,
|
|
_ => DeviceUnlockWording.Android,
|
|
};
|
|
}
|