From ed4418993a8e658148a0064d10307bcc25b43646 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 29 Nov 2024 16:07:19 +0000 Subject: [PATCH] fix: add HTTPS_HOST header if invoking a Sinatra app affects sinatra users 4.1.x post https://github.com/sinatra/sinatra/pull/2053 --- example/animal-service/Gemfile.lock | 71 +++++++++++++---------------- example/zoo-app/Gemfile.lock | 46 ++++++++----------- lib/pact/provider/request.rb | 1 + 3 files changed, 51 insertions(+), 67 deletions(-) diff --git a/example/animal-service/Gemfile.lock b/example/animal-service/Gemfile.lock index 9f0e12dc..0287c371 100644 --- a/example/animal-service/Gemfile.lock +++ b/example/animal-service/Gemfile.lock @@ -1,14 +1,13 @@ PATH remote: ../.. specs: - pact (1.64.0) + pact (1.65.3) pact-mock_service (~> 3.0, >= 3.3.1) pact-support (~> 1.16, >= 1.16.9) rack-test (>= 0.6.3, < 3.0.0) + rainbow (~> 3.1) rspec (~> 3.0) - term-ansicolor (~> 1.7) thor (>= 0.20, < 2.0) - webrick (~> 1.8) GEM remote: https://rubygems.org/ @@ -21,14 +20,16 @@ GEM expgen (0.1.1) parslet find_a_port (1.0.1) - json (2.7.2) + json (2.8.2) + jsonpath (1.1.5) + multi_json + logger (1.6.1) method_source (1.1.0) - mini_portile2 (2.8.7) - mize (0.4.1) - protocol (~> 2.0) - mustermann (3.0.0) + mini_portile2 (2.8.8) + multi_json (1.15.0) + mustermann (3.0.3) ruby2_keywords (~> 0.0.1) - pact-mock_service (3.12.2) + pact-mock_service (3.12.3) find_a_port (~> 1.0.1) json pact-support (~> 1.16, >= 1.16.4) @@ -37,69 +38,61 @@ GEM rspec (>= 2.14) thor (>= 0.19, < 2.0) webrick (~> 1.8) - pact-support (1.20.0) + pact-support (1.21.0) awesome_print (~> 1.9) diff-lcs (~> 1.5) expgen (~> 0.1) + jsonpath (~> 1.0) rainbow (~> 3.1.1) + string_pattern (~> 2.0) parslet (2.0.0) - protocol (2.0.0) - ruby_parser (~> 3.0) - pry (0.14.2) + pry (0.15.0) coderay (~> 1.1) method_source (~> 1.0) - racc (1.8.0) - rack (3.1.7) - rack-protection (4.0.0) + rack (3.1.8) + rack-protection (4.1.1) base64 (>= 0.1.0) + logger (>= 1.6.0) rack (>= 3.0.0, < 4) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) rainbow (3.1.1) rake (13.2.1) + regexp_parser (2.9.2) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) ruby2_keywords (0.0.5) - ruby_parser (3.21.0) - racc (~> 1.5) - sexp_processor (~> 4.16) - sequel (5.81.0) + sequel (5.86.0) bigdecimal - sexp_processor (4.17.1) - sinatra (4.0.0) + sinatra (4.1.1) + logger (>= 1.6.0) mustermann (~> 3.0) rack (>= 3.0.0, < 4) - rack-protection (= 4.0.0) + rack-protection (= 4.1.1) rack-session (>= 2.0.0, < 3) tilt (~> 2.0) - sqlite3 (2.0.2) + sqlite3 (2.3.1) mini_portile2 (~> 2.8.0) - sync (0.5.0) - term-ansicolor (1.10.2) - mize - tins (~> 1.0) - thor (1.3.1) - tilt (2.3.0) - tins (1.33.0) - bigdecimal - sync - webrick (1.8.1) + string_pattern (2.3.0) + regexp_parser (~> 2.5, >= 2.5.0) + thor (1.3.2) + tilt (2.4.0) + webrick (1.9.0) PLATFORMS ruby diff --git a/example/zoo-app/Gemfile.lock b/example/zoo-app/Gemfile.lock index b4237fd7..a8c79cfa 100644 --- a/example/zoo-app/Gemfile.lock +++ b/example/zoo-app/Gemfile.lock @@ -1,14 +1,13 @@ PATH remote: ../.. specs: - pact (1.64.0) + pact (1.65.3) pact-mock_service (~> 3.0, >= 3.3.1) pact-support (~> 1.16, >= 1.16.9) rack-test (>= 0.6.3, < 3.0.0) + rainbow (~> 3.1) rspec (~> 3.0) - term-ansicolor (~> 1.7) thor (>= 0.20, < 2.0) - webrick (~> 1.8) GEM remote: https://rubygems.org/ @@ -27,14 +26,13 @@ GEM csv mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - json (2.7.2) + json (2.8.2) method_source (1.1.0) mini_mime (1.1.5) - mize (0.4.1) - protocol (~> 2.0) multi_xml (0.7.1) bigdecimal (~> 3.1) - pact-mock_service (3.12.2) + ostruct (0.6.1) + pact-mock_service (3.12.3) find_a_port (~> 1.0.1) json pact-support (~> 1.16, >= 1.16.4) @@ -43,61 +41,53 @@ GEM rspec (>= 2.14) thor (>= 0.19, < 2.0) webrick (~> 1.8) - pact-support (1.20.0) + pact-support (1.20.2) awesome_print (~> 1.9) diff-lcs (~> 1.5) expgen (~> 0.1) rainbow (~> 3.1.1) - pact_broker-client (1.75.3) + pact_broker-client (1.77.0) base64 (~> 0.2) dig_rb (~> 1.0) httparty (>= 0.21.0, < 1.0.0) + ostruct rake (~> 13.0) table_print (~> 1.5) term-ansicolor (~> 1.7) thor (>= 0.20, < 2.0) parslet (2.0.0) - protocol (2.0.0) - ruby_parser (~> 3.0) - pry (0.14.2) + pry (0.15.0) coderay (~> 1.1) method_source (~> 1.0) - racc (1.8.0) - rack (3.1.7) + rack (3.1.8) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) rainbow (3.1.1) rake (13.2.1) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - ruby_parser (3.21.0) - racc (~> 1.5) - sexp_processor (~> 4.16) - sexp_processor (4.17.1) sync (0.5.0) table_print (1.5.7) - term-ansicolor (1.10.2) - mize + term-ansicolor (1.11.2) tins (~> 1.0) - thor (1.3.1) - tins (1.33.0) + thor (1.3.2) + tins (1.37.0) bigdecimal sync - webrick (1.8.1) + webrick (1.9.0) PLATFORMS ruby diff --git a/lib/pact/provider/request.rb b/lib/pact/provider/request.rb index ad4b1998..98e3acd1 100644 --- a/lib/pact/provider/request.rb +++ b/lib/pact/provider/request.rb @@ -33,6 +33,7 @@ def body def headers request_headers = {} + request_headers.merge!('HTTP_HOST' => 'localhost') if defined?(Sinatra) return request_headers if expected_request.headers.is_a?(Pact::NullExpectation) expected_request.headers.each do |key, value| request_headers[rack_request_header_for(key)] = Pact::Reification.from_term(value)