Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3rd-party platform APIs #69

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<AbpVersion>6.0.1</AbpVersion>
<EasyAbpAbpTagHelperPlusModuleVersion>1.2.3</EasyAbpAbpTagHelperPlusModuleVersion>
<EasyAbpAbpWeChatModuleVersion>2.0.0-rc.2</EasyAbpAbpWeChatModuleVersion>
<EasyAbpAbpWeChatModuleVersion>2.0.0-rc.4</EasyAbpAbpWeChatModuleVersion>

</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>2.0.0-rc.1</Version>
<Version>2.0.0-rc.2</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using EasyAbp.Abp.WeChat.Common.RequestHandling;
using EasyAbp.Abp.WeChat.OpenPlatform.RequestHandling.Dtos;
using EasyAbp.Abp.WeChat.OpenPlatform.ThirdPartyPlatform.RequestHandling;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
Expand All @@ -16,15 +17,13 @@ public EventHandlingAppService(WeChatThirdPartyPlatformEventRequestHandlingServi
_handlingService = handlingService;
}

public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(string componentAppId,
WeChatEventRequestModel request)
public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(NotifyAuthInput input)
{
return _handlingService.NotifyAuthAsync(componentAppId, request);
return _handlingService.NotifyAuthAsync(input);
}

public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(string componentAppId, string authorizerAppId,
WeChatEventRequestModel request)
public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(NotifyAppInput input)
{
return _handlingService.NotifyAppAsync(componentAppId, authorizerAppId, request);
return _handlingService.NotifyAppAsync(input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EasyAbp.Abp.WeChat.OpenPlatform.HttpApi" Version="$(EasyAbpAbpWeChatModuleVersion)" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\Common\src\EasyAbp.WeChatManagement.Common.HttpApi\EasyAbp.WeChatManagement.Common.HttpApi.csproj" />
<ProjectReference Include="..\EasyAbp.WeChatManagement.ThirdPartyPlatforms.Application.Contracts\EasyAbp.WeChatManagement.ThirdPartyPlatforms.Application.Contracts.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using EasyAbp.Abp.WeChat.Common.RequestHandling;
using EasyAbp.Abp.WeChat.OpenPlatform.RequestHandling.Dtos;
using EasyAbp.WeChatManagement.Common;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
Expand All @@ -19,15 +20,17 @@ public EventHandlingController(IEventHandlingAppService service)
_service = service;
}

public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(
string componentAppId, WeChatEventRequestModel request)
[HttpPost]
[Route("notify/auth")]
public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(NotifyAuthInput input)
{
return _service.NotifyAuthAsync(componentAppId, request);
return _service.NotifyAuthAsync(input);
}

public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(
string componentAppId, string authorizerAppId, WeChatEventRequestModel request)
[HttpPost]
[Route("notify/app")]
public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(NotifyAppInput input)
{
return _service.NotifyAppAsync(componentAppId, authorizerAppId, request);
return _service.NotifyAppAsync(input);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using EasyAbp.Abp.WeChat.Common.RequestHandling;
using EasyAbp.Abp.WeChat.OpenPlatform.RequestHandling;
using EasyAbp.Abp.WeChat.OpenPlatform.RequestHandling.Dtos;
using Volo.Abp.DependencyInjection;

namespace EasyAbp.WeChatManagement.ThirdPartyPlatforms.RequestHandling;
Expand All @@ -16,15 +17,13 @@ public RemoteWeChatThirdPartyPlatformEventHandlingService(IEventHandlingAppServi
_eventHandlingAppService = eventHandlingAppService;
}

public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(
string componentAppId, WeChatEventRequestModel request)
public virtual Task<WeChatRequestHandlingResult> NotifyAuthAsync(NotifyAuthInput input)
{
return _eventHandlingAppService.NotifyAuthAsync(componentAppId, request);
return _eventHandlingAppService.NotifyAuthAsync(input);
}

public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(
string componentAppId, string authorizerAppId, WeChatEventRequestModel request)
public virtual Task<WeChatRequestHandlingResult> NotifyAppAsync(NotifyAppInput input)
{
return _eventHandlingAppService.NotifyAppAsync(componentAppId, authorizerAppId, request);
return _eventHandlingAppService.NotifyAppAsync(input);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EasyAbp.WeChatManagement.Common;
using EasyAbp.Abp.WeChat.OpenPlatform;
using EasyAbp.WeChatManagement.Common;
using Localization.Resources.AbpUi;
using EasyAbp.WeChatManagement.ThirdPartyPlatforms.Localization;
using Volo.Abp.AspNetCore.Mvc;
Expand All @@ -11,6 +12,7 @@ namespace EasyAbp.WeChatManagement.ThirdPartyPlatforms;
[DependsOn(
typeof(WeChatManagementCommonHttpApiModule),
typeof(WeChatManagementThirdPartyPlatformsApplicationContractsModule),
typeof(AbpWeChatOpenPlatformHttpApiModule),
typeof(AbpAspNetCoreMvcModule))]
public class WeChatManagementThirdPartyPlatformsHttpApiModule : AbpModule
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml.Linq;
using EasyAbp.Abp.WeChat.Common.Infrastructure.Encryption;
using EasyAbp.Abp.WeChat.Common.Infrastructure.Services;
using EasyAbp.Abp.WeChat.Common.RequestHandling;
using EasyAbp.Abp.WeChat.Common.RequestHandling.Dtos;
using EasyAbp.Abp.WeChat.OpenPlatform.RequestHandling.Dtos;
using EasyAbp.Abp.WeChat.OpenPlatform.ThirdPartyPlatform.AccessToken;
using EasyAbp.Abp.WeChat.OpenPlatform.ThirdPartyPlatform.Options;
using EasyAbp.Abp.WeChat.OpenPlatform.ThirdPartyPlatform.Services;
using EasyAbp.Abp.WeChat.OpenPlatform.ThirdPartyPlatform.Services.Response;
using EasyAbp.WeChatManagement.Common.WeChatApps;
using EasyAbp.WeChatManagement.ThirdPartyPlatforms.AuthorizerSecrets;
using EasyAbp.WeChatManagement.ThirdPartyPlatforms.Fakes;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using NSubstitute;
using Shouldly;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Encryption;
using Xunit;

Expand Down Expand Up @@ -80,14 +77,17 @@ public async Task Should_Save_Verify_Ticket()

var xml = XDocument.Parse(encryptedMsg);

(await _eventHandlingAppService.NotifyAuthAsync(ThirdPartyPlatformsTestConsts.AppId,
new WeChatEventRequestModel
(await _eventHandlingAppService.NotifyAuthAsync(new NotifyAuthInput
{
ComponentAppId = ThirdPartyPlatformsTestConsts.AppId,
EventRequest = new WeChatEventRequestModel
{
PostData = encryptedMsg,
MsgSignature = xml.Element("xml")!.Element("MsgSignature")!.Value,
Timestamp = TimeStamp,
Notice = Nonce
})).Success.ShouldBeTrue();
}
})).Success.ShouldBeTrue();

var weChatApp =
await _weChatAppRepository.GetThirdPartyPlatformAppByAppIdAsync(ThirdPartyPlatformsTestConsts.AppId);
Expand Down Expand Up @@ -129,14 +129,17 @@ public async Task Should_Update_Refresh_Token()

var xml = XDocument.Parse(encryptedMsg);

(await _eventHandlingAppService.NotifyAuthAsync(ThirdPartyPlatformsTestConsts.AppId,
new WeChatEventRequestModel
(await _eventHandlingAppService.NotifyAuthAsync(new NotifyAuthInput
{
ComponentAppId = ThirdPartyPlatformsTestConsts.AppId,
EventRequest = new WeChatEventRequestModel
{
PostData = encryptedMsg,
MsgSignature = xml.Element("xml")!.Element("MsgSignature")!.Value,
Timestamp = TimeStamp,
Notice = Nonce
})).Success.ShouldBeTrue();
}
})).Success.ShouldBeTrue();

authorizerSecret = await _authorizerSecretRepository.GetAsync(x =>
x.ComponentAppId == ThirdPartyPlatformsTestConsts.AppId &&
Expand Down Expand Up @@ -176,14 +179,17 @@ public async Task Should_Delete_AuthorizerSecret_Entity()

var xml = XDocument.Parse(encryptedMsg);

(await _eventHandlingAppService.NotifyAuthAsync(ThirdPartyPlatformsTestConsts.AppId,
new WeChatEventRequestModel
(await _eventHandlingAppService.NotifyAuthAsync(new NotifyAuthInput
{
ComponentAppId = ThirdPartyPlatformsTestConsts.AppId,
EventRequest = new WeChatEventRequestModel
{
PostData = encryptedMsg,
MsgSignature = xml.Element("xml")!.Element("MsgSignature")!.Value,
Timestamp = TimeStamp,
Notice = Nonce
})).Success.ShouldBeTrue();
}
})).Success.ShouldBeTrue();

authorizerSecret = await _authorizerSecretRepository.FindAsync(x =>
x.ComponentAppId == ThirdPartyPlatformsTestConsts.AppId &&
Expand Down