|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
@ -41,6 +42,23 @@ public class AuditTestController_Tests : AspNetCoreMvcTestBase
|
|
|
|
|
x.Actions.Any(a => a.MethodName == nameof(AuditTestController.Get))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Should_Disable_AuditLog_For_Get_And_Head_Requests()
|
|
|
|
|
{
|
|
|
|
|
_options.IsEnabledForGetRequests = false;
|
|
|
|
|
await GetResponseAsync("api/audit-test/audit-success");
|
|
|
|
|
await _auditingStore.Received().DidNotReceive().SaveAsync(Arg.Any<AuditLogInfo>());
|
|
|
|
|
|
|
|
|
|
using (var requestMessage = new HttpRequestMessage(HttpMethod.Head, "api/audit-test/audit-success"))
|
|
|
|
|
{
|
|
|
|
|
var response = await Client.SendAsync(requestMessage);
|
|
|
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _auditingStore.Received().DidNotReceive().SaveAsync(Arg.Any<AuditLogInfo>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_GetRequests()
|
|
|
|
|
{
|
|
|
|
@ -50,7 +68,6 @@ public class AuditTestController_Tests : AspNetCoreMvcTestBase
|
|
|
|
|
await _auditingStore.Received().SaveAsync(Arg.Any<AuditLogInfo>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Should_Trigger_Middleware_And_AuditLog_Success_For_Specified_Requests()
|
|
|
|
|
{
|
|
|
|
|