forked from abpframework/abp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request abpframework#12896 from abpframework/integration-s…
…ervices Introduce Integration Service Infrastructure
- Loading branch information
Showing
24 changed files
with
250 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/AbpAspNetCoreConsts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Volo.Abp.AspNetCore; | ||
|
||
public static class AbpAspNetCoreConsts | ||
{ | ||
public const string DefaultApiPrefix = "api"; | ||
public const string DefaultIntegrationServiceApiPrefix = "integration-api"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
namespace Volo.Abp; | ||
|
||
public interface IRemoteService //TODO: Can we move this to another package? | ||
public interface IRemoteService | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
framework/src/Volo.Abp.Core/Volo/Abp/IntegrationServiceAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace Volo.Abp; | ||
|
||
[AttributeUsage(AttributeTargets.Class)] | ||
public class IntegrationServiceAttribute : Attribute | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...tCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditIntegrationServiceTestController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Volo.Abp.AspNetCore.Mvc.Auditing; | ||
|
||
[Route("integration-api/audit-test")] | ||
[IntegrationService] | ||
public class AuditIntegrationServiceTestController : AbpController | ||
{ | ||
[HttpGet] | ||
public IActionResult Get() | ||
{ | ||
return Ok(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditIntegrationServiceTestController_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Options; | ||
using NSubstitute; | ||
using Shouldly; | ||
using Volo.Abp.Auditing; | ||
using Xunit; | ||
|
||
namespace Volo.Abp.AspNetCore.Mvc.Auditing; | ||
|
||
public class AuditIntegrationServiceTestController_Tests : AspNetCoreMvcTestBase | ||
{ | ||
private readonly AbpAuditingOptions _options; | ||
private IAuditingStore _auditingStore; | ||
|
||
public AuditIntegrationServiceTestController_Tests() | ||
{ | ||
_options = ServiceProvider.GetRequiredService<IOptions<AbpAuditingOptions>>().Value; | ||
_auditingStore = ServiceProvider.GetRequiredService<IAuditingStore>(); | ||
} | ||
|
||
protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services) | ||
{ | ||
_auditingStore = Substitute.For<IAuditingStore>(); | ||
services.Replace(ServiceDescriptor.Singleton(_auditingStore)); | ||
base.ConfigureServices(context, services); | ||
} | ||
|
||
[Fact] | ||
public async Task Should_Write_Audit_Log_For_Controllers_With_IntegrationService_Attribute_If_IsEnabledForIntegrationServices() | ||
{ | ||
_options.IsEnabledForGetRequests = true; | ||
_options.IsEnabledForIntegrationServices = true; | ||
await GetResponseAsync("/integration-api/audit-test/"); | ||
await _auditingStore | ||
.Received() | ||
.SaveAsync( | ||
Arg.Is<AuditLogInfo>( | ||
x => x.Actions.Any( | ||
a => | ||
a.MethodName == nameof(AuditIntegrationServiceTestController.Get) && | ||
a.ServiceName == typeof(AuditIntegrationServiceTestController).FullName | ||
) | ||
) | ||
); | ||
} | ||
|
||
[Fact] | ||
public async Task Should_Not_Write_Audit_Log_For_Controllers_With_IntegrationService_Attribute() | ||
{ | ||
_options.IsEnabledForGetRequests = true; | ||
await GetResponseAsync("/integration-api/audit-test/"); | ||
await _auditingStore.DidNotReceive().SaveAsync(Arg.Any<AuditLogInfo>()); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...lo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController_Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.