Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -15,14 +15,16 @@ public class OfflineVerificationProviderTests
|
||||
_provider = new OfflineVerificationCryptoProvider();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Name_ReturnsCorrectValue()
|
||||
{
|
||||
// Assert
|
||||
_provider.Name.Should().Be("offline-verification");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData(CryptoCapability.Signing, "ES256", true)]
|
||||
[InlineData(CryptoCapability.Signing, "ES384", true)]
|
||||
[InlineData(CryptoCapability.Signing, "ES512", true)]
|
||||
@@ -52,7 +54,8 @@ public class OfflineVerificationProviderTests
|
||||
result.Should().Be(expected);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("SHA-256", "hello world", "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9")]
|
||||
[InlineData("SHA-384", "hello world", "fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd")]
|
||||
[InlineData("SHA-512", "hello world", "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f")]
|
||||
@@ -71,7 +74,8 @@ public class OfflineVerificationProviderTests
|
||||
actualHex.Should().Be(expectedHex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void GetHasher_WithUnsupportedAlgorithm_ThrowsNotSupportedException()
|
||||
{
|
||||
// Act
|
||||
@@ -82,7 +86,8 @@ public class OfflineVerificationProviderTests
|
||||
.WithMessage("*MD5*");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void GetPasswordHasher_ThrowsNotSupportedException()
|
||||
{
|
||||
// Act
|
||||
@@ -93,7 +98,8 @@ public class OfflineVerificationProviderTests
|
||||
.WithMessage("*Password hashing*");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("ES256")]
|
||||
[InlineData("ES384")]
|
||||
[InlineData("ES512")]
|
||||
@@ -132,7 +138,8 @@ public class OfflineVerificationProviderTests
|
||||
isValid.Should().BeTrue("ephemeral verifier should verify signature from original key");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreateEphemeralVerifier_ForRsaPkcs1_VerifiesSignatureCorrectly()
|
||||
{
|
||||
// Arrange - Create a real RSA key, sign a message
|
||||
@@ -151,7 +158,8 @@ public class OfflineVerificationProviderTests
|
||||
isValid.Should().BeTrue("ephemeral RSA verifier should verify PKCS1 signature from original key");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreateEphemeralVerifier_ForRsaPss_VerifiesSignatureCorrectly()
|
||||
{
|
||||
// Arrange - Create a real RSA key, sign a message
|
||||
@@ -170,7 +178,8 @@ public class OfflineVerificationProviderTests
|
||||
isValid.Should().BeTrue("ephemeral RSA verifier should verify PSS signature from original key");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("ES256")]
|
||||
[InlineData("PS256")]
|
||||
public void EphemeralVerifier_SignAsync_ThrowsNotSupportedException(string algorithmId)
|
||||
@@ -199,7 +208,8 @@ public class OfflineVerificationProviderTests
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("ES256")]
|
||||
[InlineData("PS256")]
|
||||
public void EphemeralVerifier_WithTamperedMessage_FailsVerification(string algorithmId)
|
||||
@@ -233,7 +243,8 @@ public class OfflineVerificationProviderTests
|
||||
isValid.Should().BeFalse("ephemeral verifier should fail with tampered message");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CreateEphemeralVerifier_WithUnsupportedAlgorithm_ThrowsNotSupportedException()
|
||||
{
|
||||
// Arrange - Create a dummy public key
|
||||
@@ -248,7 +259,8 @@ public class OfflineVerificationProviderTests
|
||||
.WithMessage("*UNSUPPORTED*");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("ES256")]
|
||||
[InlineData("PS256")]
|
||||
public void EphemeralVerifier_HasCorrectProperties(string algorithmId)
|
||||
@@ -258,6 +270,7 @@ public class OfflineVerificationProviderTests
|
||||
using (var ecdsa = ECDsa.Create())
|
||||
{
|
||||
publicKeyBytes = ecdsa.ExportSubjectPublicKeyInfo();
|
||||
using StellaOps.TestKit;
|
||||
}
|
||||
|
||||
// Act
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.Cryptography\StellaOps.Cryptography.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Cryptography.Plugin.OfflineVerification\StellaOps.Cryptography.Plugin.OfflineVerification.csproj" />
|
||||
<ProjectReference Include="../../StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user