pact 1.43.0 → 1.43.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- 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/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
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f770afeb5bcc6a3f87b8bef7469f3ca7ac674d8
|
4
|
+
data.tar.gz: 15139fb4ed56138410a6b46ab75c71314104ba07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 214f1133c45463be3ec2f4e393d31c00ac3fa9251d5e7c174c4491dc799cc3354fd0126fd2a7a8673b7b9d2a3bc4208b0b793b6f466c61d7dbdd34502c056f05
|
7
|
+
data.tar.gz: 80ae6c4b68a4e5cbd3fdc56bca61e6ec5d384de3bbda35c6ebbe2ba36aef3bfb86831ae528fbe2a123c1ac941cad6de11a451439d437bd491dedc08fd2db41d0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
<a name="v1.43.1"></a>
|
2
|
+
### v1.43.1 (2020-01-11)
|
3
|
+
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* use configured credentials when fetching the diff with previous version ([b9deb09](/../../commit/b9deb09))
|
8
|
+
* use URI.open instead of Kernel.open ([7b3ea81](/../../commit/7b3ea81))
|
9
|
+
|
10
|
+
|
1
11
|
<a name="v1.43.0"></a>
|
2
12
|
### v1.43.0 (2020-01-11)
|
3
13
|
|
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
|
@@ -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
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.43.
|
4
|
+
version: 1.43.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fraser
|
@@ -308,6 +308,7 @@ files:
|
|
308
308
|
- lib/pact/hal/entity.rb
|
309
309
|
- lib/pact/hal/http_client.rb
|
310
310
|
- lib/pact/hal/link.rb
|
311
|
+
- lib/pact/hal/non_json_entity.rb
|
311
312
|
- lib/pact/pact_broker.rb
|
312
313
|
- lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
|
313
314
|
- lib/pact/pact_broker/fetch_pacts.rb
|