feat(tenpayv3): 独立化境外支付 API

This commit is contained in:
Fu Diwei
2024-05-06 20:50:58 +08:00
parent 2e19fc8aa1
commit 9b18df8f2e
850 changed files with 2016 additions and 1088 deletions

View File

@@ -377,74 +377,6 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.UnitTests
}
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /merchants/{sub_mchid}")]
public async Task TestDecryptResponseSensitiveProperty_GetHKSubMerchantResponse()
{
static Models.GetHKSubMerchantResponse GenerateMockResponseModel(Func<string, string> encryptor)
{
return SetMockResponseRawStatusAsOk(new Models.GetHKSubMerchantResponse()
{
Contact = new Models.GetHKSubMerchantResponse.Types.Contact
{
ContactName = encryptor.Invoke(MOCK_PLAIN_STR),
MobileNumber = encryptor.Invoke(MOCK_PLAIN_STR),
Email = encryptor.Invoke(MOCK_PLAIN_STR)
}
});
}
static void AssertMockResponseModel(Models.GetHKSubMerchantResponse response)
{
Assert.Equal(MOCK_PLAIN_STR, response.Contact!.ContactName!);
Assert.Equal(MOCK_PLAIN_STR, response.Contact!.MobileNumber!);
Assert.Equal(MOCK_PLAIN_STR, response.Contact!.Email!);
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantRSACertificatePrivateKey))
{
using (var client = CreateMockClientUseRSA(autoDecrypt: false))
{
var response = GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain, Utilities.RSAUtility.PADDING_MODE_PKCS1)!);
client.DecryptResponseSensitiveProperty(response);
AssertMockResponseModel(response);
}
using (var client = CreateMockClientUseRSA(
autoDecrypt: true,
mockResponseContent: new SystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.RSAUtility.EncryptWithECBByCertificate(RSA_PEM_CERTIFICATE, plain, Utilities.RSAUtility.PADDING_MODE_PKCS1)!)
)
))
{
var request = new Models.GetHKSubMerchantRequest();
var response = await client.ExecuteGetHKSubMerchantAsync(request);
AssertMockResponseModel(response);
}
}
if (!string.IsNullOrEmpty(TestConfigs.WechatMerchantSM2CertificatePrivateKey))
{
using (var client = CreateMockClientUseSM2(autoDecrypt: false))
{
var response = GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!);
client.DecryptResponseSensitiveProperty(response);
AssertMockResponseModel(response);
}
using (var client = CreateMockClientUseSM2(
autoDecrypt: true,
mockResponseContent: new SystemTextJsonSerializer().Serialize(
GenerateMockResponseModel((plain) => Utilities.SM2Utility.EncryptByCertificate(SM2_PEM_CERTIFICATE, plain)!)
)
))
{
var request = new Models.GetHKSubMerchantRequest();
var response = await client.ExecuteGetHKSubMerchantAsync(request);
AssertMockResponseModel(response);
}
}
}
[Fact(DisplayName = "测试用例:解密响应中的敏感数据([GET] /merchant-service/complaints-v2")]
public async Task TestDecryptResponseSensitiveProperty_QueryMerchantServiceComplaintsResponse()
{