Hello, I have just signed up for pactflow and crea...
# pactflow
g
Hello, I have just signed up for pactflow and created an account. Now I would like to publish the pact file generated by the consumer to my pactflow account. I have the authentication token with me. My question is how to publish the pact file to pactflow.io on Windows/.Net core. I have seen this example, however this is not working. any ideas on this?
$Headers = @{
Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1")))" } $res = Invoke-WebRequest -Uri "https://test.pactflow.io/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/version/1.0.0" -Headers $Headers -Method Put -InFile .\matching_service-animal_profile_service.json -ContentType "application/json"
m
The advice is to use https://docs.pact.io/implementation_guides/cli. I don’t believe any official docs still point to a manual powershell publish.
g
thanks Matt. The links on the above page pointed me to Pact ruby standalone executable at https://github.com/pact-foundation/pact-ruby-standalone/releases. I did download pact-1.89.02-rc1-win32 zip, unzipped into local folder. Tried to run pactflow.bat from bin folder command prompt with this:
Copy code
pactflow publish-provider-contract C:\pact-workshop-dotnet-core-v3\pacts\ApiClient-ProductService.json --broker-token=myAuthenticationtoken --broker-base-url=<https://mydomain.pactflow.io> --provider ProductService --provider-app-version 1.0 --branch main --content-type application/json  --verification-exit-code=0
I am getting this error
I did also installed the certificate and set the environment variable to the path as explain here https://docs.pact.io/pact_broker/advanced_topics/using-tls#extracting-a-copy-of-the-certificate-from-a-running-pact-broker, however I am still getting the same error
m
hmm you shouldn’t need to install custom certificates - it should work out of the box
Can you please share verbose logs? One guess would be an intermediate proxy presenting an invalid certificate
g
Please find the logs:
Copy code
opening connection to <http://mydomain.pactflow.io:443|mydomain.pactflow.io:443>...
opened
starting SSL for <http://mydomain.pactflow.io:443|mydomain.pactflow.io:443>...
Conn close because of connect error SSL_connect returned=1 errno=0 state=error: certificate verify failed
OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 state=error: certificate verify failed
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/ruby/lib/ruby/2.4.0/net/protocol.rb:44:in `connect_nonblock'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/ruby/lib/ruby/2.4.0/net/protocol.rb:44:in `ssl_socket_connect'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/ruby/lib/ruby/2.4.0/net/http.rb:948:in `connect'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/ruby/lib/ruby/2.4.0/net/http.rb:887:in `do_start'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/ruby/lib/ruby/2.4.0/net/http.rb:876:in `start'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/http_client.rb:79:in `block in perform_request'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/http_client.rb:93:in `until_truthy_or_max_times'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/http_client.rb:64:in `perform_request'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/http_client.rb:25:in `get'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/link.rb:41:in `get'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal/link.rb:45:in `get!'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/hal_client_methods.rb:24:in `index_resource'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/versions/create.rb:48:in `branch_versions_supported?'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/versions/create.rb:11:in `do_call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/base_command.rb:25:in `call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/base_command.rb:13:in `call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pactflow/client/provider_contracts/publish.rb:37:in `create_branch_version_and_tags'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pactflow/client/provider_contracts/publish.rb:24:in `do_call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/base_command.rb:25:in `call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/base_command.rb:13:in `call'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pactflow/client/cli/provider_contract_commands.rb:36:in `publish_provider_contract'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/vendor/ruby/2.4.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start'
C:/Users/testuser/Downloads/pact-1.89.02-rc1-win32/pact/lib/app/pactflow.rb:28:in `<main>'
@Matt (pactflow.io / pact-js / pact-go) you might be correct. I was trying to connect through my company laptop and getting that connection error. I did try on my personal laptop, and it was successful. So something on my company laptop is stopping the successful connection. I have two questions if you could help 1. Any idea what's stopping me to make a successful SSL connection on my company laptop. Ultimately this is the environment we would be running our tests 2. And in Pactflow, I see this . There is no information about consumer. When I checked "pactflow publish-provider-contract", it has no options to provide information about consumer. Is there another command to publish the contract generated by the consumer to pactflow?
🙌 1
m
that’s great news. Now to isolate your corporate environment issue: 1. There are likely two paths to success. 1 set or unset the
http_proxy
and
https_proxy
environment variables. If you don’t know what these are, find somebody in your organisation that does. They’ll be able to advise what to do with them. If not this, you’ll need to get a copy of the intermediate proxy SSL certificate and get that into your trust store (the docs above you linked are the right ones). This is unlikely the problem though, so start with the env vars 2. You don’t publish the consumer with your provider contract - each of your consumers publish contracts, and when they do, there will be an integration in the left nav for each consumer that says
ProductService
is a provider
g
thanks Matt . I will check with IT support team on proxy environment variables. And just be clear on point 2), you said each of my consumer should publish the contract. How do I do this through pactflow?
m
Read the docs 😉
Have you read the bi-directional guide and workshops?
g
checking...
Ok, some progress made. As described here I did use pact-broker publish command to publish the pact file generated by the consumer
And it did update status on Pactflow . I think now I need to perform the verification by the provider and upload the results to the pactflow
1