Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recorded requests skipped by request logger #346

Merged
merged 6 commits into from
Sep 17, 2019

Conversation

vitaliydavydiak
Copy link
Contributor

When proxy is enabled the recorded requests are mistaken (IMO) for admin interface requests and skipped in LogEntries. Actually none of requests logged in proxy mode. It is valuable to monitor that while recording.

- When proxy is enabled the recorded requests are mistaken (IMO) for admin requests and skipped
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a look?

@@ -99,7 +100,7 @@ private async Task InvokeInternal(IContext ctx)
return;
}

logRequest = !targetMapping.IsAdminInterface;
logRequest = !targetMapping.IsAdminInterface || targetMapping.Provider is ProxyAsyncResponseProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapping class already has this code:

public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider || Provider is ProxyAsyncResponseProvider;

So no need to add this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the root cause of the problem (there is negation). In this check it is actually assumes that proxy response is NOT admin interface in order to log it. I have tried to remove that condition on mapping but it actually conflicts with Admin interface. There is a test for that - FluentMockServer_Proxy_Should_Not_overrule_AdminMappings. So it is kind of workaround to still log proxy requests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, Sorry.

In that case. Maybe it's better to to add a property to the mapping class, like this:

public bool LogRequest => !(Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about smth like:
public bool IsProxyRequest => Provider is ProxyAsyncResponseProvider

Copy link
Collaborator

@StefH StefH Sep 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you still need to check if it's not an admin request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the MiddleWare - yes. Let me update the PR

@@ -46,7 +46,10 @@ public class Mapping : IMapping
public bool IsStartState => Scenario == null || Scenario != null && NextState != null && ExecutionConditionState == null;

/// <inheritdoc cref="IMapping.IsAdminInterface" />
public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider || Provider is ProxyAsyncResponseProvider;
public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is too dangerous to update this code because .IsAdminInterface is used in more places in the application.

I think the best solution is to add a property LogRequest as proposed earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually logs both, request and response. Is LogMapping better name for this property?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogMapping is fine.

@codecov
Copy link

codecov bot commented Sep 17, 2019

Codecov Report

Merging #346 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #346      +/-   ##
==========================================
+ Coverage   80.25%   80.26%   +<.01%     
==========================================
  Files         111      111              
  Lines        4442     4443       +1     
==========================================
+ Hits         3565     3566       +1     
  Misses        877      877
Impacted Files Coverage Δ
src/WireMock.Net/Owin/WireMockMiddleware.cs 94.17% <100%> (ø) ⬆️
src/WireMock.Net/Mapping.cs 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f40602...56fb16e. Read the comment docs.

@StefH
Copy link
Collaborator

StefH commented Sep 17, 2019

Thanks.

@StefH StefH merged commit feea64b into WireMock-Net:master Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants