diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumCredsCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumCredsCommandTests.cs index 6f9ab993..3248f641 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumCredsCommandTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumCredsCommandTests.cs @@ -19,7 +19,7 @@ namespace Yubico.YubiKey.Fido2.Commands { - [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)] + [Trait(TraitTypes.Category, TestCategories.Elevated)] public class EnumCredsCommandTests : SimpleIntegrationTestConnection { public EnumCredsCommandTests() diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumRpsCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumRpsCommandTests.cs index 52b007fb..c5ea684f 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumRpsCommandTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/EnumRpsCommandTests.cs @@ -19,7 +19,7 @@ namespace Yubico.YubiKey.Fido2.Commands { - [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)] + [Trait(TraitTypes.Category, TestCategories.Elevated)] public class EnumRpsCommandTests : SimpleIntegrationTestConnection { public EnumRpsCommandTests() diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/UpdateUserInfoCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/UpdateUserInfoCommandTests.cs index 9e6ca420..5240bb48 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/UpdateUserInfoCommandTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/UpdateUserInfoCommandTests.cs @@ -19,7 +19,7 @@ namespace Yubico.YubiKey.Fido2.Commands { - [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)] + [Trait(TraitTypes.Category, TestCategories.Elevated)] public class UpdateUserInfoCommandTests : SimpleIntegrationTestConnection { public UpdateUserInfoCommandTests() diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs index e47b5c95..3fc57ad2 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs @@ -20,7 +20,7 @@ namespace Yubico.YubiKey.Fido2 { - [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)] + [Trait(TraitTypes.Category, TestCategories.Elevated)] public class SimpleCredMgmtTests : SimpleIntegrationTestConnection { public SimpleCredMgmtTests() diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs index ae76a62d..aa0d954c 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs @@ -19,6 +19,8 @@ namespace Yubico.YubiKey.Management { [Trait(TraitTypes.Category, TestCategories.Simple)] + [Trait(TraitTypes.Category, TestCategories.RequiresFips)] + public class SetDeviceInfoCommandTests { [SkippableTheory(typeof(DeviceNotFoundException))] diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/ReclaimTimeoutTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/ReclaimTimeoutTests.cs index 4d3cbe27..64dd5b0b 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/ReclaimTimeoutTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/ReclaimTimeoutTests.cs @@ -39,6 +39,7 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) public class ReclaimTimeoutTests { + [Trait(TraitTypes.Category, TestCategories.Elevated)] [Fact] public void SwitchingBetweenTransports_ForcesThreeSecondWait() { @@ -57,7 +58,7 @@ public void SwitchingBetweenTransports_ForcesThreeSecondWait() .AddFilter(level => level >= LogLevel.Information)); // TEST ASSUMPTION: This test requires FIDO. On Windows, that means this test case must run elevated (admin). - IYubiKeyDevice testDevice = IntegrationTestDeviceEnumeration.GetTestDevice(StandardTestDevice.Fw5); + IYubiKeyDevice testDevice = IntegrationTestDeviceEnumeration.GetTestDevice(); // Ensure all interfaces are active if (testDevice.EnabledUsbCapabilities != YubiKeyCapabilities.All) diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs index fa29536b..a081e5e0 100644 --- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs +++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs @@ -38,10 +38,10 @@ public PinTests() } } - IEnumerable devices = HidDevice.GetHidDevices(); + var devices = HidDevice.GetHidDevices(); Assert.NotNull(devices); - HidDevice? deviceToUse = CommandTests.GetFidoHid(devices); + var deviceToUse = CommandTests.GetFidoHid(devices); Assert.NotNull(deviceToUse); if (deviceToUse is null) @@ -69,7 +69,7 @@ public void SetPin_Succeeds() }; var cmd = new GetPagedDeviceInfoCommand(); - GetPagedDeviceInfoResponse rsp = _fidoConnection.SendCommand(cmd); + var rsp = _fidoConnection.SendCommand(cmd); Assert.Equal(ResponseStatus.Success, rsp.Status); var getData = YubiKeyDeviceInfo.CreateFromResponseData(rsp.GetData()); @@ -79,13 +79,13 @@ public void SetPin_Succeeds() } var vfyCmd = new VerifyFipsModeCommand(); - VerifyFipsModeResponse vfyRsp = _fidoConnection.SendCommand(vfyCmd); + var vfyRsp = _fidoConnection.SendCommand(vfyCmd); Assert.Equal(ResponseStatus.Success, vfyRsp.Status); - bool isFipsMode = vfyRsp.GetData(); + var isFipsMode = vfyRsp.GetData(); Assert.True(isFipsMode); var setCmd = new SetPinCommand(currentPin, newPin); - SetPinResponse setRsp = _fidoConnection.SendCommand(setCmd); + var setRsp = _fidoConnection.SendCommand(setCmd); Assert.Equal(ResponseStatus.Success, setRsp.Status); setCmd = new SetPinCommand(newPin, currentPin); @@ -108,7 +108,7 @@ public void InvalidPin_CorrectError() }; var setCmd = new SetPinCommand(currentPin, badPin); - SetPinResponse setRsp = _fidoConnection.SendCommand(setCmd); + var setRsp = _fidoConnection.SendCommand(setCmd); Assert.Equal(ResponseStatus.Failed, setRsp.Status); } @@ -123,7 +123,7 @@ public void VerifyPin_Succeeds() }; var cmd = new GetPagedDeviceInfoCommand(); - GetPagedDeviceInfoResponse rsp = _fidoConnection.SendCommand(cmd); + var rsp = _fidoConnection.SendCommand(cmd); Assert.Equal(ResponseStatus.Success, rsp.Status); var getData = YubiKeyDeviceInfo.CreateFromResponseData(rsp.GetData()); @@ -133,7 +133,7 @@ public void VerifyPin_Succeeds() } var vfyCmd = new VerifyPinCommand(correctPin); - VerifyPinResponse vfyRsp = _fidoConnection.SendCommand(vfyCmd); + var vfyRsp = _fidoConnection.SendCommand(vfyCmd); Assert.Equal(ResponseStatus.Success, vfyRsp.Status); vfyCmd = new VerifyPinCommand(wrongPin); @@ -161,7 +161,7 @@ public void WrongPin_ThreeTimes() // Not sure how to run this test 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 }; - bool isValid = IsYubiKeyVersion4Fips(out bool isFipsMode); + var isValid = IsYubiKeyVersion4Fips(out var isFipsMode); Skip.IfNot(isValid); if (!isFipsMode) { @@ -170,7 +170,7 @@ public void WrongPin_ThreeTimes() // Not sure how to run this test } var vfyCmd = new VerifyPinCommand(correctPin); - VerifyPinResponse vfyRsp = _fidoConnection.SendCommand(vfyCmd); + var vfyRsp = _fidoConnection.SendCommand(vfyCmd); Assert.Equal(ResponseStatus.Success, vfyRsp.Status); // Verify with the wrong PIN 3 times. @@ -198,7 +198,7 @@ private bool IsYubiKeyVersion4Fips(out bool isFipsMode) isFipsMode = false; var cmd = new GetPagedDeviceInfoCommand(); - GetPagedDeviceInfoResponse rsp = _fidoConnection.SendCommand(cmd); + var rsp = _fidoConnection.SendCommand(cmd); if (rsp.Status != ResponseStatus.Success) { return false; @@ -214,7 +214,7 @@ private bool IsYubiKeyVersion4Fips(out bool isFipsMode) } var vfyCmd = new VerifyFipsModeCommand(); - VerifyFipsModeResponse vfyRsp = _fidoConnection.SendCommand(vfyCmd); + var vfyRsp = _fidoConnection.SendCommand(vfyCmd); if (vfyRsp.Status != ResponseStatus.Success) { return false; @@ -230,7 +230,7 @@ private bool IsYubiKeyVersion4Fips(out bool isFipsMode) private bool SetU2fPin(byte[] newPin) { var setCmd = new SetPinCommand(ReadOnlyMemory.Empty, newPin); - SetPinResponse setRsp = _fidoConnection.SendCommand(setCmd); + var setRsp = _fidoConnection.SendCommand(setCmd); return setRsp.Status == ResponseStatus.Success; } diff --git a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs index 9bcd2542..5b4b01ae 100644 --- a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs +++ b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs @@ -14,7 +14,7 @@ namespace Yubico.YubiKey.TestUtilities { - public class TestCategories + public static class TestCategories { /// /// When touch is required, the user should touch the YubiKey. @@ -22,17 +22,18 @@ public class TestCategories /// aware of when touch is about to be expected. /// public const string RequiresTouch = "RequiresTouch"; + /// /// These tests are considered to be simple and should not require any special circumstances to run successfully. /// public const string Simple = "Simple"; + /// - /// These tests require that you run your tests in an elevated session, e.g. 'Run as Administrator' on Windows + /// These tests require that you run your tests in an elevated session, e.g. 'Run as Administrator' on Windows. + /// For example, all FIDO tests require an elevated session on Windows. /// public const string Elevated = "Elevated"; - public const string FirmwareOrHardwareMismatch = "FirmwareOrHardwareMismatch"; - /// /// These tests require a Yubikey with biometric capabilities /// @@ -46,10 +47,15 @@ public class TestCategories /// /// These tests may require step debugging to avoid timing issues /// - public const string RequiresStepDebug = "RequiresStepDebug"; + public const string RequiresStepDebug = "RequiresStepDebug"; + + /// + /// These tests require a Yubikey with FIPS + /// + public const string RequiresFips = "RequiresFips"; } - public class TraitTypes + public static class TraitTypes { public const string Category = "Category"; }