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
parent
commit
84eea65ec4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
  2. 6
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController.cs
  3. 14
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController_Tests.cs
  4. 7
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage.cshtml.cs
  5. 18
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage_Tests.cs

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.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
); );

6
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController.cs

@ -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()
{ {

14
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestController_Tests.cs

@ -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()
{ {
@ -51,7 +63,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>()); await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>());
} }
[Fact] [Fact]
public async Task Should_Trigger_Middleware_And_AuditLog_Exception_When_Returns_Object() public async Task Should_Trigger_Middleware_And_AuditLog_Exception_When_Returns_Object()
{ {

7
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage.cshtml.cs

@ -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();
@ -30,4 +35,4 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
throw new UserFriendlyException("Exception occurred!"); throw new UserFriendlyException("Exception occurred!");
} }
} }
} }

18
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Auditing/AuditTestPage_Tests.cs

@ -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()
{ {
@ -50,7 +62,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>()); await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>());
} }
[Fact] [Fact]
public async Task Should_Trigger_Middleware_And_AuditLog_Exception_When_Returns_Object() public async Task Should_Trigger_Middleware_And_AuditLog_Exception_When_Returns_Object()
{ {
@ -62,4 +74,4 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>()); await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>());
} }
} }
} }

Loading…
Cancel
Save