mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 18:48:10 +08:00
feat(wxapi): 升级公共组件
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class TestCase_AESUtilityTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:AES-CBC 解密")]
|
||||
public void TestAESCBCDecryption()
|
||||
{
|
||||
string iv = "KEWv/gyiIwAfHvjrLeaX6w==";
|
||||
string key = "YZJqKnNFi0KAiKUc0ggC2g==";
|
||||
string cipherText = "Gu2PVnxVWl+jK4F8c0liGxfkB5Bj3m5HRvwgEIk1Yb+36RZ3Bg7YmUnud/ooiHz0PQroipsH7GCjlGwUeT04NwmrFaP1y3dRYPLpS43ed9QZWcFIFo+8vTs3Zco6S98DUvaNEAs8duhz/BzfBOZaIHMziRqEtPFI0ZDzCgJluBirJ6Wl3UkygZ5/QLo3KA53qGdip7K48Rq8XbCwuidTCw==";
|
||||
|
||||
string expectedPlainData = "{\"phoneNumber\":\"186****5613\",\"purePhoneNumber\":\"186****5613\",\"countryCode\":\"86\",\"watermark\":{\"timestamp\":1634545675,\"appid\":\"wxc****17e87e0e0a7\"}}";
|
||||
string actualPlainData = Utilities.AESUtility.DecryptWithCBC(encodingKey: key, encodingIV: iv, encodingCipherText: cipherText);
|
||||
|
||||
Assert.Equal(expectedPlainData, actualPlainData, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCVTests
|
||||
public class TestCase_ApiExecuteCVTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /cv/img/qrcode")]
|
||||
public async Task CVImageQrcodeTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cv/img/qrcode")]
|
||||
public async Task TestExecuteCVImageQrcode()
|
||||
{
|
||||
var request = new Models.CVImageQrcodeRequest()
|
||||
{
|
||||
@@ -24,8 +24,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.ImageSize);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cv/img/aicrop")]
|
||||
public async Task CVImageAICropTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cv/img/aicrop")]
|
||||
public async Task TestExecuteCVImageAICrop()
|
||||
{
|
||||
var request = new Models.CVImageAICropRequest()
|
||||
{
|
||||
@@ -39,8 +39,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.ImageSize);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cv/img/superresolution")]
|
||||
public async Task CVImageSuperResolutionTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cv/img/superresolution")]
|
||||
public async Task TestExecuteCVImageSuperResolution()
|
||||
{
|
||||
var request = new Models.CVImageSuperResolutionRequest()
|
||||
{
|
||||
@@ -53,8 +53,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.MediaId);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cv/ocr/comm")]
|
||||
public async Task CVOCRCommonTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cv/ocr/comm")]
|
||||
public async Task TestExecuteCVOCRCommon()
|
||||
{
|
||||
var request = new Models.CVOCRCommonRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinMaterialTests
|
||||
public class TestCase_ApiExecuteCgibinMaterialTests
|
||||
{
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/material/get_materialcount")]
|
||||
public async Task CgibinMaterialGetMaterialCountTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/material/get_materialcount")]
|
||||
public async Task TestExecuteCgibinMaterialGetMaterialCount()
|
||||
{
|
||||
var request = new Models.CgibinMaterialGetMaterialCountRequest()
|
||||
{
|
||||
@@ -21,8 +21,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.IsSuccessful());
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/material/batchget_material")]
|
||||
public async Task CgibinMaterialBatchGetMaterialTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/material/batchget_material")]
|
||||
public async Task TestExecuteCgibinMaterialBatchGetMaterial()
|
||||
{
|
||||
var request = new Models.CgibinMaterialBatchGetMaterialRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinMediaTests
|
||||
public class TestCase_ApiExecuteCgibinMediaTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/media/upload")]
|
||||
public async Task CgibinMediaUploadTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/media/upload")]
|
||||
public async Task TestExecuteCgibinMediaUpload()
|
||||
{
|
||||
var request = new Models.CgibinMediaUploadRequest()
|
||||
{
|
||||
@@ -26,8 +26,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.MediaId);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/media/get")]
|
||||
public async Task CgibinMediaGetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/media/get")]
|
||||
public async Task TestExecuteCgibinMediaGet()
|
||||
{
|
||||
var request = new Models.CgibinMediaGetRequest()
|
||||
{
|
||||
@@ -39,8 +39,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.IsSuccessful());
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/media/uploadimg")]
|
||||
public async Task CgibinMediaUploadImageTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/media/uploadimg")]
|
||||
public async Task TestExecuteCgibinMediaUploadImage()
|
||||
{
|
||||
var request = new Models.CgibinMediaUploadImageRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinMessageMassTests
|
||||
public class TestCase_ApiExecuteCgibinMessageMassTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/message/mass/send")]
|
||||
public async Task CgibinMessageMassSendTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/message/mass/send")]
|
||||
public async Task TestExecuteCgibinMessageMassSend()
|
||||
{
|
||||
var request = new Models.CgibinMessageMassSendRequest()
|
||||
{
|
||||
@@ -27,8 +27,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.MessageId > 0);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/message/mass/preview")]
|
||||
public async Task CgibinMessageMassPreviewTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/message/mass/preview")]
|
||||
public async Task TestExecuteCgibinMessageMassPreview()
|
||||
{
|
||||
var request = new Models.CgibinMessageMassPreviewRequest()
|
||||
{
|
||||
@@ -45,8 +45,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.IsSuccessful());
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/message/mass/speed/get")]
|
||||
public async Task CgibinMessageMassSpeedGetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/message/mass/speed/get")]
|
||||
public async Task TestExecuteCgibinMessageMassSpeedGet()
|
||||
{
|
||||
var request = new Models.CgibinMessageMassSpeedGetRequest()
|
||||
{
|
||||
@@ -58,8 +58,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.SpeedValue > 0);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/message/mass/speed/set")]
|
||||
public async Task CgibinMessageMassSpeedSetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/message/mass/speed/set")]
|
||||
public async Task TestExecuteCgibinMessageMassSpeedSet()
|
||||
{
|
||||
var request = new Models.CgibinMessageMassSpeedSetRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinQrcodeTests
|
||||
public class TestCase_ApiExecuteCgibinQrcodeTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/qrcode/create")]
|
||||
public async Task CgibinQrcodeCreateTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/qrcode/create")]
|
||||
public async Task TestExecuteCgibinQrcodeCreate()
|
||||
{
|
||||
var request = new Models.CgibinQrcodeCreateRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinTagsTests
|
||||
public class TestCase_ApiExecuteCgibinTagsTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/tags/create")]
|
||||
public async Task CgibinTagsCreateTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/tags/create")]
|
||||
public async Task TestExecuteCgibinTagsCreate()
|
||||
{
|
||||
var request = new Models.CgibinTagsCreateRequest()
|
||||
{
|
||||
@@ -26,8 +26,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Equal(request.Tag.Name, response.Tag.Name);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/tags/get")]
|
||||
public async Task CgibinTagsGetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/tags/get")]
|
||||
public async Task TestExecuteCgibinTagsGet()
|
||||
{
|
||||
var request = new Models.CgibinTagsGetRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinTests
|
||||
public class TestCase_ApiExecuteCgibinTests
|
||||
{
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/token")]
|
||||
public async Task CgibinTokenTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/token")]
|
||||
public async Task TestExecuteCgibinToken()
|
||||
{
|
||||
var request = new Models.CgibinTokenRequest();
|
||||
var response = await TestClients.Instance.ExecuteCgibinTokenAsync(request);
|
||||
@@ -18,8 +18,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.AccessToken);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/ticket/getticket")]
|
||||
public async Task CgibinTicketGetTicketTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/ticket/getticket")]
|
||||
public async Task TestExecuteCgibinTicketGetTicket()
|
||||
{
|
||||
var request = new Models.CgibinTicketGetTicketRequest()
|
||||
{
|
||||
@@ -30,8 +30,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.Ticket);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/getcallbackip")]
|
||||
public async Task CgibinGetCallbackIpTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/getcallbackip")]
|
||||
public async Task TestExecuteCgibinGetCallbackIp()
|
||||
{
|
||||
var request = new Models.CgibinGetCallbackIpRequest()
|
||||
{
|
||||
@@ -42,8 +42,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotEmpty(response.IPList);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/get_api_domain_ip")]
|
||||
public async Task CgibinGetApiDomainIpTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/get_api_domain_ip")]
|
||||
public async Task TestExecuteCgibinGetApiDomainIp()
|
||||
{
|
||||
var request = new Models.CgibinGetApiDomainIpRequest()
|
||||
{
|
||||
@@ -54,8 +54,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotEmpty(response.IPList);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/clear_quota")]
|
||||
public async Task CgibinClearQuotaTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/clear_quota")]
|
||||
public async Task TestExecuteCgibinClearQuota()
|
||||
{
|
||||
var request = new Models.CgibinClearQuotaRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinUserTests
|
||||
public class TestCase_ApiExecuteCgibinUserTests
|
||||
{
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/user/info")]
|
||||
public async Task CgibinUserInfoTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/user/info")]
|
||||
public async Task TestExecuteCgibinUserInfo()
|
||||
{
|
||||
var request = new Models.CgibinUserInfoRequest()
|
||||
{
|
||||
@@ -24,8 +24,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.IsSubscribed);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/user/info/batchget")]
|
||||
public async Task CgibinUserInfoBatchGetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/user/info/batchget")]
|
||||
public async Task TestExecuteCgibinUserInfoBatchGet()
|
||||
{
|
||||
var request = new Models.CgibinUserInfoBatchGetRequest()
|
||||
{
|
||||
@@ -43,8 +43,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(response.UserList.First().IsSubscribed);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[POST] /cgi-bin/user/info/updateremark")]
|
||||
public async Task CgibinUserInfoUpdateRemarkTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /cgi-bin/user/info/updateremark")]
|
||||
public async Task TestExecuteCgibinUserInfoUpdateRemark()
|
||||
{
|
||||
var request = new Models.CgibinUserInfoUpdateRemarkRequest()
|
||||
{
|
||||
@@ -57,8 +57,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Equal(0, response.ErrorCode);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /cgi-bin/user/get")]
|
||||
public async Task CgibinUserGetTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /cgi-bin/user/get")]
|
||||
public async Task TestExecuteCgibinUserGet()
|
||||
{
|
||||
var request = new Models.CgibinUserGetRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteSemanticTests
|
||||
public class TestCase_ApiExecuteSemanticTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /semantic/semproxy/search")]
|
||||
public async Task SemanticSemproxySearchRestaurantTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /semantic/semproxy/search")]
|
||||
public async Task TestExecuteSemanticSemproxySearchRestaurant()
|
||||
{
|
||||
var request = new Models.SemanticSemproxySearchRequest()
|
||||
{
|
@@ -6,10 +6,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteSnsWithAccessTokenTests
|
||||
public class TestCase_ApiExecuteSnsWithAccessTokenTests
|
||||
{
|
||||
[Fact(DisplayName = "[GET] /sns/userinfo")]
|
||||
public async Task SnsUserInfoTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /sns/userinfo")]
|
||||
public async Task TestExecuteSnsUserInfo()
|
||||
{
|
||||
var request = new Models.SnsUserInfoRequest()
|
||||
{
|
||||
@@ -22,8 +22,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.Nickname);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /sns/auth")]
|
||||
public async Task SnsAuthTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /sns/auth")]
|
||||
public async Task TestExecuteSnsAuth()
|
||||
{
|
||||
var request = new Models.SnsAuthRequest()
|
||||
{
|
@@ -6,10 +6,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteSnsWithAppSecretTests
|
||||
public class TestCase_ApiExecuteSnsWithAppSecretTests
|
||||
{
|
||||
[Fact(DisplayName = "[GET] /sns/oauth2/access_token")]
|
||||
public async Task SnsOAuth2AccessTokenTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /sns/oauth2/access_token")]
|
||||
public async Task TestExecuteSnsOAuth2AccessToken()
|
||||
{
|
||||
var request = new Models.SnsOAuth2AccessTokenRequest()
|
||||
{
|
||||
@@ -22,8 +22,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.OpenId);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /sns/oauth2/refresh_token")]
|
||||
public async Task SnsOAuth2RefreshTokenTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /sns/oauth2/refresh_token")]
|
||||
public async Task TestExecuteSnsOAuth2RefreshToken()
|
||||
{
|
||||
var request = new Models.SnsOAuth2RefreshTokenRequest()
|
||||
{
|
||||
@@ -35,8 +35,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotNull(response.RefreshToken);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /sns/jscode2session")]
|
||||
public async Task SnsJsCode2SessionTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /sns/jscode2session")]
|
||||
public async Task TestExecuteSnsJsCode2Session()
|
||||
{
|
||||
var request = new Models.SnsJsCode2SessionRequest()
|
||||
{
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteWxaApiTests
|
||||
public class TestCase_ApiExecuteWxaApiTests
|
||||
{
|
||||
[Fact(DisplayName = "[POST] /wxaapi/log/jserr_list")]
|
||||
public async Task WxaApiLogGetPerformanceTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [POST] /wxaapi/log/jserr_list")]
|
||||
public async Task TestExecuteWxaApiLogGetPerformance()
|
||||
{
|
||||
var request = new Models.WxaApiLogGetPerformanceRequest()
|
||||
{
|
||||
@@ -26,8 +26,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotEmpty(response.DefaultTimeData.DataList);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /wxaapi/log/get_scene")]
|
||||
public async Task WxaApiLogGetSceneTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /wxaapi/log/get_scene")]
|
||||
public async Task TestExecuteWxaApiLogGetScene()
|
||||
{
|
||||
var request = new Models.WxaApiLogGetSceneRequest()
|
||||
{
|
||||
@@ -39,8 +39,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.NotEmpty(response.SceneDataList);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "[GET] /wxaapi/log/get_client_version")]
|
||||
public async Task WxaApiLogGetClientVersionTest()
|
||||
[Fact(DisplayName = "测试用例:调用 API [GET] /wxaapi/log/get_client_version")]
|
||||
public async Task TestExecuteWxaApiLogGetClientVersion()
|
||||
{
|
||||
var request = new Models.WxaApiLogGetClientVersionRequest()
|
||||
{
|
@@ -9,14 +9,14 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiDeclarationTests
|
||||
public class TestCase_CodeReviewAnalyzer
|
||||
{
|
||||
private static readonly Assembly _assembly = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Api");
|
||||
private Assembly SourceAssembly { get; } = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Api");
|
||||
|
||||
[Fact(DisplayName = "验证 API 模型命名")]
|
||||
public void ApiModelsNamingTest()
|
||||
[Fact(DisplayName = "代码评审:分析 API 模型命名")]
|
||||
public void TestApiModelsNaming()
|
||||
{
|
||||
CodeStyleUtil.VerifyApiModelsNaming(_assembly, out var ex);
|
||||
CodeStyleUtil.VerifyApiModelsNaming(SourceAssembly, out var ex);
|
||||
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
@@ -24,11 +24,11 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验证 API 模型定义")]
|
||||
public void ApiModelsDefinitionTest()
|
||||
[Fact(DisplayName = "代码评审:分析 API 模型定义")]
|
||||
public void TestApiModelsDefinition()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
|
||||
CodeStyleUtil.VerifyApiModelsDefinition(_assembly, workdir, out var ex);
|
||||
CodeStyleUtil.VerifyApiModelsDefinition(SourceAssembly, workdir, out var ex);
|
||||
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
@@ -36,11 +36,11 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验证 API 事件定义")]
|
||||
public void ApiEventsDefinitionTest()
|
||||
[Fact(DisplayName = "代码评审:分析 API 事件定义")]
|
||||
public void TestApiEventsDefinition()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "EventSamples");
|
||||
CodeStyleUtil.VerifyApiEventsDefinition(_assembly, workdir, out var ex);
|
||||
CodeStyleUtil.VerifyApiEventsDefinition(SourceAssembly, workdir, out var ex);
|
||||
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
@@ -48,10 +48,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验证 API 接口命名")]
|
||||
public void ApiExtensionsNamingTest()
|
||||
[Fact(DisplayName = "代码评审:分析 API 接口命名")]
|
||||
public void TestApiExtensionsNaming()
|
||||
{
|
||||
CodeStyleUtil.VerifyApiExtensionsNaming(_assembly, out var ex);
|
||||
CodeStyleUtil.VerifyApiExtensionsNaming(SourceAssembly, out var ex);
|
||||
|
||||
if (ex != null)
|
||||
throw ex;
|
||||
@@ -59,8 +59,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Null(ex);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验证代码规范")]
|
||||
public void CodeStyleTest()
|
||||
[Fact(DisplayName = "代码评审:分析代码规范")]
|
||||
public void TestCodeStyle()
|
||||
{
|
||||
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory);
|
||||
CodeStyleUtil.VerifySourceCodeStyle(workdir, out var ex);
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinExpressTests
|
||||
public class TestCase_DeliveryRequestSignatureTests
|
||||
{
|
||||
[Fact(DisplayName = "即时配送请求签名")]
|
||||
public async Task DeliverySignatureTest()
|
||||
[Fact(DisplayName = "测试用例:即时配送请求签名")]
|
||||
public async Task TestDeliveryRequestSignature()
|
||||
{
|
||||
var client = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
@@ -8,10 +8,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiEventDeserializationTests
|
||||
public class TestCase_EventDeserializationTests
|
||||
{
|
||||
[Fact(DisplayName = "获取事件消息类型")]
|
||||
public void GetEventMessageTypeTest()
|
||||
[Fact(DisplayName = "测试用例:获取事件消息类型")]
|
||||
public void TestGetEventMessageType()
|
||||
{
|
||||
string xml = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><FromUserName><![CDATA[fromUser]]></FromUserName><CreateTime>1348831860</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[this is a test]]></Content><MsgId>1234567890123456</MsgId></xml>";
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.Equal("TEXT", eventModel.MessageType, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "反序列化 TEXT 事件")]
|
||||
public void DeserializeTextMessageEventTest()
|
||||
[Fact(DisplayName = "测试用例:反序列化 TEXT 事件")]
|
||||
public void TestDeserializeTextMessageEvent()
|
||||
{
|
||||
string xml = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><FromUserName><![CDATA[fromUser]]></FromUserName><CreateTime>1348831860</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[this is a test]]></Content><MsgId>1234567890123456</MsgId></xml>";
|
||||
|
@@ -8,10 +8,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiEventVerificationTests
|
||||
public class TestCase_EventVerificationTests
|
||||
{
|
||||
[Fact(DisplayName = "验签并解密回调数据")]
|
||||
public void GetEventMessageTypeTest()
|
||||
[Fact(DisplayName = "测试用例:验签并解密回调数据")]
|
||||
public void TestVerifyEvent()
|
||||
{
|
||||
string callbacMsgSig = "477715d11cdb4164915debcba66cb864d751f3e6";
|
||||
string callbacTimeStamp = "1409659813";
|
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class TestCase_HashUtilityTests
|
||||
{
|
||||
[Fact(DisplayName = "测试用例:SHA-1 信息摘要")]
|
||||
public void TestSHA1Hash()
|
||||
{
|
||||
string rawData = "jsapi_ticket=HoagFKDcsGMVCIY2vOjf9nGrZ3eaM0qXs5ROFN_3k_HrGc0VocemA6wMXkvrL-Ei4IitXxwKF62CJWR8mWXZ3Q&noncestr=e7b435f73835402da44f16640ddc8696×tamp=1621348162&url=https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign";
|
||||
|
||||
string actualHash = Utilities.SHA1Utility.Hash(rawData);
|
||||
string expectedHash = "b214ea1f8ae019c207f8c6ffb843c8474cbab28c";
|
||||
|
||||
Assert.Equal(expectedHash, actualHash, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "测试用例:HMAC-SHA-256 消息认证码")]
|
||||
public void TestHMACHashWithSHA1()
|
||||
{
|
||||
string secret = "zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u";
|
||||
string rawData = "appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&ts=1507530737&zone_id=1&org_loc=/cgi-bin/midas/getbalance&method=POST&secret=zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u";
|
||||
|
||||
string actualHash = Utilities.HMACUtility.HashWithSHA256(secret, rawData);
|
||||
string expectedHash = "1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b";
|
||||
|
||||
Assert.Equal(expectedHash, actualHash, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,10 +7,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiExecuteCgibinMidasTests
|
||||
public class TestCase_MidasRequestSignatureTests
|
||||
{
|
||||
[Fact(DisplayName = "米大师请求签名")]
|
||||
public async Task MidasSigTest()
|
||||
[Fact(DisplayName = "测试用例:米大师请求签名")]
|
||||
public async Task TestMidasRequestSignature()
|
||||
{
|
||||
var client = new WechatApiClient(new WechatApiClientOptions()
|
||||
{
|
@@ -8,10 +8,10 @@ using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiWxBizMsgCryptorTests
|
||||
public class TestCase_WxBizMsgCryptorUtilityTests
|
||||
{
|
||||
[Fact(DisplayName = "验签并解密回调数据")]
|
||||
public void VerifyAndDecryptEventTest()
|
||||
[Fact(DisplayName = "试用例:验签并解密回调数据")]
|
||||
public void TestVerifyAndDecryptEvent()
|
||||
{
|
||||
string token = "QDG6eK";
|
||||
string appId = "wx5823bf96d3bd56c7";
|
||||
@@ -29,8 +29,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
Assert.True(Utilities.WxBizMsgCryptor.VerifySignature(token, reqTimeStamp, reqNonce, reqCipherText, reqMsgSig));
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "验签回调数据")]
|
||||
public void VerifyEventTest()
|
||||
[Fact(DisplayName = "试用例:验签回调数据")]
|
||||
public void TestVerifyEvent()
|
||||
{
|
||||
string token = "ovAkP0Tb";
|
||||
string reqMsgSig = "8128e41a38892d814e4aa67753425da9dc8ec2b3";
|
@@ -8,8 +8,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
static TestConfigs()
|
||||
{
|
||||
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
||||
// WARN: 敏感信息请不要提交到 git!
|
||||
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
||||
// WARNING: 请在 DEBUG 模式下运行测试用例。
|
||||
// WARNING: 敏感信息请不要提交到 git!
|
||||
|
||||
try
|
||||
{
|
||||
@@ -17,13 +18,13 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
using var jdoc = JsonDocument.Parse(stream);
|
||||
|
||||
var config = jdoc.RootElement.GetProperty("TestConfig");
|
||||
WechatAppId = config.GetProperty("AppId").GetString();
|
||||
WechatAppSecret = config.GetProperty("AppSecret").GetString();
|
||||
WechatAccessToken = config.GetProperty("AccessToken").GetString();
|
||||
WechatOpenId = config.GetProperty("OpenId").GetString();
|
||||
WechatAppId = config.GetProperty("AppId").GetString()!;
|
||||
WechatAppSecret = config.GetProperty("AppSecret").GetString()!;
|
||||
WechatAccessToken = config.GetProperty("AccessToken").GetString()!;
|
||||
WechatOpenId = config.GetProperty("OpenId").GetString()!;
|
||||
|
||||
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString();
|
||||
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString();
|
||||
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString()!;
|
||||
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString()!;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
||||
{
|
||||
public class WechatApiSecurityTests
|
||||
{
|
||||
[Fact(DisplayName = "信息摘要(SHA-1)")]
|
||||
public void Sha1HashTest()
|
||||
{
|
||||
string rawData = "jsapi_ticket=HoagFKDcsGMVCIY2vOjf9nGrZ3eaM0qXs5ROFN_3k_HrGc0VocemA6wMXkvrL-Ei4IitXxwKF62CJWR8mWXZ3Q&noncestr=e7b435f73835402da44f16640ddc8696×tamp=1621348162&url=https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign";
|
||||
|
||||
string actualHash = Utilities.SHA1Utility.Hash(rawData);
|
||||
string expectedHash = "b214ea1f8ae019c207f8c6ffb843c8474cbab28c";
|
||||
|
||||
Assert.Equal(expectedHash, actualHash, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "信息摘要(HMAC-SHA-256)")]
|
||||
public void HmacSha1HashTest()
|
||||
{
|
||||
string secret = "zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u";
|
||||
string rawData = "appid=wx1234567&offer_id=12345678&openid=odkx20ENSNa2w5y3g_qOkOvBNM1g&pf=android&ts=1507530737&zone_id=1&org_loc=/cgi-bin/midas/getbalance&method=POST&secret=zNLgAGgqsEWJOg1nFVaO5r7fAlIQxr1u";
|
||||
|
||||
string actualHash = Utilities.HMACSHA256Utility.Hash(secret, rawData);
|
||||
string expectedHash = "1ad64e8dcb2ec1dc486b7fdf01f4a15159fc623dc3422470e51cf6870734726b";
|
||||
|
||||
Assert.Equal(expectedHash, actualHash, ignoreCase: true);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "AES-CBC 解密")]
|
||||
public void AesCbcDecryptTest()
|
||||
{
|
||||
string iv = "KEWv/gyiIwAfHvjrLeaX6w==";
|
||||
string key = "YZJqKnNFi0KAiKUc0ggC2g==";
|
||||
string cipherText = "Gu2PVnxVWl+jK4F8c0liGxfkB5Bj3m5HRvwgEIk1Yb+36RZ3Bg7YmUnud/ooiHz0PQroipsH7GCjlGwUeT04NwmrFaP1y3dRYPLpS43ed9QZWcFIFo+8vTs3Zco6S98DUvaNEAs8duhz/BzfBOZaIHMziRqEtPFI0ZDzCgJluBirJ6Wl3UkygZ5/QLo3KA53qGdip7K48Rq8XbCwuidTCw==";
|
||||
|
||||
string expectedPlainData = "{\"phoneNumber\":\"186****5613\",\"purePhoneNumber\":\"186****5613\",\"countryCode\":\"86\",\"watermark\":{\"timestamp\":1634545675,\"appid\":\"wxc****17e87e0e0a7\"}}";
|
||||
string actualPlainData = Utilities.AESUtility.DecryptWithCBC(encodingKey: key, encodingIV: iv, encodingCipherText: cipherText);
|
||||
|
||||
Assert.Equal(expectedPlainData, actualPlainData, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user