https://pact.io logo
#pact-python
Title
# pact-python
y

Yumi

03/01/2022, 8:20 AM
Hi, when using pact-verifier command with --custom-provider-header, I want to check the real header when request is replayed. I got a pact.log file after replay, however there is no custom header in it. It's like:
Copy code
I, [2022-03-01T16:05:12.110368 #6736]  INFO -- : Sending PUT request to path: "/api/cartItems" with headers: {"CONTENT_TYPE"=>"application/json", "HTTP_X_PACT_ORIGINAL_HEADER_NAMES"=>"Content-Type"}, see debug logs for body
D, [2022-03-01T16:05:12.113360 #6736] DEBUG -- : body :[{"duration":0,"id":"c3c46c8ccd254b32bfa52ba84aafa371","number":1}]
I, [2022-03-01T16:05:15.427349 #6736]  INFO -- : Received response with status: 200, headers: {"P3p"=>"CP=CAO PSA OUR", "Bluewareguid"=>"7b0774ea1ea787f7", "X-Blueware-App-Data"=>"Olx7QXtkY0UQancBBFEGGAsAJhgCCisNIA51JUI0PDgGcD0EHhw6FQ0bMD5hMyofbmkjZz0cMQsYGhwNBBMxPmFyciZnEnx0TRFiRFpMeVtRUHZVfGVqRwd+d3oPRj4GRkxiG1FJdVYrM2sTU3FtYQcEcDc=", "Content-Type"=>"application/json", "Date"=>"Tue, 01 Mar 2022 08:05:12 GMT", "Cache-Control"=>"no-cache, no-store, max-age=0, must-revalidate", "Pragma"=>"no-cache", "Expires"=>"0", "X-Xss-Protection"=>"1 ; mode=block", "Referrer-Policy"=>"no-referrer", "Vary"=>"Origin\nAccess-Control-Request-Method\nAccess-Control-Request-Headers", "Strict-Transport-Security"=>"max-age=16000000; includeSubDomains; preload;", "Content-Length"=>"79"}, see debug logs for body
D, [2022-03-01T16:05:15.430341 #6736] DEBUG -- : body: {"state":"OK","body":null,"requestId":"reqId-171d3c0265906198b4f02-b83abbaa-1"}
What I use to verify is like:
Copy code
pact-verifier --log-dir=F:\code\pact-python-master-1227\consumer\mop\pact_logs --provider-base-url=<https://baseurl.cn> --pact-ur
l=F:\code\pact-python-master-1227\consumer\mop\contract_files\ECS\ECS-OP_EditCaterProduct.json --custom-provider-header=Cookie:CMECLOUDTOKEN=3a8c6ccb407e48bb8857535bc23cba37
I'm wondering if there is a log that I can check when the request is replayed, it does request with what I provide in the custom-provider-header?
y

Yousaf Nabi (pactflow.io)

03/01/2022, 12:47 PM
Hey @Yumi, Are you using the standalone pact verifier, the pact-python or docker-cli one? There are two settings
verbose
and and
log-level
although it looks like log level defaults to debug https://github.com/pact-foundation/pact-provider-verifier/#usage Most of the examples show a space after the cookie name, and then the value
--custom-provider-header "Authentication: Type VALUE"
so I wonder if the following might work ?
--custom-provider-header "Cookie: CMECLOUDTOKEN=3a8c6ccb407e48bb8857535bc23cba37"
y

Yumi

03/02/2022, 3:12 AM
hi @Yousaf Nabi (pactflow.io) I'm using pact-python, and I tried the verbose and log-level settings, and changed the custom-provider-header velue as you suggest. however it seems no differnce from what I posted before.
Copy code
pact-verifier --log-dir=F:\op\pact_logs --provider-base-url=<https://baseurl.cn> --pact-url
=F:\op\contract_files\ECS\ECS-OP_GetCaterProduct.json --verbose --custom-provider-header "Cookie:CMECLOUDTOKEN=ea072e6bcf7b451489e5ae95151c82be"  --log-level=debug
the log is:
Copy code
I, [2022-03-02T10:55:38.406632 #17956]  INFO -- : Running example 'Verifying a pact between ECS and OP_GetCaterProduct A request for op with GET /api/web/core/op-cart/api/v1/cartItems/c3d5707fc3f7437f86d229687341f826 returns a response which has status code 200'
I, [2022-03-02T10:55:38.409624 #17956]  INFO -- : Sending GET request to path: "/api/web/core/op-cart/api/v1/cartItems/c3d5707fc3f7437f86d229687341f826" with headers: {}, see debug logs for body
D, [2022-03-02T10:55:38.413614 #17956] DEBUG -- : body :
I, [2022-03-02T10:55:41.505904 #17956]  INFO -- : Received response with status: 200, headers: {"P3p"=>"CP=CAO PSA OUR", "Bluewareguid"=>"0fc65b96134ebd16", "X-Blueware-App-Data"=>"Olx7QXtlak8QancBBFEGGAsAJhgCCisNIA51JUI0PDgGcD0EHhw6FQ0bMD5hMyofbmkjZz0cMQsYGhwNBBMxQGJwalgCZHl0UR1jXVJeYUtZT2BOICc2Gh5kZTACBWcIU1hkSlUbIAZ/ZHgr", "Content-Type"=>"application/json", "Date"=>"Wed, 02 Mar 2022 02:55:38 GMT", "Cache-Control"=>"no-cache, no-store, max-age=0, must-revalidate", "Pragma"=>"no-cache", "Expires"=>"0", "X-Xss-Protection"=>"1 ; mode=block", "Referrer-Policy"=>"no-referrer", "Vary"=>"Origin\nAccess-Control-Request-Method\nAccess-Control-Request-Headers", "Strict-Transport-Security"=>"max-age=16000000; includeSubDomains; preload;", "Content-Length"=>"1234"}, see debug logs for body
D, [2022-03-02T10:55:41.509884 #17956] DEBUG -- : body: {"state":"OK","body":null,"requestId":"reqId-171d3c0265906198b4f02-b83abbaa-1"}
Yes the custom header works, but the log does't show the request header, I mean, is there a way the custom request header can be seen in the log, instead of showing `Sending GET request to path: ....with headers: {}.`is there a way that it shows like
Sending GET request to path: ....with headers: {"Cookie":"CMECLOUDTOKEN=ea072e6bcf7b451489e5ae95151c82be"}
I tried but found that only when I set the header in `pact.with_request`in consumer test it can be seen in logs. What I really want is to show the custom-provider-header in the log file.I'm wondering is there something wrong when I use the settings?
2 Views