pact-foundation / pact-net

.NET 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.
https://pact.io
MIT License
842 stars 231 forks source link

Error when publishing on pactflow from windows #242

Closed opuech closed 4 years ago

opuech commented 4 years ago

Hi,

Step to reproduce :

How can i fix this issue ?

Thank you !

opuech commented 4 years ago

I don't know how to convert on windows bash your script : openssl req -x509 -out localhost.crt -keyout localhost.key \ -newkey rsa:2048 -nodes -sha256 \ -subj '/CN=localhost' -extensions EXT -days 365 -config <( \ printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

opuech commented 4 years ago

It could be usefull to have exemple of powershell script :

bethesque commented 4 years ago

You could try using the pact-ruby-standalone (which is the underlying CLI that pact-net uses) to publish the pacts. It works on windows. https://github.com/pact-foundation/pact-ruby-standalone/releases

Another other alternative is to use the docker container https://hub.docker.com/repository/docker/pactfoundation/pact-cli

to extract consumer Pact file in order to put it on an available directory file for the provider

Can I ask why you want do you need to do this? The verifier pulls pacts from the Pact Broker directly.

mefellows commented 4 years ago

Hi Olivier,

Thanks for the detailed post.

As discussed in the support ticket, I think you'll need to add the certificate from https://olivier.pact.dius.com.au (which is an AWS CA issued certificate, fairy recent) to your trust store. I'm not a Windows expert, but the following articles looks promising:

As for being able to download Pacts, as Beth noted, you are best using the verifier with the PactBroker option (just pointed to your broker, not an individual contract) as it will automatically pull contracts, verify them, publish the results etc. etc. If you pulled the contracts down manually and verified them one by one, you won't be able to do a lot of the magic that Pact lets you do.

I'll add the PowerShell script to examples though.

opuech commented 4 years ago

You could try using the pact-ruby-standalone (which is the underlying CLI that pact-net uses) to publish the pacts. It works on windows. https://github.com/pact-foundation/pact-ruby-standalone/releases

Another other alternative is to use the docker container https://hub.docker.com/repository/docker/pactfoundation/pact-cli

to extract consumer Pact file in order to put it on an available directory file for the provider

Can I ask why you want do you need to do this? The verifier pulls pacts from the Pact Broker directly.

Because the interactions with Powershell work very well without any configuration, and because it is better for adoption to communicate about powershell than ruby with a complex configuration. My public will be a public of windows users / developers.

opuech commented 4 years ago

Hi Olivier,

Thanks for the detailed post.

As discussed in the support ticket, I think you'll need to add the certificate from https://olivier.pact.dius.com.au (which is an AWS CA issued certificate, fairy recent) to your trust store. I'm not a Windows expert, but the following articles looks promising:

As for being able to download Pacts, as Beth noted, you are best using the verifier with the PactBroker option (just pointed to your broker, not an individual contract) as it will automatically pull contracts, verify them, publish the results etc. etc. If you pulled the contracts down manually and verified them one by one, you won't be able to do a lot of the magic that Pact lets you do.

I'll add the PowerShell script to examples though.

Thank you Matt, What is the better way to start a ruby irb prompt with my configuration ? Start a new ruby irb prompt, and try the following:$irb>require 'open-uri'$irb>open('https://www.gmail.com')

bethesque commented 4 years ago

Hi Oliver,

The Ruby that is used in pact-net is packaged along with the Pact code, so it's not using your system ruby. Running irb for your own system ruby will not allow you to reproduce any issues you might be seeing with your Pact code.

You can download the pact-ruby-standalone for windows here https://github.com/pact-foundation/pact-ruby-standalone/releases If you dig around inside the folders, you'll find an irb executable. You can try running that. I believe it shows a few errors, it from memory, it does run.

because it is better for adoption to communicate about powershell than ruby with a complex configuration

You don't see any of the Ruby - it's all wrapped with Pact.NET, or docker command line arguments.

You're going to miss out on a lot of new features (pending pacts, wip pacts) by using the direct URLs.

It may be that the windows certificates bundled with the standalone are not working with the certificates on Pactflow - it would be strange however, because we haven't noticed any issues on any of the other platforms. Here's an issue that might be relevant. https://github.com/pact-foundation/pact-ruby-standalone/issues/30

opuech commented 4 years ago

Thanks Beth,

Thank you for your help !

bethesque commented 4 years ago

Sorry, I'm unclear, did copying the certificate file in fix it or not?

bethesque commented 4 years ago

Have you tried using the c# publisher? https://github.com/pact-foundation/pact-net#using-the-c-client

opuech commented 4 years ago

Hello Beth,

I copied the certificate file and the problem still persists. Maybe a "ruby irb prompt" could help to diagnose ($irb>open('https://olivier.pact.dius.com.au'))

On Tue, May 12, 2020 at 8:22 PM Beth Skurrie notifications@github.com wrote:

Sorry, I'm unclear, did copying the certificate file in fix it or not?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pact-foundation/pact-net/issues/242#issuecomment-627669273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEO7PLVOD436FDNNCOVCN6LRRHR45ANCNFSM4M4HIXNQ .

opuech commented 4 years ago

Have you tried using the c# publisher? https://github.com/pact-foundation/pact-net#using-the-c-client

Publishing the pact with Powershell is ok, not with c#, not with command line tool. The best way coul be to use System.Net.Http.HttpClient for interaction with PactBroker. Is it possible ?

opuech commented 4 years ago

I think it is a windows firewall problem :

Erreur pare feur   ruby

(i restarted from stratch, and i remembered that i already had this message )

mefellows commented 4 years ago

Interesting. So if you can't put exclusions in for the Ruby process to publish, you're going to have to do one of a few things:

  1. Stick with Powershell
  2. Write a full C# wrapper to do it

@bethesque this is going to affect the publishing of the pact and the verification results, correct?

@neilcampbell would you support a PR? @opuech has indicated he's willing to help out

bethesque commented 4 years ago

I'd rather not have another completely separate publishing implementation unless we can avoid it. Can you whitelist the Ruby process?

opuech commented 4 years ago

I'd rather not have another completely separate publishing implementation unless we can avoid it. Can you whitelist the Ruby process?

I think it will be difficult (my company policy) but it is an option.

mefellows commented 4 years ago

Whitelisting would be the best option, otherwise you would have a reasonable amount of work ahead of you.

The other option would be getting the Rust implementation in, and adding support for publishing and all of this stuff - that would at least be strategic, but not something that would be quick or easy.

opuech commented 4 years ago

I deployed successfully a pact-broker on a k8s cluster - http mode - no security; no problem to publish to this broker. Whitelisting the Ruby process is still an option to go further. Thank you for your help, i will close the ticket.