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

Post request with "BodyAsBytes" is not matched by RegexMatcher #624

Closed
FSatmar opened this issue Aug 4, 2021 · 5 comments
Closed

Post request with "BodyAsBytes" is not matched by RegexMatcher #624

FSatmar opened this issue Aug 4, 2021 · 5 comments
Labels

Comments

@FSatmar
Copy link

FSatmar commented Aug 4, 2021

Describe the bug

When a mapping is in place for a Post request with Body RegexMatcher = ".*" and a request with "BodyAsBytes" is made, the mapping is not returned.

Expected behavior:

The mapping should be returned since the RegexMatcher should match any body content.

Test to reproduce

  • 1 create Post mapping with RegexMatcher = ".*"
  • 2 make request with "BodyAsBytes"

Other related info

Please see attached files for examples of mapping and requests. Note that Request1with String body type works, while Request2 with BodyAsBytes fails.
Mapping.txt
Request1.txt
Request2.txt
Also note that this used to work fine in version 1.0.9.

@FSatmar FSatmar added the bug label Aug 4, 2021
@StefH
Copy link
Collaborator

StefH commented Aug 4, 2021

Hello @FSatmar ,

I understand your point, however when the body is just bytes, a RegExMatcher/WildcardMatcher (= StringMatcher) cannot be used because I never know if the bytes area actually a string (and which encoding is used).

So I think what could be a solution for you is that a new matcher like AnyBytesMatcher will be added, which can be used to detect if the body contains any bytes.

Another option would be to update the ExactObjectMatcher which can take a base64 string which defines the exact body you want to match.

@FSatmar
Copy link
Author

FSatmar commented Aug 4, 2021

Is there an option to define a matcher that would match any type of body and any content? as in this case I don't care about the body content. otherwise, it seems I'll need to create 2 mappings, one for each body type.

@StefH
Copy link
Collaborator

StefH commented Aug 4, 2021

I've added a NotNullOrEmptyMatcher which should be possible to use for string, json and bytes.

Try the MyGet preview version: 1.4.19-ci-15242.

#625

@FSatmar
Copy link
Author

FSatmar commented Aug 4, 2021

I've added a NotNullOrEmptyMatcher which should be possible to use for string, json and bytes.

Try the MyGet preview version: 1.4.19-ci-15242.

#625

This works great, thank you very much!

@StefH
Copy link
Collaborator

StefH commented Aug 4, 2021

@FSatmar OK

I'll merge the PR and create a new official version in some time.

@StefH StefH closed this as completed Aug 4, 2021
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