diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/IYubiKeyDeviceInfo.cs b/Yubico.YubiKey/src/Yubico/YubiKey/IYubiKeyDeviceInfo.cs
index f4c88865..a9951445 100644
--- a/Yubico.YubiKey/src/Yubico/YubiKey/IYubiKeyDeviceInfo.cs
+++ b/Yubico.YubiKey/src/Yubico/YubiKey/IYubiKeyDeviceInfo.cs
@@ -56,6 +56,7 @@ public interface IYubiKeyDeviceInfo
///
/// The serial number of the YubiKey, if one is present.
+ /// Security Keys don't have serial numbers
///
public int? SerialNumber { get; }
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaOaepTimingTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaOaepTimingTests.cs
index d0bcd9df..0cb8dc96 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaOaepTimingTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaOaepTimingTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Cryptography
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class RsaOaepTimingTests
{
private const int IterationCount1024 = 200000;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaP1TimingTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaP1TimingTests.cs
index 956e7d64..ca90811d 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaP1TimingTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Cryptography/RsaP1TimingTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Cryptography
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class RsaP1TimingTests
{
private const int IterationCount1024 = 10000000;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/BioEnrollTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/BioEnrollTests.cs
index 12193b94..a74be24a 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/BioEnrollTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/BioEnrollTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Fido2
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class BioEnrollTests : SimpleIntegrationTestConnection
{
// Set to 0 meaning don't cancel.
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/BioEnrollmentCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/BioEnrollmentCommandTests.cs
index ffd90112..a3365b47 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/BioEnrollmentCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/BioEnrollmentCommandTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class BioEnrollmentCommandTests : NeedPinToken
{
public BioEnrollmentCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/ConfigCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/ConfigCommandTests.cs
index 003e6884..30b162d9 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/ConfigCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/ConfigCommandTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class ConfigCommandTests : NeedPinToken
{
public ConfigCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/DeleteCredCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/DeleteCredCommandTests.cs
index e256cc2f..ecaf395e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/DeleteCredCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/DeleteCredCommandTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class DeleteCredCommandTests : SimpleIntegrationTestConnection
{
public DeleteCredCommandTests()
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 96582d1b..6f9ab993 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("Category", "FirmwareOrHardwareMissmatch")]
+ [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)]
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 c8210a16..52b007fb 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("Category", "FirmwareOrHardwareMissmatch")]
+ [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)]
public class EnumRpsCommandTests : SimpleIntegrationTestConnection
{
public EnumRpsCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetAssertionCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetAssertionCommandTests.cs
index fc9cdfc5..c4d33abd 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetAssertionCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetAssertionCommandTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class GetAssertionCommandTests : NeedPinToken
{
public GetAssertionCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetKeyAgreeCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetKeyAgreeCommandTests.cs
index 2f8e8c21..4522a935 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetKeyAgreeCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/GetKeyAgreeCommandTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class GetKeyAgreeCommandTests : SimpleIntegrationTestConnection
{
public GetKeyAgreeCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/HmacSecretTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/HmacSecretTests.cs
index ea25ee55..a3904f7e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/HmacSecretTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/HmacSecretTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class HmacSecretTests : SimpleIntegrationTestConnection
{
private readonly byte[] _pin;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredBlobTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredBlobTests.cs
index 90310d0c..3ff0f57a 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredBlobTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredBlobTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class MakeCredBlobTests : NeedPinToken
{
private readonly byte[] _clientDataHash = {
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredentialCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredentialCommandTests.cs
index 8442cdd9..b12d1692 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredentialCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeCredentialCommandTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class MakeCredentialCommandTests : NeedPinToken
{
public MakeCredentialCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeLargeBlobTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeLargeBlobTests.cs
index 1e50a891..0381b2a4 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeLargeBlobTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/MakeLargeBlobTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class MakeLargeBlobTests : NeedPinToken
{
public MakeLargeBlobTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/SetPinCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/SetPinCommandTests.cs
index 55887134..deb83a3e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/SetPinCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/Commands/SetPinCommandTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Fido2.Commands
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class SetPinCommandTests : SimpleIntegrationTestConnection
{
private const int Fido2AuthPin = 1;
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 77b2784a..9e6ca420 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("Category", "FirmwareOrHardwareMissmatch")]
+ [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)]
public class UpdateUserInfoCommandTests : SimpleIntegrationTestConnection
{
public UpdateUserInfoCommandTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/ConfigTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/ConfigTests.cs
index 3323dd87..f449e123 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/ConfigTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/ConfigTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Fido2
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ConfigTests : SimpleIntegrationTestConnection
{
public ConfigTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/CredMgmtTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/CredMgmtTests.cs
index 81f31d38..67627cfc 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/CredMgmtTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/CredMgmtTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Fido2
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class CredMgmtTests : IClassFixture
{
private readonly BioFido2Fixture _bioFido2Fixture;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/GetAuthenticatorInfoTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/GetAuthenticatorInfoTests.cs
index 1d36f6b9..f2466f61 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/GetAuthenticatorInfoTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/GetAuthenticatorInfoTests.cs
@@ -14,13 +14,14 @@
using System.Linq;
using Xunit;
+using Yubico.YubiKey.TestUtilities;
namespace Yubico.YubiKey.Fido2
{
public class GetAuthenticatorInfoTests
{
[Fact]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public void GetAuthenticator_Succeeds()
{
IYubiKeyDevice yubiKey = YubiKeyDevice.FindAll().First();
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/LargeBlobTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/LargeBlobTests.cs
index afe6f9f3..65c00549 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/LargeBlobTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/LargeBlobTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Fido2
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class LargeBlobTests
{
static readonly byte[] _clientDataHash = {
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialBlobTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialBlobTests.cs
index 3ec796dc..059ee4b0 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialBlobTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialBlobTests.cs
@@ -25,7 +25,7 @@ public class MakeCredentialBlobTests
[Fact]
public void CredBlobExtension_Correct()
{
- IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevices()[0];
+ IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevice();
IYubiKeyConnection connection = yubiKeyDevice.Connect(YubiKeyApplication.Fido2);
var getInfoCmd = new GetInfoCommand();
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialGetAssertionTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialGetAssertionTests.cs
index 4bccafff..764d1eed 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialGetAssertionTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MakeCredentialGetAssertionTests.cs
@@ -31,7 +31,7 @@ public class MakeCredentialGetAssertionTests
static readonly RelyingParty _rp = new RelyingParty("relyingparty1");
// This test requires user to touch the device.
- [Fact, Trait("Category", "RequiresTouch")]
+ [Fact, Trait(TraitTypes.Category, TestCategories.RequiresTouch)]
public void MakeCredential_NonDiscoverable_GetAssertion_Succeeds()
{
IYubiKeyDevice yubiKeyDevice = YubiKeyDevice.FindByTransport(Transport.HidFido).First();
@@ -85,7 +85,7 @@ public void MakeCredential_NonDiscoverable_GetAssertion_Succeeds()
}
// This test requires user to touch the device.
- [Fact, Trait("Category", "RequiresTouch")]
+ [Fact, Trait(TraitTypes.Category, TestCategories.RequiresTouch)]
public void MakeCredential_NoName_GetAssertion_Succeeds()
{
IYubiKeyDevice yubiKeyDevice = YubiKeyDevice.FindByTransport(Transport.HidFido).First();
@@ -124,7 +124,7 @@ public void MakeCredential_NoName_GetAssertion_Succeeds()
}
// This test requires user to touch the device.
- [Fact, Trait("Category", "RequiresTouch")]
+ [Fact, Trait(TraitTypes.Category, TestCategories.RequiresTouch)]
public void MakeCredential_MultipleCredentials_GetAssertion_ReturnsMultipleAssertions()
{
IYubiKeyDevice yubiKeyDevice = YubiKeyDevice.FindByTransport(Transport.HidFido).First();
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MinPinLenTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MinPinLenTests.cs
index 103fc6de..02d64f56 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MinPinLenTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/MinPinLenTests.cs
@@ -42,7 +42,7 @@ public MinPinLenTests()
}
[Fact]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public void GetMinPinFromCredential_Succeeds()
{
using (var fido2Session = new Fido2Session(Device))
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/NoSerialNumberTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/NoSerialNumberTests.cs
deleted file mode 100644
index 6f80fd11..00000000
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/NoSerialNumberTests.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2023 Yubico AB
-//
-// Licensed under the Apache License, Version 2.0 (the "License").
-// You may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using Xunit;
-using Yubico.YubiKey.TestUtilities;
-
-namespace Yubico.YubiKey.Fido2
-{
- public class NoSerialNumberTests
- {
- [Fact]
- [Trait("Category", "Simple")]
- public void GetTestDevice_NoSerialNumber_Succeeds()
- {
- IYubiKeyDevice device = IntegrationTestDeviceEnumeration.GetTestDevice(StandardTestDevice.Fw5, false);
- Assert.NotNull(device);
- if (device.SerialNumber is null)
- {
- _ = Assert.Throws(() => IntegrationTestDeviceEnumeration.GetTestDevice(StandardTestDevice.Fw5));
- }
- }
- }
-}
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/PinCollectionTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/PinCollectionTests.cs
index 132f4cff..1ee47750 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/PinCollectionTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/PinCollectionTests.cs
@@ -17,13 +17,14 @@
using System.Text;
using Xunit;
using Yubico.YubiKey.Fido2.Commands;
+using Yubico.YubiKey.TestUtilities;
namespace Yubico.YubiKey.Fido2
{
public class PinCollectionTests
{
[Fact]
- [Trait("Category", "RequiresSetup")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresSetup)]
public void PinOperations_Succeed()
{
// Assumption - the YubiKey returned has a new or reset FIDO2 application with no PIN set.
@@ -83,7 +84,7 @@ public void PinOperations_Succeed()
}
[Fact]
- [Trait("Category", "RequiresSetup")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresSetup)]
public void UvOperations_Succeed()
{
// Test assumptions: PIN is already set to 123456 (UTF-8 chars, not the number `123456`)
@@ -99,7 +100,7 @@ public void UvOperations_Succeed()
}
[Fact]
- [Trait("Category", "RequiresSetup")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresSetup)]
public void InvalidPinFollowedByValidPin_Succeeds()
{
// Test assumption: PIN is already set to 123456 (UTF-8 chars, not the number `123456`)
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/SimpleCredMgmtTests.cs
index 56bb51cc..e47b5c95 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("Category", "FirmwareOrHardwareMissmatch")]
+ [Trait(TraitTypes.Category, TestCategories.FirmwareOrHardwareMismatch)]
public class SimpleCredMgmtTests : SimpleIntegrationTestConnection
{
public SimpleCredMgmtTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/VerifyFpTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/VerifyFpTests.cs
index 4af51eec..d1532f81 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/VerifyFpTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/VerifyFpTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Fido2
{
- [Trait("Category", "RequiresBio")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresBio)]
public class VerifyFpTests : SimpleIntegrationTestConnection
{
public VerifyFpTests()
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/HasFidoFeatureTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/HasFidoFeatureTests.cs
index e78df759..5f847539 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/HasFidoFeatureTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/HasFidoFeatureTests.cs
@@ -33,7 +33,7 @@ public void HasFeature_ApplicationOTP_Correct()
[Fact]
public void HasFeature_ApplicationU2F_Correct()
{
- IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevices().First();
+ IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevice();
bool expectedResult = true;
//Can this be removed?
@@ -50,7 +50,7 @@ public void HasFeature_ApplicationU2F_Correct()
[Fact]
public void HasFeature_ApplicationFido2_Correct()
{
- IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevices().First();
+ IYubiKeyDevice yubiKeyDevice = IntegrationTestDeviceEnumeration.GetTestDevice();
bool expectedResult = true;
if (!yubiKeyDevice.IsSkySeries && yubiKeyDevice.FirmwareVersion.Major < 5)
{
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs
index 95c8aa6a..ae76a62d 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Management/SetDeviceInfoCommandTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Management
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class SetDeviceInfoCommandTests
{
[SkippableTheory(typeof(DeviceNotFoundException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/CredentialTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/CredentialTests.cs
index ca78003d..db72f3d0 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/CredentialTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/CredentialTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Oath
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[TestCaseOrderer(PriorityOrderer.TypeName, PriorityOrderer.AssembyName)]
public class CredentialTests : IClassFixture
{
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/GetLargeData.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/GetLargeData.cs
index e52691be..2e12dfb2 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/GetLargeData.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/GetLargeData.cs
@@ -24,7 +24,7 @@ namespace Yubico.YubiKey.Oath
// retrieve large amounts of data that spans more
// than one APDU. For more information, see
// Pipelines.ResponseChainingTransform.
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class GetLargeData
{
private static readonly Random random = new Random();
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/NoCollectorPasswordTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/NoCollectorPasswordTests.cs
index dca64dbe..a70f7204 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/NoCollectorPasswordTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/NoCollectorPasswordTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Oath
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class NoCollectorPasswordTests
{
[Fact]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionCredentialTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionCredentialTests.cs
index 3d0b1402..17c35d60 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionCredentialTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionCredentialTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Oath
{
[TestCaseOrderer(PriorityOrderer.TypeName, PriorityOrderer.AssembyName)]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class OathSessionCredentialTests : IClassFixture
{
// Shared object instance across tests.
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionPasswordTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionPasswordTests.cs
index e8a212e2..ce3043ab 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionPasswordTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/OathSessionPasswordTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Oath
{
[TestCaseOrderer(PriorityOrderer.TypeName, PriorityOrderer.AssembyName)]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class OathSessionPasswordTests
{
[Theory, TestPriority(0)]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/SelectApplicationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/SelectApplicationTests.cs
index 60c969f2..1f1ac830 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/SelectApplicationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Oath/SelectApplicationTests.cs
@@ -17,7 +17,7 @@
namespace Yubico.YubiKey.Oath
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class SelectApplicationTests
{
[SkippableTheory(typeof(DeviceNotFoundException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ConfigureStaticTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ConfigureStaticTests.cs
index 2a6b7c87..13db5955 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ConfigureStaticTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ConfigureStaticTests.cs
@@ -23,7 +23,7 @@ namespace Yubico.YubiKey.Otp
public class ConfigureStaticTests
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
[InlineData(StandardTestDevice.Fw5Fips)]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenHidTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenHidTests.cs
index 36818d1a..3d0a6847 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenHidTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenHidTests.cs
@@ -15,10 +15,11 @@
using Xunit;
using Xunit.Abstractions;
using Yubico.Core.Devices.Hid;
+using Yubico.YubiKey.TestUtilities;
namespace Yubico.PlatformInterop
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ListenHidTests
{
private int _counter;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenSmartCardTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenSmartCardTests.cs
index 03cfd75f..1147f17d 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenSmartCardTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Otp/ListenSmartCardTests.cs
@@ -15,10 +15,11 @@
using Xunit;
using Xunit.Abstractions;
using Yubico.Core.Devices.SmartCard;
+using Yubico.YubiKey.TestUtilities;
namespace Yubico.PlatformInterop
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ListenSmartCardTests
{
private int _counter;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AesMgmtKeyTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AesMgmtKeyTests.cs
index e41cd161..c24cbb1d 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AesMgmtKeyTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AesMgmtKeyTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class AesMgmtKeyTests : IDisposable
{
private readonly Memory _currentKey;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AttestTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AttestTests.cs
index 2caf993b..ba1921ef 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AttestTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/AttestTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class AttestTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertSizeTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertSizeTests.cs
index 03cbb84a..39e444a7 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertSizeTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertSizeTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class CertSizeTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertTests.cs
index 3f72c9e5..db137b1e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/CertTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class CertTests
{
[SkippableTheory(typeof(NotSupportedException), typeof(DeviceNotFoundException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ChangePinWithDerivedTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ChangePinWithDerivedTests.cs
index 9815ba5c..cc959505 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ChangePinWithDerivedTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ChangePinWithDerivedTests.cs
@@ -25,7 +25,7 @@ namespace Yubico.YubiKey.Piv
// set of bytes, followed by 2048 random bytes. If you want to get only
// random bytes, skip the first SpecifiedStart bytes (get a random object and
// generate that many bytes).
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ChangePinWithDerivedTests : IDisposable
{
private readonly IYubiKeyDevice yubiKey;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Commands/AuthMgmtKeyCmdTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Commands/AuthMgmtKeyCmdTests.cs
index a1870888..7fca166e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Commands/AuthMgmtKeyCmdTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Commands/AuthMgmtKeyCmdTests.cs
@@ -24,7 +24,7 @@ namespace Yubico.YubiKey.Piv.Commands
// set of bytes, followed by 2048 random bytes. If you want to get only
// random bytes, skip the first SpecifiedStart bytes (get a random object and
// generate that many bytes).
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class AuthMgmtKeyCmdTests : IDisposable
{
private readonly IYubiKeyDevice yubiKey;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/DecryptTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/DecryptTests.cs
index d36ce745..a3b1f277 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/DecryptTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/DecryptTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class DecryptTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GenerateTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GenerateTests.cs
index 0b58b1d4..cf3c6e7b 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GenerateTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GenerateTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class GenerateTests
{
[SkippableTheory(typeof(NotSupportedException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GetPutDataTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GetPutDataTests.cs
index e77cbd77..9ff52ba1 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GetPutDataTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/GetPutDataTests.cs
@@ -377,7 +377,7 @@ public void Printed_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void Security_Auth_Req(StandardTestDevice testDeviceType)
@@ -496,7 +496,7 @@ public void KeyHistory_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void Iris_Auth_Req(StandardTestDevice testDeviceType)
@@ -597,7 +597,7 @@ public void Iris_Auth_Req(StandardTestDevice testDeviceType)
}
[SkippableTheory(typeof(DeviceNotFoundException))]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[InlineData(StandardTestDevice.Fw5)]
public void Facial_Auth_Req(StandardTestDevice testDeviceType)
{
@@ -696,7 +696,7 @@ public void Facial_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void Fingerprint_Auth_Req(StandardTestDevice testDeviceType)
@@ -796,7 +796,7 @@ public void Fingerprint_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void Bitgt_Auth_Req(StandardTestDevice testDeviceType)
@@ -828,7 +828,7 @@ public void Bitgt_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void SMSigner_Auth_Req(StandardTestDevice testDeviceType)
@@ -890,7 +890,7 @@ public void SMSigner_Auth_Req(StandardTestDevice testDeviceType)
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
public void PCRef_Auth_Req(StandardTestDevice testDeviceType)
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ImportTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ImportTests.cs
index 8fa6b2a1..a16e99e5 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ImportTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ImportTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ImportTests
{
[SkippableTheory(typeof(NotSupportedException), typeof(DeviceNotFoundException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/KeyAgreeTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/KeyAgreeTests.cs
index 79d13a68..7d62c6ba 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/KeyAgreeTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/KeyAgreeTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class KeyAgreeTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ManagementKeyTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ManagementKeyTests.cs
index dcb51432..6e7e5d71 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ManagementKeyTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ManagementKeyTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ManagementKeyTests
{
private readonly byte[] _currentKey;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MgmtKeyNoCollectorTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MgmtKeyNoCollectorTests.cs
index b76a0fca..23247028 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MgmtKeyNoCollectorTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MgmtKeyNoCollectorTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class MgmtKeyNoCollectorTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MoveDeleteKeyTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MoveDeleteKeyTests.cs
index 69c7d154..a2b6f7be 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MoveDeleteKeyTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/MoveDeleteKeyTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class MoveDeleteKeyTests
{
[SkippableTheory(typeof(NotSupportedException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/AdminIntegrationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/AdminIntegrationTests.cs
index b4f33c0c..c6116769 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/AdminIntegrationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/AdminIntegrationTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class AdminIntegrationTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/CccIntegrationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/CccIntegrationTests.cs
index 90b09127..c2b90a0a 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/CccIntegrationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/CccIntegrationTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class CccIntegrationTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/ChangePinTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/ChangePinTests.cs
index 44c35c86..fe04464e 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/ChangePinTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/ChangePinTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class ChangePinTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/HistoryIntegrationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/HistoryIntegrationTests.cs
index dd79db25..90653bc2 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/HistoryIntegrationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/HistoryIntegrationTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class HistoryIntegrationTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/PinProtectedIntegrationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/PinProtectedIntegrationTests.cs
index 289f0e03..f85f8267 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/PinProtectedIntegrationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/PinProtectedIntegrationTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PinProtectedIntegrationTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/TagTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/TagTests.cs
index 3c46688c..76aae2a6 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/TagTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/Objects/TagTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class TagTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinNoCollectorTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinNoCollectorTests.cs
index 38c74c68..62dc8128 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinNoCollectorTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinNoCollectorTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PinNoCollectorTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinOnlyWithResetTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinOnlyWithResetTests.cs
index c644d54e..72fb25f7 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinOnlyWithResetTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PinOnlyWithResetTests.cs
@@ -27,7 +27,7 @@ namespace Yubico.YubiKey.Piv
// set of bytes, followed by 2048 random bytes. If you want to get only
// random bytes, skip the first SpecifiedStart bytes (get a random object and
// generate that many bytes).
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PinOnlyWithResetTests : IDisposable
{
private const int SpecifiedStart = 72;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivObjectTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivObjectTests.cs
index 35ca1814..1315e190 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivObjectTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivObjectTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PivObjectTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionTests.cs
index d6571342..fa2a3811 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionTests.cs
@@ -21,7 +21,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PivSessionTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PssTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PssTests.cs
index 73669176..f98ccdb7 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PssTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PssTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class PssTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/RetryTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/RetryTests.cs
index da97d7d5..043729a4 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/RetryTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/RetryTests.cs
@@ -18,7 +18,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class RetryTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SelectApplicationTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SelectApplicationTests.cs
index 3ca8b495..b7eb0093 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SelectApplicationTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SelectApplicationTests.cs
@@ -19,7 +19,7 @@
namespace Yubico.YubiKey.Piv
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public sealed class SelectApplicationTests
{
[Theory]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SignTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SignTests.cs
index ba10f6be..cded8cb9 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SignTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/SignTests.cs
@@ -62,7 +62,7 @@ public void Sign_EccP256_Succeeds(bool useScp03, StandardTestDevice device, PivP
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(NotSupportedException), typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5, PivAlgorithm.Rsa1024, 0x86)]
[InlineData(StandardTestDevice.Fw5, PivAlgorithm.Rsa2048, 0x87)]
@@ -117,7 +117,7 @@ public void Sign_RandomData_Succeeds(StandardTestDevice testDeviceType, PivAlgor
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(NotSupportedException), typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5Fips, PivAlgorithm.Rsa1024, 0x92, RsaFormat.Sha1, 1)]
[InlineData(StandardTestDevice.Fw5Fips, PivAlgorithm.Rsa1024, 0x92, RsaFormat.Sha256, 1)]
@@ -309,7 +309,7 @@ public void SignEcc_VerifyCSharp_Correct(StandardTestDevice testDeviceType, PivA
}
}
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
[SkippableTheory(typeof(DeviceNotFoundException))]
[InlineData(StandardTestDevice.Fw5)]
[InlineData(StandardTestDevice.Fw5Fips)]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Scp03/Commands/DeleteKeyCommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Scp03/Commands/DeleteKeyCommandTests.cs
index c0e1827b..46b3245a 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Scp03/Commands/DeleteKeyCommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/Scp03/Commands/DeleteKeyCommandTests.cs
@@ -17,7 +17,7 @@
namespace Yubico.YubiKey.Scp03.Commands
{
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public class DeleteKeyCommandTests
{
[SkippableTheory(typeof(DeviceNotFoundException))]
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/CommandTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/CommandTests.cs
index 11f66aa7..fbe5595c 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/CommandTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/CommandTests.cs
@@ -17,6 +17,7 @@
using Xunit;
using Yubico.Core.Devices.Hid;
using Yubico.PlatformInterop;
+using Yubico.YubiKey.TestUtilities;
using Yubico.YubiKey.U2f.Commands;
namespace Yubico.YubiKey.U2f
@@ -56,7 +57,7 @@ public void Dispose()
}
[Fact]
- [Trait("Category", "Simple")]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public void RunGetDeviceInfo()
{
var cmd = new GetPagedDeviceInfoCommand();
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs
index 2f4803d4..fa29536b 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/U2f/PinTests.cs
@@ -18,11 +18,12 @@
using Yubico.Core.Devices.Hid;
using Yubico.Core.Iso7816;
using Yubico.PlatformInterop;
+using Yubico.YubiKey.TestUtilities;
using Yubico.YubiKey.U2f.Commands;
namespace Yubico.YubiKey.U2f
{
- [Trait("Category", "Elevated")]
+ [Trait(TraitTypes.Category, TestCategories.Elevated)]
public class PinTests : IDisposable
{
private readonly FidoConnection _fidoConnection;
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/SessionGetAes128SessionKeysTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/SessionGetAes128SessionKeysTests.cs
index 174fa656..897b41b5 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/SessionGetAes128SessionKeysTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/SessionGetAes128SessionKeysTests.cs
@@ -15,15 +15,18 @@
using System;
using System.Security;
using Xunit;
+using Yubico.YubiKey.TestUtilities;
+
namespace Yubico.YubiKey.YubiHsmAuth
{
public class SessionGetAes128SessionKeysTests
{
#region NonKeyCollector
+
#region password
- [Fact]
- [Trait("Category", "FirmwareOrHardwareMissmatch")]
+ [SkippableFact(typeof(DeviceNotFoundException))]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public void GetAes128SessionKeys_TouchNotRequired_ReturnsTrueAndSessionKeys()
{
// Preconditions
@@ -48,8 +51,8 @@ public void GetAes128SessionKeys_TouchNotRequired_ReturnsTrueAndSessionKeys()
Assert.NotNull(keys);
}
- [Fact]
- [Trait("Category", "Flaky")]
+ [SkippableFact(typeof(DeviceNotFoundException))]
+ [Trait(TraitTypes.Category, TestCategories.Simple)]
public void GetAes128SessionKeys_WrongCredPassword_ThrowsSecurityException()
{
// Preconditions
@@ -68,15 +71,17 @@ void getSessionKeys() => yubiHsmAuthSession.GetAes128SessionKeys(
_ = Assert.Throws(getSessionKeys);
}
}
+
#endregion
#region touch
+
// When touch is required, the user should touch the YubiKey.
//
// It's recommended to use a debug break point in either the
// key collector or GetAes128SessionKeys(...) so that you're
// aware of when touch is about to be expected.
- [Trait("Category", "RequiresStepDebug")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresTouch)]
[Fact(Skip = "Requires user interaction")]
public void GetAes128SessionKeys_TouchRequired_ReturnsSessionKeys()
{
@@ -123,6 +128,7 @@ void getSessionKeys() => yubiHsmAuthSession.GetAes128SessionKeys(
_ = Assert.Throws(getSessionKeys);
}
}
+
#endregion
[Fact]
@@ -147,10 +153,13 @@ void getSessionKeys() => yubiHsmAuthSession.GetAes128SessionKeys(
_ = Assert.Throws(getSessionKeys);
}
}
+
#endregion
#region KeyCollector
+
#region password
+
[Fact]
public void TryGetAes128SessionKeys_TouchNotRequired_ReturnsTrueAndSessionKeys()
{
@@ -267,9 +276,11 @@ void tryGetSessionKeys() => yubiHsmAuthSession.TryGetAes128SessionKeys(
_ = Assert.Throws(tryGetSessionKeys);
}
}
+
#endregion
#region touch
+
// When touch is requested, the user should touch the YubiKey.
//
// It's recommended to use a debug break point in either the
@@ -326,6 +337,7 @@ void tryGetSessionKeys() => yubiHsmAuthSession.TryGetAes128SessionKeys(
_ = Assert.Throws(tryGetSessionKeys);
}
}
+
#endregion
[Fact]
@@ -372,6 +384,7 @@ void tryGetSessionKeys() => yubiHsmAuthSession.TryGetAes128SessionKeys(
_ = Assert.Throws(tryGetSessionKeys);
}
}
+
#endregion KeyCollector
}
}
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/YhaTestUtilities.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/YhaTestUtilities.cs
index 8c5c63e9..7e5a5190 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/YhaTestUtilities.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiHsmAuth/YhaTestUtilities.cs
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System.Collections.Generic;
-using System.Linq;
using Yubico.YubiKey.TestUtilities;
namespace Yubico.YubiKey.YubiHsmAuth
@@ -25,8 +23,6 @@ namespace Yubico.YubiKey.YubiHsmAuth
///
public class YhaTestUtilities
{
- private static readonly FirmwareVersion MinimumFirmwareVersion = new FirmwareVersion(5, 4, 3);
-
#region default
public static readonly byte[] DefaultMgmtKey =
new byte[16] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -90,27 +86,13 @@ public class YhaTestUtilities
AlternateCredTouchRequired);
///
- /// Finds a device with the minimum firmware version (see ),
- /// and puts the device into a known "control" state for performing integration
- /// tests with the YubiHSM Auth application.
- ///
- public static IYubiKeyDevice GetCleanDevice() => GetCleanDevice(MinimumFirmwareVersion);
-
- ///
- /// Finds a device with the matching FirmwareVersion, and puts the device
+ /// Finds a standard device and puts the device
/// into a known "control" state for performing integration
/// tests with the YubiHSM Auth application.
///
- private static IYubiKeyDevice GetCleanDevice(FirmwareVersion fwVersion)
+ public static IYubiKeyDevice GetCleanDevice()
{
- IList? testDevices = IntegrationTestDeviceEnumeration.GetTestDevices();
- IYubiKeyDevice testDevice = testDevices
- .First(d =>
- d.FirmwareVersion >= fwVersion &&
- d.SerialNumber.HasValue);
-
- testDevice = DeviceReset.EnableAllCapabilities(testDevice);
-
+ var testDevice = DeviceReset.EnableAllCapabilities(IntegrationTestDeviceEnumeration.GetTestDevice());
return DeviceReset.ResetYubiHsmAuth(testDevice);
}
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyDeviceTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyDeviceTests.cs
index 5cff415e..3022a58d 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyDeviceTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyDeviceTests.cs
@@ -20,7 +20,7 @@
namespace Yubico.YubiKey
{
- [Trait("Category", "RequiresStepDebug")] // Timing issues, may need to step with debugger
+ [Trait(TraitTypes.Category, TestCategories.RequiresStepDebug)] // Timing issues, may need to step with debugger
public class YubiKeyDeviceTests
{
private static readonly byte[] LockCodeAllZero = new byte[16];
diff --git a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyTests.cs b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyTests.cs
index 83bd947e..e73a7d54 100644
--- a/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyTests.cs
+++ b/Yubico.YubiKey/tests/integration/Yubico/YubiKey/YubiKeyTests.cs
@@ -18,10 +18,11 @@
using System.Linq;
using Xunit;
using Xunit.Abstractions;
+using Yubico.YubiKey.TestUtilities;
namespace Yubico.YubiKey
{
- [Trait("Category", "RequiresSetup")]
+ [Trait(TraitTypes.Category, TestCategories.RequiresSetup)]
public class YubiKeyTests
{
private readonly ITestOutputHelper _testOutputHelper;
diff --git a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/Fido2ResetForTest.cs b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/Fido2ResetForTest.cs
index 369d25d4..a18eedf0 100644
--- a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/Fido2ResetForTest.cs
+++ b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/Fido2ResetForTest.cs
@@ -335,6 +335,11 @@ public static bool ResetKeyCollector(KeyEntryData keyEntryData, ReadOnlyMemory
+ /// Requires you to remove and reinsert the Yubikey, read the console log for timely instructions
+ ///
+ ///
+ ///
public static bool DoReset(int? serialNum)
{
var fido2Reset = new Fido2ResetForTest(serialNum);
diff --git a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/IntegrationTestDeviceEnumeration.cs b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/IntegrationTestDeviceEnumeration.cs
index 1f9debe7..588283a9 100644
--- a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/IntegrationTestDeviceEnumeration.cs
+++ b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/IntegrationTestDeviceEnumeration.cs
@@ -28,7 +28,7 @@ namespace Yubico.YubiKey.TestUtilities
/// Instructions for setting up the allow-list file:
///
/// The user needs to add their Yubikeys serial numbers to the allow-list file which is located at
- /// C:\Users\<username>\AppData\Local\Yubico\YUBIKEY_INTEGRATIONTEST_ALLOWEDKEYS.txt for Windows users
+ /// %LOCALAPPDATA%\Yubico\YUBIKEY_INTEGRATIONTEST_ALLOWEDKEYS.txt for Windows users
/// and /Users/<username>/.local/share/Yubico/YUBIKEY_INTEGRATIONTEST_ALLOWEDKEYS.txt for macOS users.
/// The SDK attempts to create the file if it doesn't already exist.
///
@@ -56,7 +56,7 @@ public IntegrationTestDeviceEnumeration(string? configDirectory = null)
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Yubico");
var allowListFilePath = Path.Combine(configDirectory ?? defaultDirectory, _allowlistFileName);
- CreateIfMissing(allowListFilePath);
+ CreateAllowListFileIfMissing(allowListFilePath);
AllowedSerialNumbers = File.Exists(allowListFilePath)
? new HashSet(File.ReadLines(allowListFilePath))
@@ -65,7 +65,7 @@ public IntegrationTestDeviceEnumeration(string? configDirectory = null)
var allowedKeys = Environment.GetEnvironmentVariable(YubikeyIntegrationtestAllowedKeysName)
?.Split(':') ?? Array.Empty();
- foreach (string allowedKey in allowedKeys)
+ foreach (var allowedKey in allowedKeys)
{
_ = AllowedSerialNumbers.Add(allowedKey);
}
@@ -84,18 +84,13 @@ public IntegrationTestDeviceEnumeration(string? configDirectory = null)
string.Join(",", AllowedSerialNumbers));
}
- private static void CreateIfMissing(string allowListFilePath)
- {
- if (File.Exists(allowListFilePath))
- {
- return;
- }
-
- _ = Directory.CreateDirectory(Path.GetDirectoryName(allowListFilePath)!);
-
- var file = File.Create(allowListFilePath);
- file.Close();
- }
+ ///
+ /// Gets a Yubikey device by its serial number
+ ///
+ ///
+ ///
+ public static IYubiKeyDevice GetBySerial(int serialNumber)
+ => GetTestDevices().Single(d => d.SerialNumber == serialNumber);
///
/// Enumerates all YubiKey test devices on a system.
@@ -105,7 +100,8 @@ public static IList GetTestDevices(Transport transport = Transpo
{
return YubiKeyDevice
.FindByTransport(transport)
- .Where(IsAllowedKey).ToList();
+ .Where(IsAllowedKey)
+ .ToList();
static bool IsAllowedKey(IYubiKeyDevice key)
=> key.SerialNumber == null ||
@@ -116,26 +112,13 @@ static bool IsAllowedKey(IYubiKeyDevice key)
/// Get YubiKey test device of specified type available on a system.
///
/// The type of the device.
- /// A boolean indicating if the caller
- /// wants to require finding YubiKeys with serial numbers only. If
- /// true the method will only examine YubiKeys have a visible
- /// serial number. This is the default, if no requireSerialNumber
- /// arg is given, then this method will require serial numbers. If
- /// false, the method will examine all YubiKeys, whether the
- /// serial number is visible or not.
+ /// The transport the device must support.
/// The allow-list filtered YubiKey that was found.
public static IYubiKeyDevice GetTestDevice(
- StandardTestDevice testDeviceType,
- bool requireSerialNumber = true)
- {
- var devices = GetTestDevices();
- if (requireSerialNumber)
- {
- devices = devices.Where(d => d.SerialNumber.HasValue).ToList();
- }
-
- return devices.SelectRequiredTestDevice(testDeviceType);
- }
+ StandardTestDevice testDeviceType = StandardTestDevice.Fw5,
+ Transport transport = Transport.All)
+ => GetTestDevices(transport)
+ .SelectByStandardTestDevice(testDeviceType);
///
/// Get YubiKey test device of specified transport and for which the
@@ -146,17 +129,21 @@ public static IYubiKeyDevice GetTestDevice(
/// caller is willing to accept.
/// The allow-list filtered YubiKey that was found.
public static IYubiKeyDevice GetTestDevice(Transport transport, FirmwareVersion minimumFirmwareVersion)
+ => GetTestDevices(transport)
+ .SelectByMinimumVersion(minimumFirmwareVersion);
+
+
+ private static void CreateAllowListFileIfMissing(string allowListFilePath)
{
- IList deviceList = GetTestDevices(transport);
- foreach (IYubiKeyDevice currentDevice in deviceList)
+ if (File.Exists(allowListFilePath))
{
- if (currentDevice.FirmwareVersion >= minimumFirmwareVersion)
- {
- return currentDevice;
- }
+ return;
}
- throw new InvalidOperationException("No matching YubiKey found.");
+ _ = Directory.CreateDirectory(Path.GetDirectoryName(allowListFilePath)!);
+
+ var file = File.Create(allowListFilePath);
+ file.Close();
}
}
}
diff --git a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs
new file mode 100644
index 00000000..9bcd2542
--- /dev/null
+++ b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestCategories.cs
@@ -0,0 +1,56 @@
+// Copyright 2024 Yubico AB
+//
+// Licensed under the Apache License, Version 2.0 (the "License").
+// You may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Yubico.YubiKey.TestUtilities
+{
+ public class TestCategories
+ {
+ ///
+ /// When touch is required, the user should touch the YubiKey.
+ /// It's recommended to use a debug break point at the code where touch is required, so that you're
+ /// 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
+ ///
+ public const string Elevated = "Elevated";
+
+ public const string FirmwareOrHardwareMismatch = "FirmwareOrHardwareMismatch";
+
+ ///
+ /// These tests require a Yubikey with biometric capabilities
+ ///
+ public const string RequiresBio = "RequiresBio";
+
+ ///
+ /// These tests require certain setup on the Yubikey in order to succeed.
+ ///
+ public const string RequiresSetup = "RequiresSetup";
+
+ ///
+ /// These tests may require step debugging to avoid timing issues
+ ///
+ public const string RequiresStepDebug = "RequiresStepDebug";
+ }
+
+ public class TraitTypes
+ {
+ public const string Category = "Category";
+ }
+}
diff --git a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestDeviceSelection.cs b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestDeviceSelection.cs
index a3a4a0ad..ea0bf63c 100644
--- a/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestDeviceSelection.cs
+++ b/Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestDeviceSelection.cs
@@ -39,9 +39,7 @@ public static IYubiKeyDevice RenewDeviceEnumeration(int serialNumber)
try
{
- return TestDev
- .GetTestDevices()
- .Single(d => d.SerialNumber == serialNumber);
+ return TestDev.GetBySerial(serialNumber);
}
catch (InvalidOperationException)
{
@@ -61,12 +59,12 @@ public static IYubiKeyDevice RenewDeviceEnumeration(int serialNumber)
///
/// Thrown when the input sequence did not contain a valid test device.
///
- public static IYubiKeyDevice SelectRequiredTestDevice(
+ public static IYubiKeyDevice SelectByStandardTestDevice(
this IEnumerable yubiKeys,
StandardTestDevice testDevice)
{
- IEnumerable yubiKeyDevices = yubiKeys as IYubiKeyDevice[] ?? yubiKeys.ToArray();
- if (!yubiKeyDevices.Any())
+ var devices = yubiKeys as IYubiKeyDevice[] ?? yubiKeys.ToArray();
+ if (!devices.Any())
{
throw new InvalidOperationException("Could not find any connected Yubikeys");
}
@@ -75,7 +73,7 @@ public static IYubiKeyDevice SelectRequiredTestDevice(
{
StandardTestDevice.Fw3 => SelectDevice(3),
StandardTestDevice.Fw4Fips => SelectDevice(4, isFipsSeries: true),
- StandardTestDevice.Fw5 => SelectDevice(5, formFactor: null),
+ StandardTestDevice.Fw5 => SelectDevice(5),
StandardTestDevice.Fw5Fips => SelectDevice(5, formFactor: FormFactor.UsbAKeychain, isFipsSeries: true),
StandardTestDevice.Fw5Bio => SelectDevice(5, formFactor: FormFactor.UsbABiometricKeychain),
_ => throw new ArgumentException("Invalid test device value.", nameof(testDevice)),
@@ -83,24 +81,59 @@ public static IYubiKeyDevice SelectRequiredTestDevice(
IYubiKeyDevice SelectDevice(int majorVersion, FormFactor? formFactor = null, bool isFipsSeries = false)
{
+ IYubiKeyDevice device = null!;
try
{
- return yubiKeyDevices.First(d =>
- d.FirmwareVersion.Major == majorVersion &&
- (formFactor is null || d.FormFactor == formFactor) &&
- d.IsFipsSeries == isFipsSeries);
+ bool MatchingDeviceSelector(IYubiKeyDevice d) =>
+ d.FirmwareVersion.Major == majorVersion &&
+ (formFactor is null || d.FormFactor == formFactor) &&
+ d.IsFipsSeries == isFipsSeries;
+
+ device = devices.First(MatchingDeviceSelector);
}
catch (InvalidOperationException)
{
- string connectedDevices = yubiKeyDevices.Any()
- ? "Connected devices: " + string.Join(", ",
- yubiKeyDevices.Select(y => $"{{{y.FirmwareVersion}, {y.FormFactor}}}"))
- : string.Empty;
- throw new DeviceNotFoundException(
- $"Target test device not found ({testDevice}). ({connectedDevices})");
+ ThrowDeviceNotFoundException($"Target test device not found ({testDevice})", devices);
}
+
+ return device;
+ }
+ }
+
+ public static IYubiKeyDevice SelectByMinimumVersion(
+ this IEnumerable yubiKeys,
+ FirmwareVersion minimumFirmwareVersion)
+ {
+ var devices = yubiKeys as IYubiKeyDevice[] ?? yubiKeys.ToArray();
+ if (!devices.Any())
+ {
+ throw new InvalidOperationException("Could not find any connected Yubikeys");
+ }
+
+ var device = devices.FirstOrDefault(d => d.FirmwareVersion >= minimumFirmwareVersion);
+ if (device is null)
+ {
+ ThrowDeviceNotFoundException("No matching YubiKey found", devices);
}
+
+ return device!;
}
+
+ private static void ThrowDeviceNotFoundException(string errorMessage,IYubiKeyDevice[] devices)
+ {
+ var connectedDevicesText = FormatConnectedDevices(devices);
+ throw new DeviceNotFoundException($"{errorMessage}. {connectedDevicesText}");
+ }
+
+ private static string FormatConnectedDevices(IReadOnlyCollection devices)
+ {
+ var deviceText =
+ devices.Select(y => $"{{{y.FirmwareVersion}, {y.FormFactor}, IsFipsSeries: {y.IsFipsSeries}}}");
+
+ return devices.Any()
+ ? $"Connected devices: {string.Join(", ", deviceText)}"
+ : string.Empty;
+ }
}
// Custom test exception inheriting from InvalidOperationException as some test code depends on InvalidOperationExceptions