Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 2.25 KB

testing.md

File metadata and controls

63 lines (45 loc) · 2.25 KB

Testing

Unit Tests

Project: Yubico.YubiKey.UnitTests

Integration Tests

Project: Yubico.YubiKey.IntegrationTests

Standard Test Devices

To make integration testing easier across the team, we have standardized the set of YubiKeys used in integration testing. These devices are enumerated in Yubico.YubiKey.TestUtilities.StandardTestDevice. As of April 26, 2021, these test devices are:

  • Fw3
    • Major version 3, USB A keychain, not FIPS
  • Fw4Fips
    • Major version 4, USB A keychain, FIPS
  • Fw5
    • Major version 5, USB A keychain, not FIPS
  • Fw5Fips
    • Major version 5, USB A keychain, FIPS
  • Fw5ci
    • Major version 5, USB C Lightning, not FIPS

Selecting Test Devices

The set of all available test devices can be retrieved using Yubico.YubiKey.TestUtilities.IntegrationTestDeviceEnumeration

To run a test against a specific test device, you can use Yubico.YubiKey.TestUtilities.TestDeviceSelection For example, SelectRequiredTestDevice(StandardTestDevice) will find the first valid device in a set of IYubiKey objects. If it cannot find a valid device, it throws an exception.

[Theory]
[InlineData(StandardTestDevice.Fw5)]
[InlineData(StandardTestDevice.Fw5Fips)]
public void SetDeviceInfo_NoData_ResponseStatusSuccess(StandardTestDevice testDeviceType)
{
    IYubiKey testDevice =
        IntegrationTestDeviceEnumeration.GetTestDevices()
        .SelectRequiredTestDevice(testDeviceType);

    using IYubiKeyConnection connection = testDevice.Connect(YubiKeyApplication.Management);

    var setCommand = new SetDeviceInfoCommand();

    YubiKeyResponse setDeviceInfoResponse = connection.SendCommand(setCommand);
    Assert.Equal(ResponseStatus.Success, setDeviceInfoResponse.Status);
}