Skip to content

Commit

Permalink
Merge pull request #639 from Yubico/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade dependencies and make necessary updates.
  • Loading branch information
Greg Domzalski authored Nov 10, 2023
2 parents 56f2389 + 9878e28 commit 29b68ad
Show file tree
Hide file tree
Showing 27 changed files with 66 additions and 109 deletions.
4 changes: 2 additions & 2 deletions Yubico.Core/src/Yubico.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ limitations under the License. -->


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageReference Include="Yubico.NativeShims" Version="1.*-*" />
<ProjectReference Include="..\..\Yubico.DotNetPolyfills\src\Yubico.DotNetPolyfills.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Yubico.Core/src/Yubico/Core/Devices/Hid/MacOSHidDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MacOSHidDevice(long entryId) :
public static IEnumerable<HidDevice> GetList()
{
Logger log = Log.GetLogger();
using IDisposable logScope = log.BeginScope("MacOSHidDevice.GetList()");
using IDisposable? logScope = log.BeginScope("MacOSHidDevice.GetList()");

IntPtr manager = IntPtr.Zero;
IntPtr deviceSet = IntPtr.Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void StopListening()
private void ListeningThread()
{
const int runLoopTimeout = 10; // 10 seconds is arbitrary, pulled from Apple sample code
using IDisposable logScope = _log.BeginScope("MacOSHidDeviceListener.StartListening()");
using IDisposable? logScope = _log.BeginScope("MacOSHidDeviceListener.StartListening()");

_log.LogInformation("HID listener thread started. ThreadID is {ThreadID}.", Environment.CurrentManagedThreadId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private class TransactionScope : IDisposable
{
private readonly Logger _log = Log.GetLogger();
private readonly DesktopSmartCardConnection _thisConnection;
private readonly IDisposable _logScope;
private readonly IDisposable? _logScope;
private bool _disposedValue;

public TransactionScope(DesktopSmartCardConnection thisConnection)
Expand All @@ -58,7 +58,7 @@ protected virtual void Dispose(bool disposing)

if (disposing)
{
_logScope.Dispose();
_logScope?.Dispose();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal class DesktopSmartCardDevice : SmartCardDevice
public static IReadOnlyList<ISmartCardDevice> GetList()
{
Logger log = Log.GetLogger();
using IDisposable logScope = log.BeginScope("SmartCardDevice.GetList()");
using IDisposable? logScope = log.BeginScope("SmartCardDevice.GetList()");

uint result = SCardEstablishContext(SCARD_SCOPE.USER, out SCardContext context);
log.SCardApiCall(nameof(SCardEstablishContext), result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Yubico.Core.Devices.SmartCard
{
internal static class SmartCardLoggerExtensions
{
public static IDisposable BeginTransactionScope(this Logger logger, IDisposable transactionScope) =>
public static IDisposable? BeginTransactionScope(this Logger logger, IDisposable transactionScope) =>
logger.BeginScope("Transaction[{TransactionID}]", transactionScope.GetHashCode());

public static void SCardApiCall(this Logger logger, string apiName, uint result)
Expand Down
2 changes: 1 addition & 1 deletion Yubico.Core/src/Yubico/Core/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ public void Log<TState>(
/// <returns>
/// A disposable object that ends the logical operation scope on dispose.
/// </returns>
public IDisposable BeginScope<TState>(TState state) => _logger.BeginScope(state);
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => _logger.BeginScope(state);
}
}
2 changes: 1 addition & 1 deletion Yubico.Core/src/Yubico/Core/Logging/LoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ public static void SensitiveLog(this Logger logger, LogLevel logLevel, EventId e
/// {
/// }
/// </example>
public static IDisposable BeginScope(
public static IDisposable? BeginScope(
this Logger logger,
string messageFormat,
params object?[] args) =>
Expand Down
5 changes: 5 additions & 0 deletions Yubico.Core/tests/Yubico.Core.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ limitations under the License. -->
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\src\Yubico.Core.csproj" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.16.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void GetChar_GivenHidCode_ReturnsCorrectChar(KeyboardLayout layout, (char
}
#endif

private static IEnumerable<object> GetTestData()
public static IEnumerable<object[]> GetTestData()
{
// Originally, I hard-coded these, but I decided that it should do
// this dynamically so that newly added keyboard layouts aren't left
Expand Down
4 changes: 2 additions & 2 deletions Yubico.Core/tests/Yubico/Core/Iso7816/ResponseApduTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void SW1_GivenResponseApdu_MatchesUpperByteOfSW()

var responseApdu = new ResponseApdu(new byte[] { SW1, SW2 });

Assert.Equal(responseApdu.SW >> 8, SW1);
Assert.Equal(SW1, responseApdu.SW >> 8);
}

[Fact]
Expand All @@ -68,7 +68,7 @@ public void SW2_GivenResponseApdu_MatchesLowerByteOfSW()

var responseApdu = new ResponseApdu(new byte[] { SW1, SW2 });

Assert.Equal(responseApdu.SW & 0xFF, SW2);
Assert.Equal(SW2, responseApdu.SW & 0xFF);
}

[Fact]
Expand Down
6 changes: 1 addition & 5 deletions Yubico.DotNetPolyfills/src/Yubico.DotNetPolyfills.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,14 @@ limitations under the License. -->
</None>
</ItemGroup>

<Target Name="CopyPackage" AfterTargets="Pack">
<Copy SourceFiles="$(PackageOutputPath)$(PackageId).$(PackageVersion).nupkg" DestinationFolder="$(MSBuildProjectDirectory)\..\..\build\latestpackages" />
</Target>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">

<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Memory" Version="4.5.5" />

</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion Yubico.NET.SDK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{778EE2C1
build\CompilerSettings.props = build\CompilerSettings.props
build\Directory.Build.props = build\Directory.Build.props
build\Directory.Build.targets = build\Directory.Build.targets
build\PackageReferences.props = build\PackageReferences.props
build\ProjectTypes.props = build\ProjectTypes.props
build\Versions.props = build\Versions.props
EndProjectSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ limitations under the License. -->
<ProjectReference Include="..\..\src\Yubico.YubiKey.csproj" />
<ProjectReference Include="..\unit\Yubico.YubiKey.UnitTests.csproj" />
<ProjectReference Include="..\utilities\Yubico.YubiKey.TestUtilities.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.16.1" />

<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void EnrollFingerprint_Succeeds()
TemplateInfo templateInfo = fido2Session.EnrollFingerprint(firstName, 5000);

Assert.NotNull(templateInfo.FriendlyName);
Assert.True(templateInfo.FriendlyName.Equals(firstName, StringComparison.Ordinal));
Assert.Equal(firstName, templateInfo.FriendlyName);
Assert.NotEmpty(templateInfo.TemplateId.ToArray());

fido2Session.SetBioTemplateFriendlyName(templateInfo.TemplateId, secondName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void EnumerateEnrollmentsCommand_Succeeds()
Assert.Equal(ResponseStatus.Success, rsp.Status);

IReadOnlyList<TemplateInfo> templateInfos = rsp.GetData();
Assert.Equal(1, templateInfos.Count);
_ = Assert.Single(templateInfos);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void UpdateUserInfo_Succeeds()

IReadOnlyList<CredentialUserInfo> credList =
fido2Session.EnumerateCredentialsForRelyingParty(_bioFido2Fixture.RpInfoList[0].RelyingParty);
Assert.NotEqual(0, credList.Count);
Assert.NotEmpty(credList);

fido2Session.ClearAuthToken();
fido2Session.AddPermissions(PinUvAuthTokenPermissions.AuthenticatorConfiguration, null);
Expand All @@ -144,7 +144,7 @@ public void UpdateUserInfo_Succeeds()
credList = fido2Session.EnumerateCredentialsForRelyingParty(_bioFido2Fixture.RpInfoList[0].RelyingParty);

string displayName = credList[0].User.DisplayName??"";
Assert.True(displayName.Equals(updatedDisplayName));
Assert.Equal(updatedDisplayName, displayName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void MakeCredential_NonDiscoverable_GetAssertion_Succeeds()

IReadOnlyList<GetAssertionData> assertions = fido2.GetAssertions(gaParams);

Assert.Equal(1, assertions.Count);
Assert.Equal(1, assertions[0].NumberOfCredentials);
GetAssertionData assertion = Assert.Single(assertions);
Assert.Equal(1, assertion.NumberOfCredentials);
}
}

Expand Down Expand Up @@ -103,7 +103,7 @@ public void MakeCredential_NoName_GetAssertion_Succeeds()

IReadOnlyList<GetAssertionData> assertions = fido2.GetAssertions(gaParams);

Assert.Equal(1, assertions.Count);
_ = Assert.Single(assertions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void SetPassword_Succeeds()
Assert.False(oathSession.IsPasswordProtected);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

Credential cred = credentialList[0];
Assert.NotNull(cred.Algorithm);
_ = Assert.NotNull(cred.Algorithm);
if (!(cred.Algorithm is null))
{
Assert.Equal(HashAlgorithm.Sha256, cred.Algorithm);
Expand All @@ -65,7 +65,7 @@ public void SetPassword_Succeeds()
Assert.True(oathSession.IsPasswordProtected);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);
}

using (var oathSession = new OathSession(yubiKeyDevice))
Expand All @@ -84,10 +84,10 @@ public void SetPassword_Succeeds()
Assert.True(isVerified);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

Credential cred = credentialList[0];
Assert.NotNull(cred.Algorithm);
_ = Assert.NotNull(cred.Algorithm);
if (!(cred.Algorithm is null))
{
Assert.Equal(HashAlgorithm.Sha256, cred.Algorithm);
Expand Down Expand Up @@ -121,7 +121,7 @@ public void SetPassword_Succeeds()
Assert.False(isSet);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);
}

using (var oathSession = new OathSession(yubiKeyDevice))
Expand All @@ -138,7 +138,7 @@ public void SetPassword_Succeeds()
Assert.False(isSet);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

oathSession.ResetApplication();
}
Expand Down Expand Up @@ -184,16 +184,16 @@ public void UnsetPassword_Succeeds()
Assert.False(oathSession.IsPasswordProtected);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);
}

using (var oathSession = new OathSession(yubiKeyDevice))
{
IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

Credential cred = credentialList[0];
Assert.NotNull(cred.Algorithm);
_ = Assert.NotNull(cred.Algorithm);
if (!(cred.Algorithm is null))
{
Assert.Equal(HashAlgorithm.Sha256, cred.Algorithm);
Expand Down Expand Up @@ -295,16 +295,16 @@ public void VerifyPassword_UnsetNoCurrent_Succeeds()
Assert.False(oathSession.IsPasswordProtected);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);
}

using (var oathSession = new OathSession(yubiKeyDevice))
{
IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

Credential cred = credentialList[0];
Assert.NotNull(cred.Algorithm);
_ = Assert.NotNull(cred.Algorithm);
if (!(cred.Algorithm is null))
{
Assert.Equal(HashAlgorithm.Sha256, cred.Algorithm);
Expand Down Expand Up @@ -340,7 +340,7 @@ public void PasswordNotSet_Verify_ReturnsFalse()
Assert.False(oathSession.IsPasswordProtected);

IList<Credential> credentialList = oathSession.GetCredentials();
Assert.Equal(1, credentialList.Count);
_ = Assert.Single(credentialList);

oathSession.ResetApplication();
}
Expand Down
10 changes: 5 additions & 5 deletions Yubico.YubiKey/tests/sandbox/Yubico.YubiKey.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ limitations under the License. -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
</ItemGroup>

Expand Down
5 changes: 5 additions & 0 deletions Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ limitations under the License. -->
<ItemGroup>
<ProjectReference Include="..\..\src\Yubico.YubiKey.csproj" />
<ProjectReference Include="..\utilities\Yubico.YubiKey.TestUtilities.csproj" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.16.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SuccessResponseApdu_NoCredential_ListCredentialsCorrectly()
const byte sw2 = unchecked((byte)SWConstants.Success);

var responseApdu = new ResponseApdu(new byte[] { sw1, sw2 });

var calculateCredentialResponse = new CalculateCredentialResponse(responseApdu, credential);

Assert.Equal(SWConstants.Success, calculateCredentialResponse.StatusWord);
Expand Down Expand Up @@ -80,6 +80,7 @@ public void Constructor_SuccessResponseApdu_FullResponse_ReturnResponseCorrectly
var data = calculateCredentialResponse.GetData();

Assert.Equal(SWConstants.Success, calculateCredentialResponse.StatusWord);
Assert.NotNull(data.Value);
Assert.NotEmpty(data.Value);
}

Expand All @@ -98,6 +99,7 @@ public void Constructor_SuccessResponseApdu_TruncatedResponse_ReturnResponseCorr
var data = calculateCredentialResponse.GetData();

Assert.Equal(SWConstants.Success, calculateCredentialResponse.StatusWord);
Assert.NotNull(data.Value);
Assert.NotEmpty(data.Value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void CreateCommandApdu_GetNcProperty_ReturnsCorrectLength()
var command = new ResetCommand();
CommandApdu commandApdu = command.CreateCommandApdu();

Assert.Equal(commandApdu.Nc, lengthHeader);
Assert.Equal(lengthHeader, commandApdu.Nc);
}

[Fact]
Expand Down
Loading

0 comments on commit 29b68ad

Please sign in to comment.