for me If Authorization header doesn't exist in th...
# pact-js
a
for me If Authorization header doesn't exist in the pact then its adds value of the header from requestFilter. If Authorization header exists in the contract then I expect it to replace the value but it doesn't.
t
I don’t think I understand the question, sorry. Could you elaborate on what you’re trying to do?
a
Hi Timothy, I want to replace the value of Authorization in header from requestFilter.
But currently, It only adds the value of Authorization in header if its not present in the Contract. If authorization header exist in the contract it doesn't override it
t
What are you trying to do?
a
i am trying to override Authorization header value while doing provider side verification
t
Ah, I think I understand. The request header filters aren’t supposed to be for overriding the contract
If authorisation is part of the contract, it should be in the contract and not overridden. If it isn’t, then you can override it
What I usually do is stub the auth, so in the contract I give a dummy token, which I control with a provider state
I usually use tokens like TOKEN or TOKEN_WITH_ADMIN_SCOPE
If you don’t want to do that, then you can leave it out of the contract and inject it later
I like the stubbed token approach because it means the type of the token is not part of the contract. But what the token means is part of the contract
So you might have a provider state that is
“TOKEN_WITH_ADMIN_SCOPE” is a valid token that has admin privileges
a
So as I understood if we have, Authorization header in the contract we can't override it, right?
t
I believe that is correct
If you could override the contract, then you could have a falsely passing verification
👍 1