Hello folks, I was wondering if/how it's possible ...
# general
g
Hello folks, I was wondering if/how it's possible to define a contract in the consumer side but explicitly states that a given query parameter has to be ignored for the matching?
The typical use case is when the production code adds some query parameter like an api key but this api key is a "infrastructure requirement", it's not really part of the contract with the provider.
b
One approach is to bundle that into the state description, rather than the interaction content. E.g. "user is logged in" or "user with active session" for auth tokens, is similar to "request has valid API key". It's a very implementation-dependent question, though . . . if your responsibilities are split between actors (like, the API never gets invalid requests, because they're intercepted by a gateway), then it's not quite a 1:1 contract.
How you do the provider verification should be env-independent, though. I'd cover the extra API key header in functional/smoke tests, not unit/contract tests.
g
My issue is more on the consumer side where I don't have control over the mock server being created from the contract.
If I don't put the query parameter in the contract, the mock server is not able to find the appropriate answer.
j
@Gaël Jourdan-Weil Hello!!! Cucumber Jo here dancing pickle
g
Hey, nice to see you here @Jo Laing 👋