DotNetCore.SKIT.FlurlHttpCl.../test/SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests/TestCase_ResponseVerificationTests.cs

48 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
{
public class TestCase_ResponseVerificationTests
{
[Fact(DisplayName = "测试用例:验证响应签名(基于 RSA")]
public async Task TestVerifyResponseSignatureUseRSA()
{
await TestClients.InitializeCertificateManagerAsync();
var request = new Models.QueryCertificatesRequest() { AlgorithmType = "RSA" };
var response = await TestClients.InstanceUseRSA.ExecuteQueryCertificatesAsync(request);
Assert.True(response.GetRawStatus() == 200);
Assert.True(response.GetRawHeaders().Any());
Assert.True(response.GetRawBytes().Any());
Assert.True(TestClients.InstanceUseRSA.VerifyResponseSignature(response));
Assert.NotNull(response.WechatpayRequestId);
Assert.NotNull(response.WechatpayNonce);
Assert.NotNull(response.WechatpayTimestamp);
Assert.NotNull(response.WechatpaySignature);
Assert.NotNull(response.WechatpaySignatureType);
Assert.NotNull(response.WechatpaySerialNumber);
}
[Fact(DisplayName = "测试用例:验证响应签名(基于 SM2")]
public async Task TestVerifyResponseSignatureUseSM2()
{
await TestClients.InitializeCertificateManagerAsync();
var request = new Models.QueryCertificatesRequest() { AlgorithmType = "SM2" };
var response = await TestClients.InstanceUseSM2.ExecuteQueryCertificatesAsync(request);
Assert.True(response.GetRawStatus() == 200);
Assert.True(response.GetRawHeaders().Any());
Assert.True(response.GetRawBytes().Any());
Assert.True(TestClients.InstanceUseSM2.VerifyResponseSignature(response));
Assert.NotNull(response.WechatpayRequestId);
Assert.NotNull(response.WechatpayNonce);
Assert.NotNull(response.WechatpayTimestamp);
Assert.NotNull(response.WechatpaySignature);
Assert.NotNull(response.WechatpaySignatureType);
Assert.NotNull(response.WechatpaySerialNumber);
}
}
}