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

43 lines
1.9 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
2021-05-10 15:30:00 +08:00
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
{
2022-01-21 13:10:56 +08:00
public class TestCase_ResponseVerificationTests
2021-05-10 15:30:00 +08:00
{
2022-01-21 13:10:56 +08:00
[Fact(DisplayName = "测试用例:验证响应签名")]
public async Task TestVerifyResponseSignature()
2021-05-10 15:30:00 +08:00
{
await TestClients.InitializeCertificateManagerAsync();
var request = new Models.QueryCertificatesRequest() { AlgorithmType = "RSA" };
var response = await TestClients.InstanceUseRSA.ExecuteQueryCertificatesAsync(request);
2021-05-10 15:30:00 +08:00
2022-01-04 19:27:53 +08:00
Assert.True(response.RawStatus == 200);
Assert.True(response.RawHeaders.Count > 0);
Assert.True(response.RawBytes.Length > 0);
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.WechatpayCertificateSerialNumber);
request = new Models.QueryCertificatesRequest() { AlgorithmType = "SM2" };
response = await TestClients.InstanceUseSM2.ExecuteQueryCertificatesAsync(request);
Assert.True(response.RawStatus == 200);
Assert.True(response.RawHeaders.Count > 0);
Assert.True(response.RawBytes.Length > 0);
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.WechatpayCertificateSerialNumber);
2021-05-10 15:30:00 +08:00
}
}
}