pact 1.43.0 → 1.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +20 -0
- data/lib/pact/consumer/configuration/dsl.rb +0 -1
- data/lib/pact/hal/http_client.rb +4 -3
- data/lib/pact/hal/link.rb +15 -9
- data/lib/pact/hal/non_json_entity.rb +28 -0
- data/lib/pact/provider/configuration/dsl.rb +6 -1
- data/lib/pact/provider/configuration/message_provider_dsl.rb +32 -0
- data/lib/pact/provider/help/content.rb +4 -4
- data/lib/pact/provider/help/pact_diff.rb +10 -34
- data/lib/pact/provider/help/write.rb +6 -7
- data/lib/pact/provider/pact_source.rb +9 -0
- data/lib/pact/provider/pact_spec_runner.rb +1 -1
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +2 -1
- metadata +25 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f3a5830ca87a36c72ef7f4642781ec9b3ed8fc0c9b7ffce35201629a17da27f1
|
|
4
|
+
data.tar.gz: baaac2acf2cf8e5a25b2507e7d85a4005f217982f5145c3377c27b4148d0c6f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 055dca7b6c709c9ee90c893c8ab9c4684f142d3f742db093480131584a98079ca7bed669f521aedadbacf38cfd9c9161ab6cbd3c8d36118402407d33a0a7ccfc
|
|
7
|
+
data.tar.gz: f39ffea4a82a4608a5c6b86c5cd5ed868489ffec975698da02633804374526083aae727d24fcd9cbf462ca36186c23e6c5793b45557fc6aaf5b15c2b2e4ff859
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
<a name="v1.44.0"></a>
|
|
2
|
+
### v1.44.0 (2020-01-16)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* **message pact**
|
|
8
|
+
* add DSL for configuring Message Pact verifications ([a5181b6](/../../commit/a5181b6))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<a name="v1.43.1"></a>
|
|
12
|
+
### v1.43.1 (2020-01-11)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* use configured credentials when fetching the diff with previous version ([b9deb09](/../../commit/b9deb09))
|
|
18
|
+
* use URI.open instead of Kernel.open ([7b3ea81](/../../commit/7b3ea81))
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
<a name="v1.43.0"></a>
|
|
2
22
|
### v1.43.0 (2020-01-11)
|
|
3
23
|
|
data/lib/pact/hal/http_client.rb
CHANGED
|
@@ -36,12 +36,9 @@ module Pact
|
|
|
36
36
|
|
|
37
37
|
def create_request uri, http_method, body = nil, headers = {}
|
|
38
38
|
request = Net::HTTP.const_get(http_method).new(uri.request_uri)
|
|
39
|
-
request['Content-Type'] = "application/json" if ['Post', 'Put', 'Patch'].include?(http_method)
|
|
40
|
-
request['Accept'] = "application/hal+json"
|
|
41
39
|
headers.each do | key, value |
|
|
42
40
|
request[key] = value
|
|
43
41
|
end
|
|
44
|
-
|
|
45
42
|
request.body = body if body
|
|
46
43
|
request.basic_auth username, password if username
|
|
47
44
|
request['Authorization'] = "Bearer #{token}" if token
|
|
@@ -85,6 +82,10 @@ module Pact
|
|
|
85
82
|
def success?
|
|
86
83
|
__getobj__().code.start_with?("2")
|
|
87
84
|
end
|
|
85
|
+
|
|
86
|
+
def json?
|
|
87
|
+
self['content-type'] && self['content-type'] =~ /json/
|
|
88
|
+
end
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
end
|
data/lib/pact/hal/link.rb
CHANGED
|
@@ -23,14 +23,14 @@ module Pact
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def run(payload = nil)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
case request_method
|
|
27
|
+
when :get
|
|
28
|
+
get(payload)
|
|
29
|
+
when :put
|
|
30
|
+
put(payload)
|
|
31
|
+
when :post
|
|
32
|
+
post(payload)
|
|
33
|
+
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def title_or_name
|
|
@@ -89,8 +89,14 @@ module Pact
|
|
|
89
89
|
|
|
90
90
|
def wrap_response(href, http_response)
|
|
91
91
|
require 'pact/hal/entity' # avoid circular reference
|
|
92
|
+
require 'pact/hal/non_json_entity'
|
|
93
|
+
|
|
92
94
|
if http_response.success?
|
|
93
|
-
|
|
95
|
+
if http_response.json?
|
|
96
|
+
Entity.new(href, http_response.body, @http_client, http_response)
|
|
97
|
+
else
|
|
98
|
+
NonJsonEntity.new(href, http_response.raw_body, @http_client, http_response)
|
|
99
|
+
end
|
|
94
100
|
else
|
|
95
101
|
ErrorEntity.new(href, http_response.raw_body, @http_client, http_response)
|
|
96
102
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Pact
|
|
2
|
+
module Hal
|
|
3
|
+
class NonJsonEntity
|
|
4
|
+
def initialize(href, body, http_client, response = nil)
|
|
5
|
+
@href = href
|
|
6
|
+
@body = body
|
|
7
|
+
@client = http_client
|
|
8
|
+
@response = response
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def success?
|
|
12
|
+
true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def response
|
|
16
|
+
@response
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def body
|
|
20
|
+
@body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def assert_success!
|
|
24
|
+
self
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'pact/provider/configuration/service_provider_dsl'
|
|
2
|
+
require 'pact/provider/configuration/message_provider_dsl'
|
|
2
3
|
|
|
3
4
|
module Pact
|
|
4
5
|
|
|
@@ -8,6 +9,10 @@ module Pact
|
|
|
8
9
|
def service_provider name, &block
|
|
9
10
|
Configuration::ServiceProviderDSL.build(name, &block)
|
|
10
11
|
end
|
|
12
|
+
|
|
13
|
+
def message_provider name, &block
|
|
14
|
+
Configuration::MessageProviderDSL.build(name, &block)
|
|
15
|
+
end
|
|
11
16
|
end
|
|
12
17
|
end
|
|
13
|
-
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'pact/provider/configuration/service_provider_dsl'
|
|
2
|
+
|
|
3
|
+
module Pact
|
|
4
|
+
module Provider
|
|
5
|
+
module Configuration
|
|
6
|
+
class MessageProviderDSL < ServiceProviderDSL
|
|
7
|
+
class RackToMessageAdapter
|
|
8
|
+
def initialize(message_builder)
|
|
9
|
+
@message_builder = message_builder
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call(env)
|
|
13
|
+
request_body_json = JSON.parse(env['rack.input'].read)
|
|
14
|
+
contents = @message_builder.call(request_body_json['description'])
|
|
15
|
+
[200, {"Content-Type" => "application/json"}, [{ contents: contents }.to_json]]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize name
|
|
20
|
+
super
|
|
21
|
+
@mapper_block = lambda { |args| }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
dsl do
|
|
25
|
+
def builder &block
|
|
26
|
+
self.app_block = lambda { RackToMessageAdapter.new(block) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -5,8 +5,8 @@ module Pact
|
|
|
5
5
|
module Help
|
|
6
6
|
class Content
|
|
7
7
|
|
|
8
|
-
def initialize
|
|
9
|
-
@
|
|
8
|
+
def initialize pact_sources
|
|
9
|
+
@pact_sources = pact_sources
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def text
|
|
@@ -15,7 +15,7 @@ module Pact
|
|
|
15
15
|
|
|
16
16
|
private
|
|
17
17
|
|
|
18
|
-
attr_reader :
|
|
18
|
+
attr_reader :pact_sources
|
|
19
19
|
|
|
20
20
|
def help_text
|
|
21
21
|
temp_dir = Pact.configuration.tmp_dir
|
|
@@ -28,7 +28,7 @@ module Pact
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def pact_diffs
|
|
31
|
-
|
|
31
|
+
pact_sources.collect do | pact_json |
|
|
32
32
|
PactDiff.call(pact_json)
|
|
33
33
|
end.compact.join("\n")
|
|
34
34
|
end
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
+
require 'pact/hal/entity'
|
|
2
|
+
|
|
1
3
|
module Pact
|
|
2
4
|
module Provider
|
|
3
5
|
module Help
|
|
4
|
-
|
|
5
6
|
class PactDiff
|
|
6
|
-
|
|
7
7
|
class PrintPactDiffError < StandardError; end
|
|
8
8
|
|
|
9
|
-
attr_reader :
|
|
9
|
+
attr_reader :pact_source, :output
|
|
10
10
|
|
|
11
|
-
def initialize
|
|
12
|
-
@
|
|
11
|
+
def initialize pact_source
|
|
12
|
+
@pact_source = pact_source
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.call
|
|
16
|
-
new(
|
|
15
|
+
def self.call pact_source
|
|
16
|
+
new(pact_source).call
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def call
|
|
20
20
|
begin
|
|
21
|
-
|
|
22
|
-
header + "\n" + get_diff
|
|
23
|
-
end
|
|
21
|
+
header + "\n" + get_diff
|
|
24
22
|
rescue PrintPactDiffError => e
|
|
25
23
|
return e.message
|
|
26
24
|
end
|
|
@@ -32,35 +30,13 @@ module Pact
|
|
|
32
30
|
"The following changes have been made since the previous distinct version of this pact, and may be responsible for verification failure:\n"
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
def pact_hash
|
|
36
|
-
@pact_hash ||= json_load(pact_json)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def links
|
|
40
|
-
pact_hash['_links'] || pact_hash['links']
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def diff_rel
|
|
44
|
-
return nil unless links
|
|
45
|
-
key = links.keys.find { | key | key =~ /diff/ && key =~ /distinct/ && key =~ /previous/}
|
|
46
|
-
key ? links[key] : nil
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def diff_url
|
|
50
|
-
diff_rel['href']
|
|
51
|
-
end
|
|
52
|
-
|
|
53
33
|
def get_diff
|
|
54
34
|
begin
|
|
55
|
-
|
|
35
|
+
pact_source.hal_entity._link!("pb:diff-previous-distinct").get!(nil, "Accept" => "text/plain").body
|
|
56
36
|
rescue StandardError => e
|
|
57
|
-
raise PrintPactDiffError.new("Tried to retrieve diff with previous pact
|
|
37
|
+
raise PrintPactDiffError.new("Tried to retrieve diff with previous pact, but received error #{e.class} #{e.message}.")
|
|
58
38
|
end
|
|
59
39
|
end
|
|
60
|
-
|
|
61
|
-
def json_load json
|
|
62
|
-
JSON.load(json, nil, { max_nesting: 50 })
|
|
63
|
-
end
|
|
64
40
|
end
|
|
65
41
|
end
|
|
66
42
|
end
|
|
@@ -9,12 +9,12 @@ module Pact
|
|
|
9
9
|
|
|
10
10
|
HELP_FILE_NAME = 'help.md'
|
|
11
11
|
|
|
12
|
-
def self.call
|
|
13
|
-
new(
|
|
12
|
+
def self.call pact_sources, reports_dir = Pact.configuration.reports_dir
|
|
13
|
+
new(pact_sources, reports_dir).call
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def initialize
|
|
17
|
-
@
|
|
16
|
+
def initialize pact_sources, reports_dir
|
|
17
|
+
@pact_sources = pact_sources
|
|
18
18
|
@reports_dir = File.expand_path(reports_dir)
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -25,7 +25,7 @@ module Pact
|
|
|
25
25
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
|
-
attr_reader :reports_dir, :
|
|
28
|
+
attr_reader :reports_dir, :pact_sources
|
|
29
29
|
|
|
30
30
|
def clean_reports_dir
|
|
31
31
|
raise "Cleaning report dir #{reports_dir} would delete project!" if reports_dir_contains_pwd
|
|
@@ -46,9 +46,8 @@ module Pact
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def help_text
|
|
49
|
-
Content.new(
|
|
49
|
+
Content.new(pact_sources).text
|
|
50
50
|
end
|
|
51
|
-
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
53
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'pact/consumer_contract/pact_file'
|
|
2
|
+
require 'pact/hal/http_client'
|
|
3
|
+
require 'pact/hal/entity'
|
|
2
4
|
|
|
3
5
|
module Pact
|
|
4
6
|
module Provider
|
|
@@ -17,6 +19,13 @@ module Pact
|
|
|
17
19
|
def pact_hash
|
|
18
20
|
@pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 })
|
|
19
21
|
end
|
|
22
|
+
|
|
23
|
+
def hal_entity
|
|
24
|
+
http_client_keys = [:username, :password, :token]
|
|
25
|
+
http_client_options = uri.options.reject{ |k, _| !http_client_keys.include?(k) }
|
|
26
|
+
http_client = Pact::Hal::HttpClient.new(http_client_options.merge(verbose: true))
|
|
27
|
+
Pact::Hal::Entity.new(uri, pact_hash, http_client)
|
|
28
|
+
end
|
|
20
29
|
end
|
|
21
30
|
end
|
|
22
31
|
end
|
|
@@ -80,7 +80,7 @@ module Pact
|
|
|
80
80
|
executing_with_ruby = executing_with_ruby?
|
|
81
81
|
|
|
82
82
|
config.after(:suite) do | suite |
|
|
83
|
-
Pact::Provider::Help::Write.call(
|
|
83
|
+
Pact::Provider::Help::Write.call(Pact.provider_world.pact_sources) if executing_with_ruby
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
|
|
|
33
33
|
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
|
|
34
34
|
|
|
35
35
|
gem.add_runtime_dependency 'pact-support', '~> 1.9'
|
|
36
|
-
gem.add_runtime_dependency 'pact-mock_service', '~> 3.0'
|
|
36
|
+
gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
|
|
37
37
|
|
|
38
38
|
gem.add_development_dependency 'rake', '~> 10.0.3'
|
|
39
39
|
gem.add_development_dependency 'webmock', '~> 3.0'
|
|
@@ -45,4 +45,5 @@ Gem::Specification.new do |gem|
|
|
|
45
45
|
gem.add_development_dependency 'appraisal', '~> 2.2'
|
|
46
46
|
gem.add_development_dependency 'conventional-changelog', '~> 1.3'
|
|
47
47
|
gem.add_development_dependency 'bump', '~> 0.5'
|
|
48
|
+
gem.add_development_dependency 'pact-message'
|
|
48
49
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pact
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.44.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Fraser
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2020-01-
|
|
15
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: rspec
|
|
@@ -111,6 +111,9 @@ dependencies:
|
|
|
111
111
|
- - "~>"
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
113
|
version: '3.0'
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 3.3.1
|
|
114
117
|
type: :runtime
|
|
115
118
|
prerelease: false
|
|
116
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -118,6 +121,9 @@ dependencies:
|
|
|
118
121
|
- - "~>"
|
|
119
122
|
- !ruby/object:Gem::Version
|
|
120
123
|
version: '3.0'
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: 3.3.1
|
|
121
127
|
- !ruby/object:Gem::Dependency
|
|
122
128
|
name: rake
|
|
123
129
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -258,6 +264,20 @@ dependencies:
|
|
|
258
264
|
- - "~>"
|
|
259
265
|
- !ruby/object:Gem::Version
|
|
260
266
|
version: '0.5'
|
|
267
|
+
- !ruby/object:Gem::Dependency
|
|
268
|
+
name: pact-message
|
|
269
|
+
requirement: !ruby/object:Gem::Requirement
|
|
270
|
+
requirements:
|
|
271
|
+
- - ">="
|
|
272
|
+
- !ruby/object:Gem::Version
|
|
273
|
+
version: '0'
|
|
274
|
+
type: :development
|
|
275
|
+
prerelease: false
|
|
276
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
277
|
+
requirements:
|
|
278
|
+
- - ">="
|
|
279
|
+
- !ruby/object:Gem::Version
|
|
280
|
+
version: '0'
|
|
261
281
|
description: Enables consumer driven contract testing, providing a mock service and
|
|
262
282
|
DSL for the consumer project, and interaction playback and verification for the
|
|
263
283
|
service provider project.
|
|
@@ -308,6 +328,7 @@ files:
|
|
|
308
328
|
- lib/pact/hal/entity.rb
|
|
309
329
|
- lib/pact/hal/http_client.rb
|
|
310
330
|
- lib/pact/hal/link.rb
|
|
331
|
+
- lib/pact/hal/non_json_entity.rb
|
|
311
332
|
- lib/pact/pact_broker.rb
|
|
312
333
|
- lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
|
|
313
334
|
- lib/pact/pact_broker/fetch_pacts.rb
|
|
@@ -316,6 +337,7 @@ files:
|
|
|
316
337
|
- lib/pact/provider/configuration.rb
|
|
317
338
|
- lib/pact/provider/configuration/configuration_extension.rb
|
|
318
339
|
- lib/pact/provider/configuration/dsl.rb
|
|
340
|
+
- lib/pact/provider/configuration/message_provider_dsl.rb
|
|
319
341
|
- lib/pact/provider/configuration/pact_verification.rb
|
|
320
342
|
- lib/pact/provider/configuration/pact_verification_from_broker.rb
|
|
321
343
|
- lib/pact/provider/configuration/service_provider_config.rb
|
|
@@ -387,7 +409,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
387
409
|
version: '0'
|
|
388
410
|
requirements: []
|
|
389
411
|
rubyforge_project:
|
|
390
|
-
rubygems_version: 2.
|
|
412
|
+
rubygems_version: 2.7.7
|
|
391
413
|
signing_key:
|
|
392
414
|
specification_version: 4
|
|
393
415
|
summary: Enables consumer driven contract testing, providing a mock service and DSL
|