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

Record request mapping outputs JsonMatcher with Patterns instead of Pattern #715

Closed
tjpeel opened this issue Jan 24, 2022 · 5 comments
Closed
Assignees
Labels

Comments

@tjpeel
Copy link

tjpeel commented Jan 24, 2022

Hi,

I collated the following example https://github.com/tjpeel/wiremock-question-jsonmatcher/blob/main/Program.cs#L23-L46

Please run the Program to see the issue.

The issue might be a misconfiguration on my part or be by design, or be a bug, which is why the example was made.

TLDR; when a request is recorded with a request body, the mapping includes a JsonMatcher with a Patterns property, yet when the mapping is used it will never match the request again as the incoming request is checked against an array (Patterns property) instead of each item in the array. Or it should have serialised the recorded request using the Pattern property instead.

Example servers from Program.cs

  1. A wiremock instance representing a downstream service
  2. A wiremock instance that proxies to the downstream service and records mappings
  3. A wiremock instance that uses a pre-recorded mapping (jsonpatterns)
  • The request body JsonMatcher is as was recorded via the proxying server (2) above
  • The Patterns property of the JsonMatcher is an array, which then contains the request body that was recorded
  • There have been no manual changes to this file, it's what was recorded
  • When the same request is processed by this server, it cannot match as it compares an array of request body values to a single request body; so this results in a 404
  1. A wiremock instance that uses an adapted pre-recorded mapping (jsonpattern)
  • The request body JsonMatcher was changed manually from Patterns -> Pattern
  • The Pattern property is the request payload and not an array
  • When the same request is processed by this server, it can match and return the response

Many thanks

@StefH StefH added bug and removed question labels Jan 24, 2022
@StefH StefH changed the title Record request mapping outputs JsonMatcher with Patterns instead of Pattern, which prevents mapping from being used as a stub Record request mapping outputs JsonMatcher with Patterns instead of Pattern Jan 24, 2022
@StefH StefH self-assigned this Jan 24, 2022
@StefH
Copy link
Collaborator

StefH commented Jan 24, 2022

@tjpeel
Thank you for this issue with extended description.

I think I found some issues in the JsonMatcher, this cannot handle Patterns (yet).

For now I'll just change the Save code to output pattern instead of patterns`.

Can you try preview version 1.4.33-ci-15809 ?
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@tjpeel
Copy link
Author

tjpeel commented Jan 24, 2022 via email

@StefH
Copy link
Collaborator

StefH commented Jan 27, 2022

@tjpeel
Did you have time to verify ?

@tjpeel
Copy link
Author

tjpeel commented Jan 27, 2022

Please forgive me @StefH I was offline for the past couple of days. I have just checked now and all looks good. Thanks!

@StefH
Copy link
Collaborator

StefH commented Jan 27, 2022

Hello @tjpeel, thanks for testing.

A new official NuGet version will be released shorty.

#716

@StefH StefH closed this as completed Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants