Nothing Special   »   [go: up one dir, main page]

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

Using a fromProviderState matcher in a query parameter value shouldn't return a json path matcher in the generated pact #1132

Open
1 task
csydvs opened this issue Oct 23, 2023 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@csydvs
Copy link
csydvs commented Oct 23, 2023

Software versions

Please provide at least OS and version of pact-js

  • OS: Mac OSX 12.6.5
  • Consumer Pact library: Pact JS 12.1.0
  • Provider Pact library: pact jvm maven 4.5.6
  • Node Version: 18.17.1

Issue Checklist

Please confirm the following:

  • [*] I have upgraded to the latest
  • [*] I have the read the FAQs in the Readme
  • [*] I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • [n/a] I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

Using a fromProviderState matcher in a query parameter value shouldn't return a JsonPath matcher.

The reality is that I wasn't totally sure whether to open the bug on this side of the pact jvm side (for my provider), but I found this note from the V3 path specification, and if I'm reading it right, I think that it's an error on the pact-js side. But maybe there's something else I'm missing to get these things to match up correctly.

So, I think that in the generated pact, I should get something like this:

        "generators": {
          "query": {
            "fooIdentifier": {
              "expression": "${fooIdentifier}",
              "type": "ProviderState"
            }
          }
        },
        "matchingRules": {
          "query": {
            "fooIdentifier": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "type"
                }
              ]
            }
          }
        },

Instead of

        "generators": {
          "query": {
            "$.fooIdentifier[0]": {
              "expression": "${fooIdentifier}",
              "type": "ProviderState"
            }
          }
        },
        "matchingRules": {
          "query": {
            "$.fooIdentifier[0]": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "type"
                }
              ]
            }
          }
        },

If I make this change manually to the pact, then pact-jvm injects the provider state like I would expect.

Actual behaviour

Using json path in the path matchers for query parameters.

Steps to reproduce

Using provider = PactV3({ ... }), have a provider test with something like

provider.given('some state')
   .uponReceiving('a request for all the foos'))))
   .withRequest({
      method: 'GET',
      path: '/api/foos',
      query: {
          fooIdentifier: MatchersV3.fromProviderState('${fooIdentifier}', 'abc123')
      })
     .willRespondWith({
          status: 200
     })

And then do the test and generate the state.

@csydvs csydvs added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Oct 23, 2023
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 triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant