Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from upstream repo #2

Merged
merged 73 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
7e2d810
feat: allow mock service host to be configured
bethesque Feb 21, 2019
3b10bbc
chore(release): version 3.0.0
bethesque Feb 21, 2019
ee5cf90
fix: add missing host argument to server spawn
bethesque Mar 7, 2019
8d1de21
chore(release): version 3.0.1
bethesque Mar 7, 2019
037cc88
Improve logging robustness
lextiz Mar 26, 2019
aab8a5d
Update interaction_replay.rb
lextiz Mar 29, 2019
996a9cc
Initial version of the unit test
lextiz Apr 4, 2019
4c5792a
Move the test to appropriate context
lextiz Apr 4, 2019
a30ebe4
Update interaction_replay_spec.rb
lextiz Apr 4, 2019
2695cd8
Update interaction_replay_spec.rb
lextiz Apr 4, 2019
f607a43
Update interaction_replay_spec.rb
lextiz Apr 4, 2019
b86d6df
Update interaction_replay_spec.rb
lextiz Apr 4, 2019
2524cdb
Update interaction_replay.rb
lextiz Apr 9, 2019
b9916a6
Update interaction_replay_spec.rb
lextiz Apr 9, 2019
e3cd33f
Update interaction_replay_spec.rb
lextiz Apr 9, 2019
9264a87
feat: pact-stub-service log level cli opt
YOU54F Apr 30, 2019
84e765f
Merge pull request #109 from YOU54F/feat/stubservicelog
bethesque May 1, 2019
3c26b46
chore(release): version 3.1.0
bethesque May 1, 2019
cfb0259
Merge pull request #104 from lextiz/patch-1
bethesque May 30, 2019
e53f1df
chore(release): version 3.1.1
bethesque May 30, 2019
44ea0c3
feat(skip writing to pact): Use writable_interactions when writing to…
thatguysimon Sep 19, 2019
55e44ff
Add test for #as_json
thatguysimon Sep 20, 2019
ec6ffb9
Add feature spec
thatguysimon Sep 20, 2019
0c04197
Bump pact-support dependency
thatguysimon Sep 30, 2019
d01e846
Fix tests
thatguysimon Sep 30, 2019
080e47a
Merge pull request #113 from thatguysimon/feat/allow-skip-writing-pact
bethesque Oct 10, 2019
ad72df2
chore(release): version 3.2.0
bethesque Oct 15, 2019
88ccd15
CI: Add 2.7 to travis ci
mtchavez Jan 9, 2020
5690037
Merge pull request #1 from mtchavez/chore-show-2.7-failures
mtchavez Jan 9, 2020
4a08fd5
fix: remove apparently unused require for thwait
bethesque Jan 11, 2020
0755bbe
chore(release): version 3.2.1
bethesque Jan 11, 2020
4d60726
Merge pull request #116 from mtchavez/master
bethesque Jan 12, 2020
0ce6bef
feat: log a warning when too many interactions are set on the mock se…
bethesque Jan 15, 2020
c1607f1
chore(release): version 3.3.0
bethesque Jan 15, 2020
67ef5a6
fix: put metadata on the correct decorator
bethesque Jan 16, 2020
ecfe41f
chore(release): version 3.3.1
bethesque Jan 16, 2020
e72670c
chore: remove jruby until somebody shows they're actually using it
bethesque Jan 16, 2020
d7d6e35
chore(release): version 3.4.0
bethesque Jan 16, 2020
76236d8
feat: add token, username and password options to stub service (#118)
mefellows Jan 17, 2020
fb15fa9
chore(release): version 3.5.0
bethesque Jan 17, 2020
a0e24a2
docs: document that you can set the broker token via an env var
bethesque Jan 17, 2020
1d92d1f
chore: separate test and deploy stages
bethesque Jan 17, 2020
54c905d
chore: update .travis.yml
bethesque Jan 17, 2020
811e3c1
chore: update .travis.yml
bethesque Jan 17, 2020
96e2604
test: add expectations to make sure metadata: nil isn't stored in the…
thatguysimon Jan 27, 2020
61bd9d1
feat: add 'Access-Control-Allow-Headers' = true to cors response head…
vandemark Mar 14, 2020
6e3d6c0
chore(release): version 3.6.0
bethesque Mar 14, 2020
4a46c21
fix: fix Ruby 2.7 kwargs warning (#122)
barthez Apr 21, 2020
0e7bc86
chore(release): version 3.6.1
bethesque Apr 21, 2020
54b3f85
fix: update thor dependency (#124)
f1337 Aug 10, 2020
e0e70fa
chore: add github workflow for gem release
bethesque Aug 10, 2020
5294762
chore: disable tests as they're not running properly on github workflow
bethesque Aug 10, 2020
d1878d1
chore(release): version 3.6.2
bethesque Aug 10, 2020
ad54d0b
feat: do not require files until command is executing
bethesque Oct 9, 2020
3338e80
chore: update release workflow [ci-skip]
bethesque Nov 4, 2020
6cd0733
feat: use Pact::Query.parse_string to parse query string
bethesque Nov 12, 2020
e7734d3
chore(deps): update rake
bethesque Nov 13, 2020
4c767ab
docs: update travis badge
bethesque Nov 13, 2020
c372104
chore(release): version 3.7.0
bethesque Nov 13, 2020
6306693
feat: include interaction diffs in verification response
bethesque Feb 25, 2021
656dee1
chore: add tests to github actions
bethesque Feb 25, 2021
7191820
chore: allow workflow dispatch to release
bethesque Feb 25, 2021
b82c4f5
chore(release): version 3.8.0
bethesque Feb 25, 2021
651f580
chore: tests are hanging. try a subset
bethesque Feb 25, 2021
eb5c993
chore: try rspec
bethesque Feb 25, 2021
9239fc6
chore: disabling tests, they hang
bethesque Feb 25, 2021
b06f88f
chore: create issue template
bethesque Mar 11, 2021
ec234a4
feat: pass host into WEBrick options to allow configuration (#128)
mhall58 May 18, 2021
f701447
chore(release): version 3.9.0
bethesque May 18, 2021
e763e58
chore: handle http 2
bethesque May 18, 2021
d26e520
fix: check for nil body rather than falsey body when determining how …
bethesque Jun 3, 2021
5fa1e77
chore(release): version 3.9.1
bethesque Jun 3, 2021
23105ea
Updated from upstream
Feb 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Pre issue-raising checklist

I have already (please mark the applicable with an `x`):

* [ ] Read through the relevant docs at https://docs.pact.io
* [ ] Upgraded to the latest version of the gem
* [ ] Checked the CHANGELOG to see if the issue I am about to raise has been fixed
* [ ] Created an executable example that demonstrates the issue using either a:
* Dockerfile
* Git repository with a Travis or Appveyor (or similar) build

## Software versions

* **OS**: e.g. Mac OSX 10.11.5
* **pact mock service:** eg. v 1.23.0

## Expected behaviour

Please complete.

## Actual behaviour

Please complete.

## Steps to reproduce

Provide a repository, gist or reproducible code snippet so that we can test the problem.

## Relevant log files

Please ensure you set logging to `DEBUG` and attach any relevant log files here (or link from a gist).
59 changes: 59 additions & 0 deletions .github/workflows/release_gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release gem

on:
repository_dispatch:
types:
- release-triggered
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- run: |
gem install bundler -v 2.1
bundle install
# - name: Test
# run: bundle exec rake

release:
needs: test
runs-on: ubuntu-latest
outputs:
gem_name: ${{ steps.release-gem.outputs.gem_name }}
version: ${{ steps.release-gem.outputs.version }}
increment: ${{ steps.release-gem.outputs.increment }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: release-gem
uses: pact-foundation/release-gem@v0.0.11
env:
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
INCREMENT: '${{ github.event.client_payload.increment }}'

notify-gem-released:
needs: release
strategy:
matrix:
repository: [pact-foundation/pact-ruby-cli, pact-foundation/pact-ruby-standalone, pact-foundation/pact_broker-client]
runs-on: ubuntu-latest
steps:
- name: Notify ${{ matrix.repository }} of gem release
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GHTOKENFORPACTCLIRELEASE }}
repository: ${{ matrix.repository }}
event-type: gem-released
client-payload: |
{
"name": "${{ needs.release.outputs.gem_name }}",
"version": "${{ needs.release.outputs.version }}",
"increment": "${{ needs.release.outputs.increment }}"
}
23 changes: 23 additions & 0 deletions .github/workflows/test.yml.hangs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
ruby_version: ["2.2", "2.7"]
experimental: [false]
include:
- ruby_version: "3.0"
experimental: true
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- run: "bundle install"
- run: "bundle exec rspec"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ log
reports
Gemfile.lock
build
.byebug_history

vendor/bundle/
spec/examples.txt
48 changes: 26 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@ language: ruby
sudo: false
rvm:
- 2.2.4
- 2.3.1
- jruby-9.0.5.0
- 2.7.0
env:
global:
secure: FqQ00zkw2heLh5XafaMMv1LXgy+DBxumbcSI3c9iDlRvi4KZQ+n+NqSp/feVEIxSMzA9FmH7ZqTVJmsA5jByrk71WiguU8RZ7NSVzonlLZK0tQ9idwzPtvc38abJwWm3cR9TJlkNxUgQ2iHXLobo4zFSEK/4s0Ob9ddf3x4BUmo=
deploy:
- provider: rubygems
api_key:
secure: EbS3ZRtfqoKrQ3pMGfkx/pqUBVUaEJE+KjUAnAy4h+6BF/6ZsY2H5vtpuDB8ypQ7au1AF2QuEoZsQZkHPngyhJ7Ebtn7XFh0c5WAB+c+mM7bSsNN+ZU176cUgY5PkS9GZ3rBZ/MEW+YyKcUpTmk+ClDx/WmofRjPFSD4n0x350Y=
gem: pact-mock_service
on:
tags: true
repo: pact-foundation/pact-mock_service
- provider: releases
api_key:
secure: O9g/8HkwonBZOthoN+NFCiZQZ+AyakmqMxb/HpuC/ZB79KZ6GTM0brr++Bm08RYLD2MX6+IC8dqA4vkl4D11VEd7TrtxdtS2huScDGTEntzPtRu2WDo4cm6/B9y/erp7Thalt08+V7dqsSBMN5FWf0c001WrG7qpdWs9BElxul8=
file: pkg/*
file_glob: true
skip_cleanup: true
on:
tags: true
repo: pact-foundation/pact-mock_service
after_deploy:
- bundle exec rake generate_release_notes[$TRAVIS_TAG]
- bundle exec rake upload_release_notes[$TRAVIS_REPO_SLUG,$TRAVIS_TAG]
jobs:
include:
- stage: release
rvm: 2.7.0
script: echo "Releasing"
deploy:
- provider: rubygems
api_key:
secure: EbS3ZRtfqoKrQ3pMGfkx/pqUBVUaEJE+KjUAnAy4h+6BF/6ZsY2H5vtpuDB8ypQ7au1AF2QuEoZsQZkHPngyhJ7Ebtn7XFh0c5WAB+c+mM7bSsNN+ZU176cUgY5PkS9GZ3rBZ/MEW+YyKcUpTmk+ClDx/WmofRjPFSD4n0x350Y=
gem: pact-mock_service
on:
tags: true
repo: pact-foundation/pact-mock_service
- provider: releases
api_key:
secure: O9g/8HkwonBZOthoN+NFCiZQZ+AyakmqMxb/HpuC/ZB79KZ6GTM0brr++Bm08RYLD2MX6+IC8dqA4vkl4D11VEd7TrtxdtS2huScDGTEntzPtRu2WDo4cm6/B9y/erp7Thalt08+V7dqsSBMN5FWf0c001WrG7qpdWs9BElxul8=
file: pkg/*
file_glob: true
skip_cleanup: true
on:
tags: true
repo: pact-foundation/pact-mock_service
after_deploy:
- bundle exec rake generate_release_notes[$TRAVIS_TAG]
- bundle exec rake upload_release_notes[$TRAVIS_REPO_SLUG,$TRAVIS_TAG]
127 changes: 127 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,130 @@
<a name="v3.9.1"></a>
### v3.9.1 (2021-06-03)

#### Bug Fixes

* check for nil body rather than falsey body when determining how to render mocked response Fixes: https://github.com/pact-foundation/pact-mock_service/issues/99 ([d26e520](/../../commit/d26e520))

<a name="v3.9.0"></a>
### v3.9.0 (2021-05-17)

#### Features

* pass host into WEBrick options to allow configuration (#128) ([ec234a4](/../../commit/ec234a4))

<a name="v3.8.0"></a>
### v3.8.0 (2021-02-25)

#### Features

* include interaction diffs in verification response ([6306693](/../../commit/6306693))

<a name="v3.7.0"></a>
### v3.7.0 (2020-11-13)

#### Features

* use Pact::Query.parse_string to parse query string ([6cd0733](/../../commit/6cd0733))
* do not require files until command is executing ([ad54d0b](/../../commit/ad54d0b))

<a name="v3.6.2"></a>
### v3.6.2 (2020-08-10)

#### Bug Fixes

* update thor dependency (#124) ([54b3f85](/../../commit/54b3f85))

<a name="v3.6.1"></a>
### v3.6.1 (2020-04-22)


#### Bug Fixes

* fix Ruby 2.7 kwargs warning (#122) ([4a46c21](/../../commit/4a46c21))


<a name="v3.6.0"></a>
### v3.6.0 (2020-03-14)


#### Features

* add 'Access-Control-Allow-Headers' = true to cors response headers (#121) ([61bd9d1](/../../commit/61bd9d1))


<a name="v3.5.0"></a>
### v3.5.0 (2020-01-17)


#### Features

* add token, username and password options to stub service (#118) ([76236d8](/../../commit/76236d8))


<a name="v3.3.1"></a>
### v3.3.1 (2020-01-16)


#### Bug Fixes

* put metadata on the correct decorator ([67ef5a6](/../../commit/67ef5a6))


<a name="v3.3.0"></a>
### v3.3.0 (2020-01-16)


#### Features

* log a warning when too many interactions are set on the mock service at once ([0ce6bef](/../../commit/0ce6bef))


<a name="v3.2.1"></a>
### v3.2.1 (2020-01-11)


#### Bug Fixes

* remove apparently unused require for thwait ([4a08fd5](/../../commit/4a08fd5))


<a name="v3.2.0"></a>
### v3.2.0 (2019-09-19)


#### Features

* **skip writing to pact**
* Use writable_interactions when writing to pact file ([44ea0c3](/../../commit/44ea0c3))


<a name="v3.1.0"></a>
### v3.1.0 (2019-05-01)


#### Features

* pact-stub-service log level cli opt ([9264a87](/../../commit/9264a87))


<a name="v3.0.1"></a>
### v3.0.1 (2019-03-08)


#### Bug Fixes

* add missing host argument to server spawn ([ee5cf90](/../../commit/ee5cf90))


<a name="v3.0.0"></a>
### v3.0.0 (2019-02-21)


#### Features

* allow mock service host to be configured ([7e2d810](/../../commit/7e2d810))


<a name="v2.11.0"></a>
### v2.11.0 (2018-08-28)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Pact Mock and Stub Service

[![Build Status](https://travis-ci.org/pact-foundation/pact-mock_service.svg?branch=master)](https://travis-ci.org/pact-foundation/pact-mock_service)
[![Build Status](https://travis-ci.com/pact-foundation/pact-mock_service.svg?branch=master)](https://travis-ci.com/pact-foundation/pact-mock_service)

This codebase provides the HTTP mock and stub service used by implementations of [Pact][pact]. It is packaged as a gem, and as a standalone executable for Mac OSX and Linux and Windows.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def shutdown
private

def add_cors_header env, response
[response[0], response[1].merge('Access-Control-Allow-Origin' => env.fetch('HTTP_ORIGIN','*')), response[2]]
cors_headers = { 'Access-Control-Allow-Origin' => env.fetch('HTTP_ORIGIN','*'), 'Access-Control-Allow-Credentials' => 'true'}
[response[0], response[1].merge(cors_headers), response[2]]
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/pact/consumer/mock_service/rack_request_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'cgi/core'
require 'pact/consumer_contract/query'

module Pact
module Consumer

Expand All @@ -11,7 +13,7 @@ module RackRequestHelper
}

def params_hash env
CGI::parse env["QUERY_STRING"]
Pact::Query.parse_string(env["QUERY_STRING"])
end

def request_as_hash_from env
Expand Down
15 changes: 6 additions & 9 deletions lib/pact/consumer/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ def ports
end
end

attr_reader :app, :port, :options
attr_reader :app, :host, :port, :options

def initialize(app, port, options = {})
def initialize(app, host, port, options = {})
@app = app
@middleware = Middleware.new(@app)
@server_thread = nil
@host = host
@port = port
@options = options
end
Expand All @@ -52,10 +53,6 @@ def error
@middleware.error
end

def host
"localhost"
end

def responsive?
return false if @server_thread && @server_thread.join(0)
res = get_identity
Expand All @@ -70,7 +67,7 @@ def responsive?

def run_default_server(app, port)
require 'rack/handler/webrick'
Rack::Handler::WEBrick.run(app, webrick_opts) do |server|
Rack::Handler::WEBrick.run(app, **webrick_opts) do |server|
@port = server[:Port]
end
end
Expand All @@ -86,7 +83,7 @@ def get_identity
end

def webrick_opts
opts = { Port: port.nil? ? 0 : port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0) }
opts = { Host: host.nil? ? 'localhost' : host, Port: port.nil? ? 0 : port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0) }
opts.merge!({
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open(options[:sslcert]).read) }) if options[:sslcert]
opts.merge!({
Expand All @@ -96,7 +93,7 @@ def webrick_opts
end

def ssl_opts
{ SSLEnable: true, SSLCertName: [ %w[CN localhost] ] }
{ SSLEnable: true, SSLCertName: [ ["CN", host] ] }
end

def boot
Expand Down
Loading