Hello, I am trying to write a consumer test which ...
# pact-jvm
t
Hello, I am trying to write a consumer test which basically makes a POST request to get a token back, this POST request has an
Authorization
header where the value is a JWT. For it to be accepted fine by the provider, it needs to not be expired etc. Is there any way I can handle this with matchers etc? I have this regex
Copy code
.matchHeader("Authorization", "^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*\$")
but not sure about the JWT expiry part and obviously how the jwt would be decoded from that regex?
u
That won't work, because it won't be able to send a valid token. See https://docs.pact.io/implementation_guides/jvm/provider/junit5#modifying-the-requests-before-they-are-sent for a way to do this
t
thanks
this looks to be on the provider side though? what about consumer side? I was considering asking provider team to make a long lived jwt with expiry far away for testing or something
i read something about following Postels laws in the pact docs? So I could make the request data on my consumer side (which has this jwt auth header) more strict by using example jwt that should always work in testing, or I guess if I keep using that match header on my side or something, then the provider side could do the modifying of the request before sent?? What would normally be preferred, or am I still confused here? Thanks