Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
8 changes: 5 additions & 3 deletions CoseHandler.Tests/CoseHandler.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -12,6 +13,7 @@
<DelaySign>True</DelaySign>
<Nullable>enable</Nullable>
<AssemblyOriginatorKeyFile>..\StrongNameKeys\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<RootNamespace>CoseSignUnitTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand All @@ -22,10 +24,10 @@
<!-- Package references -->
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.9.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />

</ItemGroup>

<!-- Project refrences-->
Expand Down
15 changes: 6 additions & 9 deletions CoseHandler.Tests/CoseSignValidateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ public class CoseHandlerSignValidateTests
// Certificates and chains as objects
private static readonly X509Certificate2 SelfSignedCert = TestCertificateUtils.CreateCertificate(nameof(CoseHandlerSignValidateTests) + " self signed"); // A self-signed cert
private static readonly X509Certificate2Collection CertChain1 = TestCertificateUtils.CreateTestChain(nameof(CoseHandlerSignValidateTests) + " set 1"); // Two complete cert chains
private static readonly X509Certificate2Collection CertChain2= TestCertificateUtils.CreateTestChain(nameof(CoseHandlerSignValidateTests) + " set 2");
private static readonly X509Certificate2 Root1Priv = CertChain1[0]; // Roots from the chains
private static readonly X509Certificate2 Root2Priv = CertChain2[0];
private static readonly X509Certificate2 Int1Priv = CertChain1[1];
private static readonly X509Certificate2 Leaf1Priv = CertChain1[^1]; // Leaf node certs
private static readonly X509Certificate2 Leaf2Priv = CertChain2[^1];

// As byte arrays
private static readonly byte[] Root1Cer = Root1Priv.Export(X509ContentType.Cert);
Expand Down Expand Up @@ -49,9 +46,9 @@ public CoseHandlerSignValidateTests()
{
// export generated certs to files
File.WriteAllBytes(PrivateKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Pkcs12));
File.WriteAllBytes(PublicKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Cert));
File.WriteAllBytes(PrivateKeyRootCertFile, Root1Priv.Export(X509ContentType.Pkcs12));
File.WriteAllBytes(PublicKeyRootCertFile, Root1Priv.Export(X509ContentType.Cert));
File.WriteAllBytes(PublicKeyCertFileSelfSigned, SelfSignedCert.Export(X509ContentType.Cert));
File.WriteAllBytes(PrivateKeyRootCertFile, Root1Priv.Export(X509ContentType.Pkcs12));
File.WriteAllBytes(PublicKeyRootCertFile, Root1Priv.Export(X509ContentType.Cert));
File.WriteAllBytes(PrivateKeyCertFileChained, Leaf1Priv.Export(X509ContentType.Pkcs12));
}

Expand Down Expand Up @@ -103,7 +100,7 @@ public void PayloadFile_SignatureFile()
{
FileInfo f = new(FileSystemUtils.GeneratePayloadFile());
string signaturePath = f.FullName.Replace("spdx.json", "cose");
FileInfo signatureFile = new (signaturePath);
FileInfo signatureFile = new(signaturePath);
byte[] signedBytes = CoseHandler.Sign(f, Leaf1Priv, false, signatureFile).ToArray();

signedBytes.Should().NotBeNull();
Expand All @@ -116,7 +113,7 @@ public void PayloadFile_SignatureFile()
.Success.Should().Be(true);

// Validate from stream
FileInfo sigFile = new (signaturePath);
FileInfo sigFile = new(signaturePath);
sigFile.Should().NotBeNull();
CoseHandler.Validate(sigFile.GetStreamResilient()!, Payload1Bytes, ValidRootSetPriv, RevMode)
.Success.Should().Be(true);
Expand Down Expand Up @@ -307,7 +304,7 @@ public void DetachedValidationWithoutPayload()
public void SignWithoutPayload()
{
#pragma warning disable CS8600, CS8625 // Converting null literal -- deliberate null convetrsion for test purposes.
_ = CoseHandler.Sign((byte[]) null, Leaf1Priv);
_ = CoseHandler.Sign((byte[])null, Leaf1Priv);
#pragma warning restore CS8600, CS8625 // Converting null literal or possible null value to non-nullable type.
}

Expand Down
3 changes: 2 additions & 1 deletion CoseHandler.Tests/TestsForTheUnderlyingAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace CoseSignUnitTests;

internal class TestsForTheUnderlyingAPI
[TestClass]
public class TestsForTheUnderlyingAPI
{
private readonly byte[] Payload1 = Encoding.ASCII.GetBytes("Payload1!");
private const string SubjectName1 = $"{nameof(TestsForTheUnderlyingAPI)}_Cert1";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -21,12 +22,11 @@

<!-- Package references -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -19,10 +20,10 @@
<!-- Package references -->
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />

<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 3 additions & 3 deletions CoseSign1.Headers.Tests/CoseSign1.Headers.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -18,10 +19,9 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down
7 changes: 4 additions & 3 deletions CoseSign1.Tests/CoseSign1.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -18,12 +19,12 @@

<!-- Package references -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />

<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
7 changes: 4 additions & 3 deletions CoseSignTool.Tests/CoseSignTool.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Platforms>AnyCPU</Platforms>
<!-- must match the platform set from CoseSignTool -->
Expand All @@ -26,9 +27,9 @@
<!-- Package references -->
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.9.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />

</ItemGroup>

<!-- Project references -->
Expand Down
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<EnableNUnitRunner>true</EnableNUnitRunner>
<EnableMSTestRunner>true</EnableMSTestRunner>
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup>
</Project>
Loading