pact-foundation / pact-python

Python version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
http://pact.io
MIT License
579 stars 137 forks source link

Verifier ignores the broker token #225

Closed ngufra closed 3 years ago

ngufra commented 3 years ago

When verifying a pact, we should be able to provide a broker token in source we see

broker_token = kwargs.get('broker_token', None)

 options = {
             [...]
            'broker_token': broker_token,
             [...]
        }
   options.update(self.extract_params(**kwargs))
   success, logs = VerifyWrapper().call_verify(provider=self.provider,
                                                    provider_base_url=self.provider_base_url,
                                                    enable_pending=enable_pending,
                                                    include_wip_pacts_since=include_wip_pacts_since,
                                                    **options)

However the broker token is ignored and when we try to verify with it, it is not sent and we get a 401 unauthorized reply from the broker:

opening connection to cdc-broker-xxx.azurewebsites.net:443...
opened
starting SSL for cdc-broker-xxx.azurewebsites.net:443...
SSL established
<- "GET /pacts/provider/PROVIDER/consumer/CONSUMER/latest HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nHost: cdc-broker-xxx.azurewebsites.net\r\n\r\n"
-> "HTTP/1.1 401 Unauthorized\r\n"

It seems to be related to class VerifyWrapper method call_verify around line 150 where the other options are passed but the token is not.

The example could also use a token.

elliottmurray commented 3 years ago

226 PR resolves it @ngufra. I don't have an example using token. If you want you can check it out and test it locally (feedback would be great!). A release will come this weekend probably.

ngufra commented 3 years ago

I will have someone verify it soon and will post the results. Thanks @elliottmurray !

mefellows commented 3 years ago

Thanks folks!

ngufra commented 3 years ago

The person who is to verify it in a timezone 12 hours 30 ahead of me. They were off yesterday then started verifying but hit another issue so we have not been able to verify it fully yet but we hope to be done by the weekend

ngufra commented 3 years ago

The person who verified reported some issue, then set the environment variable and it worked. Not clear what is the issue if any.

This commit seems to address exactly the issue of the token not being passed so if there is a build only once per week, I would say merge it. Thanks.

ngufra commented 3 years ago

we have verified the fix. Thanks.