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

matchPath(regex) generates path example that do not match regexp in certain circumstances. #1826

Open
cjgwhite opened this issue Sep 13, 2024 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@cjgwhite
Copy link

Background

As of version 4.6.7 the .matchPath(regexp) method appears to validate the randomly generated path example with the regexp supplied. Prior to 4.6.7 no validation seems to be done.

The issue

The issue arises where the regexp contains certain meta-characters; e.g. ^ and $. These meta-characters are replayed into the generated random example and thus the example does not match the regexp.

e.g. regexp /pet/[0-9]+$ results in random examples like /pet/40552$

Version 4.6.7 onwards

Due to the change to the functionality of the matchPath(regexp) method, introducing checking of the example against the regexp, Consumer tests Error where the regexp contains ^ and/or $; e.g.

... .matchPath("/pet/[0-9]+$")
InvalidMatcher Example "/pet/40552$" does not match regular expression "/pet/[0-9]+$"

Version 4.6.6 and prior

These incorrectly generated examples are encoded into the .pact file generated from the consumer test.

Root Cause

This appears to be due to the use of com.github.mifmif:generex:1.0.2 for the generation of the random strings from the provided regexp.

com.github.mifmif:generex:1.0.2is the latest version of this library that was released Oct 30, 2016 -- there does not appear to have been any further development or maintenance of this project.

This specific issue has been logged with the Generex project on several occasions, e.g. Aug 4, 2017, Feb 28, 2019, with no action taken.

@rholshausen rholshausen added the enhancement Indicates new feature requests label Oct 22, 2024
@uglyog uglyog added bug Indicates an unexpected problem or unintended behavior and removed enhancement Indicates new feature requests labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants