Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit b4fc66feb6
3353 changed files with 88254 additions and 1590657 deletions

View File

@@ -10,6 +10,7 @@ using StellaOps.Cryptography;
using StellaOps.Cryptography.Plugin.SmSoft;
using Xunit;
using StellaOps.TestKit;
namespace StellaOps.Cryptography.Plugin.SmSoft.Tests;
/// <summary>
@@ -38,13 +39,15 @@ public class Sm2ComplianceTests
?? throw new InvalidOperationException("Failed to resolve SmSoftCryptoProvider");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Provider_Name_IsCnSmSoft()
{
Assert.Equal("cn.sm.soft", _provider.Name);
}
[Theory]
[Trait("Category", TestCategories.Unit)]
[Theory]
[InlineData(CryptoCapability.Signing, "SM2", true)]
[InlineData(CryptoCapability.Verification, "SM2", true)]
[InlineData(CryptoCapability.ContentHashing, "SM3", true)]
@@ -56,13 +59,15 @@ public class Sm2ComplianceTests
Assert.Equal(expected, result);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetPasswordHasher_ThrowsNotSupported()
{
Assert.Throws<NotSupportedException>(() => _provider.GetPasswordHasher("PBKDF2"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetHasher_WithSm3_ReturnsSm3Hasher()
{
var hasher = _provider.GetHasher("SM3");
@@ -70,13 +75,15 @@ public class Sm2ComplianceTests
Assert.Equal("SM3", hasher.AlgorithmId);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void GetHasher_WithInvalidAlgorithm_Throws()
{
Assert.Throws<InvalidOperationException>(() => _provider.GetHasher("SHA256"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Sm3_ComputeHash_EmptyInput_ReturnsCorrectHash()
{
// OSCCA GM/T 0004-2012 test vector for empty string
@@ -88,7 +95,8 @@ public class Sm2ComplianceTests
Assert.Equal("1ab21d8355cfa17f8e61194831e81a8f22bec8c728fefb747ed035eb5082aa2b", hash);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Sm3_ComputeHash_AbcInput_ReturnsCorrectHash()
{
// OSCCA GM/T 0004-2012 test vector for "abc"
@@ -100,7 +108,8 @@ public class Sm2ComplianceTests
Assert.Equal("66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0", hash);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Sm3_ComputeHash_LongInput_ReturnsCorrectHash()
{
// OSCCA GM/T 0004-2012 test vector for 64-byte string
@@ -113,7 +122,8 @@ public class Sm2ComplianceTests
Assert.Equal("debe9ff92275b8a138604889c18e5a4d6fdb70e5387e5765293dcba39c0c5732", hash);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task Sm2_SignAndVerify_WithTestKey_Succeeds()
{
// Note: This test uses the existing BouncyCastle SM2 implementation
@@ -157,7 +167,8 @@ public class Sm2ComplianceTests
Assert.False(isInvalid);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Sm2_ExportPublicJsonWebKey_ReturnsValidJwk()
{
var keyPair = GenerateTestSm2KeyPair();

View File

@@ -28,6 +28,7 @@
<ItemGroup>
<ProjectReference Include="..\StellaOps.Cryptography.Plugin.SmSoft\StellaOps.Cryptography.Plugin.SmSoft.csproj" />
<ProjectReference Include="..\StellaOps.Cryptography\StellaOps.Cryptography.csproj" />
<ProjectReference Include="../StellaOps.TestKit/StellaOps.TestKit.csproj" />
</ItemGroup>
</Project>