How to populate params value in webhook setup state call
Hi,
I see that when calling the webhook setup state call, I receive this in the body of the POST call:
{
"consumer": "Consumer",
"state": "User exists and has resources",
"states": [
"User exists and has resources"
],
"params": {}
}
I see the key params and I do not really know how to populate that. I also do not know the meaning of states. Is there any docs for this? I have not been able to found any.
I also asked this in Stack Overflow.
I fount this documentation: https://docs.pact.io/getting_started/provider_states, but it does not explain at all the content of the body.
The TL;DR is states and params are V3 Pact features. states is used in MessagePact implementation in Python (which uses the pact-message ruby gem). params is not used in pact-python backed by the ruby core.
There are examples of use in this repo of state handlers,
https://github.com/pact-foundation/pact-python/blob/master/examples/fastapi_provider/tests/pact_provider.py https://github.com/pact-foundation/pact-python/blob/master/examples/flask_provider/tests/pact_provider.py
you can ignore the states array for http tests
https://github.com/pact-foundation/pact-provider-verifier#api-with-provider-states
Ignore the states array that you will see if you happen to print out the live provider state set up request body - that was an attempt to make the set up call forwards compatible with the v3 pact specification, which allows multiple provider states. Unfortunately, this forwards compatibilty attempt failed, because the v3 provider states support a map of params, not just a name, so it should have been { "state": { "name": "PROVIDER_STATE, "params": {...} } }. See the next section for the actual v3 support.
Multiple provider states, and those which use params will become relevant in the v3 specification (provided by the rust core) which will be delivered post https://github.com/pact-foundation/pact-python/pull/367 is merged.
states are mapped in the http proxy for MessagePact in pact-python, see here in code https://github.com/pact-foundation/pact-python/blob/03df5c50ca7c26fe4afe013583b9b1036f5ed796/pact/http_proxy.py#L16-L28