Browse Source
Merge pull request #8107 from abpframework/maliming/razor-page-audt-patch
Get the correct type of page model.
pull/8113/head
Halil İbrahim Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
41 additions and
6 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
-
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController.cs
-
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController_Tests.cs
-
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage.cshtml.cs
-
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage_Tests.cs
|
|
@ -83,7 +83,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing |
|
|
auditLog = auditLogScope.Log; |
|
|
auditLog = auditLogScope.Log; |
|
|
auditLogAction = auditingHelper.CreateAuditLogAction( |
|
|
auditLogAction = auditingHelper.CreateAuditLogAction( |
|
|
auditLog, |
|
|
auditLog, |
|
|
context.HandlerMethod.GetType(), |
|
|
context.HandlerMethod.MethodInfo.DeclaringType, |
|
|
context.HandlerMethod.MethodInfo, |
|
|
context.HandlerMethod.MethodInfo, |
|
|
context.HandlerArguments |
|
|
context.HandlerArguments |
|
|
); |
|
|
); |
|
|
|
|
|
@ -14,6 +14,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing |
|
|
_options = options.Value; |
|
|
_options = options.Value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
public IActionResult Get() |
|
|
|
|
|
{ |
|
|
|
|
|
return Ok(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Route("audit-success")] |
|
|
[Route("audit-success")] |
|
|
public IActionResult AuditSuccessForGetRequests() |
|
|
public IActionResult AuditSuccessForGetRequests() |
|
|
{ |
|
|
{ |
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Linq; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
@ -28,6 +29,17 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing |
|
|
base.ConfigureServices(context, services); |
|
|
base.ConfigureServices(context, services); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Should_Get_Correct_ServiceName_And_MethodName() |
|
|
|
|
|
{ |
|
|
|
|
|
_options.IsEnabledForGetRequests = true; |
|
|
|
|
|
_options.AlwaysLogOnException = false; |
|
|
|
|
|
await GetResponseAsync("/api/audit-test/"); |
|
|
|
|
|
await _auditingStore.Received().SaveAsync(Arg.Is<AuditLogInfo>(x => |
|
|
|
|
|
x.Actions.Any(a => a.ServiceName == typeof(AuditTestController).FullName) && |
|
|
|
|
|
x.Actions.Any(a => a.MethodName == nameof(AuditTestController.Get)))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_GetRequests() |
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_GetRequests() |
|
|
{ |
|
|
{ |
|
|
|
|
|
@ -15,6 +15,11 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing |
|
|
_options = options.Value; |
|
|
_options = options.Value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void OnGet() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public IActionResult OnGetAuditSuccessForGetRequests() |
|
|
public IActionResult OnGetAuditSuccessForGetRequests() |
|
|
{ |
|
|
{ |
|
|
return new OkResult(); |
|
|
return new OkResult(); |
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
using System.Threading.Tasks; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
using Microsoft.Extensions.Hosting; |
|
|
@ -27,6 +28,17 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing |
|
|
base.ConfigureServices(context, services); |
|
|
base.ConfigureServices(context, services); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task Should_Get_Correct_ServiceName_And_MethodName() |
|
|
|
|
|
{ |
|
|
|
|
|
_options.IsEnabledForGetRequests = true; |
|
|
|
|
|
_options.AlwaysLogOnException = false; |
|
|
|
|
|
await GetResponseAsync("/Auditing/AuditTestPage"); |
|
|
|
|
|
await _auditingStore.Received().SaveAsync(Arg.Is<AuditLogInfo>(x => |
|
|
|
|
|
x.Actions.Any(a => a.ServiceName == typeof(AuditTestPage).FullName) && |
|
|
|
|
|
x.Actions.Any(a => a.MethodName == nameof(AuditTestPage.OnGet)))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_GetRequests() |
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_GetRequests() |
|
|
{ |
|
|
{ |
|
|
|