diff --git a/bin/pact-provider-verifier.cmd b/bin/pact-provider-verifier.cmd new file mode 100644 index 0000000..e3373dd --- /dev/null +++ b/bin/pact-provider-verifier.cmd @@ -0,0 +1,30 @@ +@ruby -x "%~f0" %* +@exit /b %ERRORLEVEL% + +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'pact-provider-verifier' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("pact-provider-verifier", "pact-provider-verifier") diff --git a/examples/test.sh b/examples/test.sh index c7f60c8..aa23f48 100755 --- a/examples/test.sh +++ b/examples/test.sh @@ -14,7 +14,11 @@ res = `pact-provider-verifier --provider-base-url http://localhost:4567 --pact-u puts res puts "=> Shutting down API" -Process.kill 'TERM', pipe.pid +if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{pipe.pid} /f /t >nul 2>&1") +else + Process.kill 'TERM', pipe.pid +end puts "Test exit status: #{res}" puts diff --git a/spec/integration_check_host_spec.rb b/spec/integration_check_host_spec.rb index 8d8fdef..3dc4b44 100644 --- a/spec/integration_check_host_spec.rb +++ b/spec/integration_check_host_spec.rb @@ -1,4 +1,4 @@ -describe "pact-provider-verifier", skip_windows: true do +describe "pact-provider-verifier" do before(:all) do @pipe = IO.popen("bundle exec rackup -p 4569 spec/support/provider-echo-host.ru") sleep 2 @@ -11,6 +11,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index f23916f..c30f900 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -1,7 +1,7 @@ require 'json' require 'fileutils' -describe "pact-provider-verifier", skip_windows: true do +describe "pact-provider-verifier" do before(:all) do @pipe = IO.popen("bundle exec rackup -p 4567 spec/support/config.ru") sleep 2 @@ -77,15 +77,19 @@ end context "running verification with filtered interactions" do - - subject { `PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.100 --provider-base-url http://localhost:4567 --provider-states-setup-url http://localhost:4567/provider-state -v` } + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + env_vars = 'set PACT_DESCRIPTION="Provider state success" && set PACT_PROVIDER_STATE="There is a greeting" && ' + else + env_vars = 'PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" ' + end + subject { `#{env_vars}bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.100 --provider-base-url http://localhost:4567 --provider-states-setup-url http://localhost:4567/provider-state -v` } it "exits with a 0 exit code" do subject expect($?).to eq 0 end - it "the output contains a message indicating that the interactions have been filtered" do + it "the output contains a message indicating that the interactions have been filtered", skip_windows: true do expect(subject).to match /Filtering interactions by.*Provider state success.*There is a greeting/ end end @@ -148,6 +152,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_verify_message_pact_spec.rb b/spec/integration_verify_message_pact_spec.rb index f3bbf1b..06e9aa8 100644 --- a/spec/integration_verify_message_pact_spec.rb +++ b/spec/integration_verify_message_pact_spec.rb @@ -1,6 +1,6 @@ require 'pact/provider_verifier/app' -RSpec.describe "verifying a message pact", skip_windows: true do +RSpec.describe "verifying a message pact" do before(:all) do @pipe = IO.popen("rackup -p 9393 spec/support/message_producer_verifier.ru") @@ -26,6 +26,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_with_custom_header_spec.rb b/spec/integration_with_custom_header_spec.rb index eba4d14..68211b6 100644 --- a/spec/integration_with_custom_header_spec.rb +++ b/spec/integration_with_custom_header_spec.rb @@ -1,4 +1,4 @@ -describe "pact-provider-verifier with basic auth", skip_windows: true do +describe "pact-provider-verifier with basic auth" do before(:all) do @pipe = IO.popen({'USE_BASIC_AUTH' => 'true'}, %w{bundle exec rackup -p 4570 spec/support/config.ru}) sleep 2 @@ -25,6 +25,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_with_custom_middleware_spec.rb b/spec/integration_with_custom_middleware_spec.rb index 34fa3cb..e5bf18a 100644 --- a/spec/integration_with_custom_middleware_spec.rb +++ b/spec/integration_with_custom_middleware_spec.rb @@ -1,4 +1,4 @@ -describe "pact-provider-verifier with basic auth", skip_windows: true do +describe "pact-provider-verifier with basic auth" do before(:all) do @pipe = IO.popen({'USE_BASIC_AUTH' => 'true'}, %w{bundle exec rackup -p 4570 spec/support/config.ru}) sleep 2 @@ -22,6 +22,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_with_monkeypatch_spec.rb b/spec/integration_with_monkeypatch_spec.rb index 4cf984c..b68c401 100644 --- a/spec/integration_with_monkeypatch_spec.rb +++ b/spec/integration_with_monkeypatch_spec.rb @@ -1,4 +1,4 @@ -describe "pact-provider-verifier with monkeypatch", skip_windows: true do +describe "pact-provider-verifier with monkeypatch" do before(:all) do @pipe = IO.popen({}, %w{bundle exec rackup -p 4870 spec/support/config.ru}) sleep 2 @@ -19,6 +19,10 @@ after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_with_prefix_spec.rb b/spec/integration_with_prefix_spec.rb index 171e502..82e03d3 100644 --- a/spec/integration_with_prefix_spec.rb +++ b/spec/integration_with_prefix_spec.rb @@ -1,6 +1,6 @@ require 'json' -describe "pact-provider-verifier with a prefix path in the base URL", skip_windows: true do +describe "pact-provider-verifier with a prefix path in the base URL" do before(:all) do @pipe = IO.popen("bundle exec rackup -p 5837 spec/support/config_with_prefix.ru") sleep 2 @@ -18,6 +18,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/integration_with_ssl_no_verify_spec.rb b/spec/integration_with_ssl_no_verify_spec.rb index ebd9eed..a371e9b 100644 --- a/spec/integration_with_ssl_no_verify_spec.rb +++ b/spec/integration_with_ssl_no_verify_spec.rb @@ -1,19 +1,22 @@ require 'support/provider_with_self_signed_cert' require 'find_a_port' -describe "verifying a provider that uses a self signed certificate", skip_windows: true do +describe "verifying a provider that uses a self signed certificate" do + before(:all) do + @port = FindAPort.available_port + @pipe = IO.popen({}, %W{ruby spec/support/provider_with_self_signed_cert.rb #{@port}}) + sleep 2 + end it "passes because it has SSL verification turned off" do - begin - @port = FindAPort.available_port - @ssl_server_pid = fork do - run_provider_with_self_signed_cert @port - end - sleep 2 - subject = `bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.0 --provider-base-url https://localhost:#{@port} --provider_states_setup_url https://localhost:#{@port}/provider-state -v` - expect(subject).to include "2 interactions, 0 failures" - ensure - Process.kill('KILL', @ssl_server_pid) + subject = `bundle exec bin/pact-provider-verifier ./test/me-they.json -a 1.0.0 --provider-base-url https://localhost:#{@port} --provider_states_setup_url https://localhost:#{@port}/provider-state -v` + expect(subject).to include "2 interactions, 0 failures" + end + after(:all) do + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid end end end diff --git a/spec/integration_with_underscored_header_spec.rb b/spec/integration_with_underscored_header_spec.rb index 501d909..d92e66c 100644 --- a/spec/integration_with_underscored_header_spec.rb +++ b/spec/integration_with_underscored_header_spec.rb @@ -1,6 +1,6 @@ require 'find_a_port' -describe "pact-provider-verifier with an underscored header", skip_windows: true do +describe "pact-provider-verifier with an underscored header" do before(:all) do @port = FindAPort.available_port @pipe = IO.popen({}, %W{ruby spec/support/provider_with_no_rack.rb #{@port}}) @@ -16,6 +16,10 @@ end after(:all) do - Process.kill 'KILL', @pipe.pid + if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{@pipe.pid} /f /t >nul 2>&1") + else + Process.kill 'KILL', @pipe.pid + end end end diff --git a/spec/support/provider_with_self_signed_cert.rb b/spec/support/provider_with_self_signed_cert.rb index b969a98..1bc9366 100644 --- a/spec/support/provider_with_self_signed_cert.rb +++ b/spec/support/provider_with_self_signed_cert.rb @@ -1,7 +1,7 @@ require_relative 'provider' def run_provider_with_self_signed_cert port - trap 'INT' do @server.shutdown end + # trap 'INT' do @server.shutdown end require 'rack' require 'rack/handler/webrick' require 'webrick/https' @@ -21,5 +21,6 @@ def run_provider_with_self_signed_cert port end if __FILE__== $0 - run_provider_with_self_signed_cert 4568 + port = ARGV[0] ? ARGV[0].to_i : 4568 + run_provider_with_self_signed_cert port end diff --git a/test/test.sh b/test/test.sh index d3e9397..aade162 100755 --- a/test/test.sh +++ b/test/test.sh @@ -20,7 +20,11 @@ puts res code = $? puts "=> Shutting down API" -Process.kill 'TERM', pipe.pid +if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ + system("taskkill /im #{pipe.pid} /f /t >nul 2>&1") +else + Process.kill 'TERM', pipe.pid +end puts puts