Fix recorded requests skipped by request logger (#346)

* Fix recorded requests skipped request logger.
- When proxy is enabled the recorded requests are mistaken (IMO) for admin requests and skipped

* Add unit test

* Use different solution

* Introduce IsRecordedByProxy property on Mapping class

* Cleanup empty lines

* Refactored fix suggested way
This commit is contained in:
Vitaliy Davydiak
2019-09-17 19:15:23 +03:00
committed by Stef Heyenrath
parent e1798fbb8e
commit feea64b328
4 changed files with 43 additions and 1 deletions

View File

@@ -78,6 +78,14 @@ namespace WireMock
/// <c>true</c> if this mapping is an Admin Interface; otherwise, <c>false</c>.
/// </value>
bool IsAdminInterface { get; }
/// <summary>
/// Gets a value indicating whether this mapping to be logged.
/// </summary>
/// <value>
/// <c>true</c> if this mapping to be logged; otherwise, <c>false</c>.
/// </value>
bool LogMapping { get; }
/// <summary>
/// ProvideResponseAsync

View File

@@ -48,6 +48,9 @@ namespace WireMock
/// <inheritdoc cref="IMapping.IsAdminInterface" />
public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider || Provider is ProxyAsyncResponseProvider;
/// <inheritdoc cref="IMapping.LogMapping" />
public bool LogMapping => !(Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider);
/// <summary>
/// Initializes a new instance of the <see cref="Mapping"/> class.
/// </summary>

View File

@@ -7,6 +7,7 @@ using WireMock.Util;
using Newtonsoft.Json;
using WireMock.Http;
using WireMock.Owin.Mappers;
using WireMock.ResponseProviders;
using WireMock.Serialization;
using WireMock.Validation;
#if !USE_ASPNETCORE
@@ -99,7 +100,7 @@ namespace WireMock.Owin
return;
}
logRequest = !targetMapping.IsAdminInterface;
logRequest = !targetMapping.IsAdminInterface || targetMapping.LogMapping;
if (targetMapping.IsAdminInterface && _options.AuthorizationMatcher != null)
{