Merge pull request #8107 from abpframework/maliming/razor-page-audt-patch

Get the correct type of page model.
pull/8113/head
Halil İbrahim Kalkan 5 years ago committed by GitHub
commit 84eea65ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,7 +83,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
auditLog = auditLogScope.Log;
auditLogAction = auditingHelper.CreateAuditLogAction(
auditLog,
context.HandlerMethod.GetType(),
context.HandlerMethod.MethodInfo.DeclaringType,
context.HandlerMethod.MethodInfo,
context.HandlerArguments
);

@ -14,6 +14,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
_options = options.Value;
}
[HttpGet]
public IActionResult Get()
{
return Ok();
}
[Route("audit-success")]
public IActionResult AuditSuccessForGetRequests()
{

@ -1,4 +1,5 @@
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
@ -28,6 +29,17 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
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]
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>());
}
[Fact]
public async Task Should_Trigger_Middleware_And_AuditLog_Exception_When_Returns_Object()
{

@ -15,6 +15,11 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
_options = options.Value;
}
public void OnGet()
{
}
public IActionResult OnGetAuditSuccessForGetRequests()
{
return new OkResult();
@ -30,4 +35,4 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
throw new UserFriendlyException("Exception occurred!");
}
}
}
}

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
@ -27,6 +28,17 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
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]
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>());
}
[Fact]
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>());
}
}
}
}

Loading…
Cancel
Save