feat(tenpayv3): 新增平台收付通发起异常退款相关接口
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeLint / Lint (push) Has been cancelled

This commit is contained in:
Fu Diwei
2024-10-14 10:51:44 +08:00
parent 5788de8aaf
commit 1ce5ee4f6f
8 changed files with 265 additions and 1 deletions

View File

@@ -677,6 +677,62 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /ecommerce/refunds/{refund_id}/apply-abnormal-refund")]
public async Task TestEncryptRequestSensitiveProperty_CreateEcommerceAbnormalRefundApplyRequest()
{
static Models.CreateEcommerceAbnormalRefundApplyRequest GenerateMockRequestModel()
{
return new Models.CreateEcommerceAbnormalRefundApplyRequest()
{
BankAccountNumber = MOCK_PLAIN_STR,
RealName = MOCK_PLAIN_STR
};
}
static void AssertMockRequestModel(Models.CreateEcommerceAbnormalRefundApplyRequest request, Func<string, string> decryptor)
{
Assert.NotEqual(MOCK_PLAIN_STR, request.BankAccountNumber!);
Assert.NotEqual(MOCK_PLAIN_STR, request.RealName!);
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.BankAccountNumber!));
Assert.Equal(MOCK_PLAIN_STR, decryptor.Invoke(request.RealName!));
Assert.Equal(MOCK_CERT_SN, request.WechatpayCertificateSerialNumber!, ignoreCase: true);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseRSA(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateEcommerceAbnormalRefundApplyAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.RSAUtility.DecryptWithECB(RSA_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoEncrypt: false))
{
var request = GenerateMockRequestModel();
client.EncryptRequestSensitiveProperty(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
using (var client = CreateMockClientUseSM2(autoEncrypt: true))
{
var request = GenerateMockRequestModel();
await client.ExecuteCreateEcommerceAbnormalRefundApplyAsync(request);
AssertMockRequestModel(request, (cipher) => Utilities.SM2Utility.Decrypt(SM2_PEM_PRIVATE_KEY, (EncodedString)cipher)!);
}
}
}
[Fact(DisplayName = "测试用例:加密请求中的敏感数据([POST] /eduschoolpay/contracts/presign")]
public async Task TestEncryptRequestSensitiveProperty_PresignEducationSchoolPayContractRequest()
{