pact-mock_service 2.1.1.pre.alpha.2 → 2.2.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/lib/pact/consumer_contract/consumer_contract_writer.rb +1 -1
- data/lib/pact/mock_service/cli.rb +9 -30
- data/lib/pact/mock_service/cli/pidfile.rb +3 -16
- data/lib/pact/mock_service/control_server/run.rb +1 -0
- data/lib/pact/mock_service/interactions/interaction_diff_message.rb +1 -1
- data/lib/pact/mock_service/run.rb +1 -0
- data/lib/pact/mock_service/session.rb +1 -0
- data/lib/pact/mock_service/version.rb +1 -1
- metadata +6 -8
- data/lib/pact/mock_service/os.rb +0 -13
- data/lib/pact/mock_service/server/windows_safe_spawn.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cf900a12d4f91a4ff30a3e9f524f989ffedca18
|
4
|
+
data.tar.gz: ac91a2457b5d83c349c70663682dfae00e22af08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296f813db0e501057558d0cdb241b56fba89144be5822f2aac010b9cfbdabf960ae644a4a508eb6ae37192b042901f3180a093a210e7c3372ee20ba3db487598
|
7
|
+
data.tar.gz: fbc2b07d41210eaf4fafe758e6135c9ca41bfe9038a5d8f327eb5dd86ef6fb9a89d81d82f0a4caaa8a0fbf6a1c46f2b1c68ce2efc7e0444f3792631a3cf57c0a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
|
4
4
|
|
5
|
+
### 2.2.0 (2017-09-30)
|
6
|
+
* 3949e3d - feat(cli): add --unique-pact-file-names option (Beth Skurrie, Thu Sep 28 11:16:22 2017 +1000)
|
7
|
+
|
5
8
|
### 2.1.0 (12 May 2017)
|
6
9
|
* 5b89d95 - Updated location of pact specification version in pact to metadata.pactSpecification.version. As per issue #137 (Beth Skurrie, Fri May 12 11:03:54 2017 +1000)
|
7
10
|
* b85ad94 - Update mock service interaction decorator to use providerState between the consumer DSL and the mock service, just to avoid any further confusion! (Beth Skurrie, Fri May 12 08:41:56 2017 +1000)
|
data/Gemfile
CHANGED
@@ -129,7 +129,7 @@ module Pact
|
|
129
129
|
|
130
130
|
def pactfile_path
|
131
131
|
raise 'You must specify a consumer and provider name' unless (consumer_name && provider_name)
|
132
|
-
file_path consumer_name, provider_name, pact_dir
|
132
|
+
file_path consumer_name, provider_name, pact_dir, unique: consumer_contract_details[:unique_pact_file_names]
|
133
133
|
end
|
134
134
|
|
135
135
|
def pact_dir
|
@@ -5,7 +5,6 @@ require 'fileutils'
|
|
5
5
|
require 'pact/mock_service/server/wait_for_server_up'
|
6
6
|
require 'pact/mock_service/cli/pidfile'
|
7
7
|
require 'socket'
|
8
|
-
require 'rake/file_utils'
|
9
8
|
|
10
9
|
module Pact
|
11
10
|
module MockService
|
@@ -20,6 +19,7 @@ module Pact
|
|
20
19
|
method_option :sslkey, desc: "Specify the path to the SSL key to use when running the service over HTTPS"
|
21
20
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
22
21
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
22
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
23
23
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
24
24
|
method_option :consumer, desc: "Consumer name"
|
25
25
|
method_option :provider, desc: "Provider name"
|
@@ -34,6 +34,7 @@ module Pact
|
|
34
34
|
method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost'
|
35
35
|
method_option :log_dir, aliases: "-l", desc: "File to which to log output"
|
36
36
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
37
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
37
38
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
38
39
|
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
39
40
|
method_option :sslcert, desc: "Specify the path to the SSL cert to use when running the service over HTTPS"
|
@@ -54,13 +55,16 @@ module Pact
|
|
54
55
|
method_option :sslkey, desc: "Specify the path to the SSL key to use when running the service over HTTPS"
|
55
56
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
56
57
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
58
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
57
59
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
58
60
|
method_option :consumer, desc: "Consumer name"
|
59
61
|
method_option :provider, desc: "Provider name"
|
60
62
|
method_option :pid_dir, desc: "PID dir", default: 'tmp/pids'
|
61
63
|
|
62
64
|
def start
|
63
|
-
|
65
|
+
start_server(mock_service_pidfile) do
|
66
|
+
service
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
desc 'stop', "Stop a Pact mock service"
|
@@ -80,6 +84,7 @@ module Pact
|
|
80
84
|
method_option :sslkey, desc: "Specify the path to the SSL key to use when running the service over HTTPS"
|
81
85
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
82
86
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
87
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
83
88
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
84
89
|
method_option :consumer, desc: "Consumer name"
|
85
90
|
method_option :provider, desc: "Provider name"
|
@@ -99,6 +104,7 @@ module Pact
|
|
99
104
|
method_option :sslkey, desc: "Specify the path to the SSL key to use when running the service over HTTPS"
|
100
105
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
101
106
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written", default: "."
|
107
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
102
108
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
103
109
|
method_option :pid_dir, desc: "PID dir", default: "tmp/pids"
|
104
110
|
|
@@ -124,6 +130,7 @@ module Pact
|
|
124
130
|
method_option :sslkey, desc: "Specify the path to the SSL key to use when running the service over HTTPS"
|
125
131
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
126
132
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written", default: "."
|
133
|
+
method_option :unique_pact_file_names, aliases: "-u", desc: "Set to true when running multiple mock service instances in parallel for the same consumer/provider pair", type: :boolean, default: false
|
127
134
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
128
135
|
method_option :pid_dir, desc: "PID dir", default: "tmp/pids"
|
129
136
|
|
@@ -173,34 +180,6 @@ module Pact
|
|
173
180
|
yield
|
174
181
|
end
|
175
182
|
end
|
176
|
-
|
177
|
-
def spawn_mock_service
|
178
|
-
require 'pact/mock_service/server/windows_safe_spawn'
|
179
|
-
pidfile = mock_service_pidfile
|
180
|
-
Pact::MockService::Server::WindowsSafeSpawn.(service_spawn_command, pidfile, options[:port], options[:ssl])
|
181
|
-
end
|
182
|
-
|
183
|
-
def service_spawn_command
|
184
|
-
command = []
|
185
|
-
if ENV['PACT_STANDALONE_WRAPPER_PATH']
|
186
|
-
command << ENV['PACT_STANDALONE_WRAPPER_PATH']
|
187
|
-
else
|
188
|
-
command << FileUtils::RUBY
|
189
|
-
command << "-S #{$0}"
|
190
|
-
end
|
191
|
-
command << "service"
|
192
|
-
command += build_service_options
|
193
|
-
command.join(" ")
|
194
|
-
end
|
195
|
-
|
196
|
-
def service_switch_names
|
197
|
-
Pact::MockService::CLI.commands['service'].options.values.each_with_object({}){| option, hash| hash[option.human_name] = option.switch_name }
|
198
|
-
end
|
199
|
-
|
200
|
-
def build_service_options
|
201
|
-
switch_names = service_switch_names
|
202
|
-
options.collect{ |key, value| "#{switch_names[key]} #{value}" if switch_names[key] }.compact
|
203
|
-
end
|
204
183
|
end
|
205
184
|
end
|
206
185
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'pact/mock_service/os'
|
3
2
|
|
4
3
|
module Pact
|
5
4
|
module MockService
|
@@ -74,13 +73,14 @@ module Pact
|
|
74
73
|
sleep sleep_time
|
75
74
|
tries += 1
|
76
75
|
end
|
77
|
-
raise "Process #{pid_from_file} not stopped after
|
76
|
+
raise "Process #{pid_from_file} not stopped after {100 * sleep_time} seconds." if process_running?
|
78
77
|
end
|
79
78
|
|
80
79
|
def kill_process
|
81
80
|
if file_exists?
|
82
81
|
begin
|
83
|
-
|
82
|
+
`ps -ef | grep pact`
|
83
|
+
Process.kill 2, pid_from_file
|
84
84
|
waitpid
|
85
85
|
delete
|
86
86
|
rescue Errno::ESRCH
|
@@ -91,19 +91,6 @@ module Pact
|
|
91
91
|
$stderr.puts "No PID file found at #{pidfile_path}, server probably not running. Use `ps -ef | grep pact` if you suspect the process is still running."
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
95
|
-
def windows?
|
96
|
-
Pact::MockService::OS.windows?
|
97
|
-
end
|
98
|
-
|
99
|
-
def kill_2
|
100
|
-
Process.kill 2, pid_from_file
|
101
|
-
end
|
102
|
-
|
103
|
-
def windows_kill
|
104
|
-
cmd = "taskkill /f /pid #{pid_from_file}"
|
105
|
-
`#{cmd}`
|
106
|
-
end
|
107
94
|
end
|
108
95
|
end
|
109
96
|
end
|
@@ -12,7 +12,7 @@ module Pact
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_s
|
15
|
-
"An interaction with same description (#{new_interaction.description.inspect}) and provider state (#{new_interaction.provider_state.inspect}) but a different #{differences} has already been used. Please use a different description or provider state."
|
15
|
+
"An interaction with same description (#{new_interaction.description.inspect}) and provider state (#{new_interaction.provider_state.inspect}) but a different #{differences} has already been used. Please use a different description or provider state, or hard-code any random data."
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -20,6 +20,7 @@ module Pact
|
|
20
20
|
@verified_interactions = Interactions::VerifiedInteractions.new
|
21
21
|
@consumer_contract_details = {
|
22
22
|
pact_dir: options[:pact_dir],
|
23
|
+
unique_pact_file_names: options[:unique_pact_file_names],
|
23
24
|
consumer: {name: options[:consumer]},
|
24
25
|
provider: {name: options[:provider]},
|
25
26
|
interactions: verified_interactions,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-mock_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.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: 2017-
|
15
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|
@@ -132,14 +132,14 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - "~>"
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '1.
|
135
|
+
version: '1.2'
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
140
|
- - "~>"
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: '1.
|
142
|
+
version: '1.2'
|
143
143
|
- !ruby/object:Gem::Dependency
|
144
144
|
name: rake
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,7 +302,6 @@ files:
|
|
302
302
|
- lib/pact/mock_service/interactions/verification.rb
|
303
303
|
- lib/pact/mock_service/interactions/verified_interactions.rb
|
304
304
|
- lib/pact/mock_service/logger.rb
|
305
|
-
- lib/pact/mock_service/os.rb
|
306
305
|
- lib/pact/mock_service/request_decorator.rb
|
307
306
|
- lib/pact/mock_service/request_handlers.rb
|
308
307
|
- lib/pact/mock_service/request_handlers/base_administration_request_handler.rb
|
@@ -323,7 +322,6 @@ files:
|
|
323
322
|
- lib/pact/mock_service/server/respawn.rb
|
324
323
|
- lib/pact/mock_service/server/spawn.rb
|
325
324
|
- lib/pact/mock_service/server/wait_for_server_up.rb
|
326
|
-
- lib/pact/mock_service/server/windows_safe_spawn.rb
|
327
325
|
- lib/pact/mock_service/session.rb
|
328
326
|
- lib/pact/mock_service/spawn.rb
|
329
327
|
- lib/pact/mock_service/version.rb
|
@@ -342,9 +340,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
342
340
|
version: '2.0'
|
343
341
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
344
342
|
requirements:
|
345
|
-
- - "
|
343
|
+
- - ">="
|
346
344
|
- !ruby/object:Gem::Version
|
347
|
-
version:
|
345
|
+
version: '0'
|
348
346
|
requirements: []
|
349
347
|
rubyforge_project:
|
350
348
|
rubygems_version: 2.6.12
|
data/lib/pact/mock_service/os.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'pact/mock_service/server/wait_for_server_up'
|
2
|
-
require 'pact/mock_service/os'
|
3
|
-
|
4
|
-
module Pact
|
5
|
-
module MockService
|
6
|
-
module Server
|
7
|
-
class WindowsSafeSpawn
|
8
|
-
|
9
|
-
class PortUnavailableError < StandardError; end
|
10
|
-
|
11
|
-
def self.call command, pidfile, port, ssl = false
|
12
|
-
if pidfile.can_start?
|
13
|
-
if port_available? port
|
14
|
-
pid = spawn(command, spawn_options)
|
15
|
-
pidfile.pid = pid
|
16
|
-
Process.detach(pid)
|
17
|
-
Server::WaitForServerUp.(port, {ssl: ssl})
|
18
|
-
pidfile.write
|
19
|
-
else
|
20
|
-
raise PortUnavailableError.new("ERROR: Port #{port} already in use.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.spawn_options
|
26
|
-
if Pact::MockService::OS.windows?
|
27
|
-
{new_pgroup: true}
|
28
|
-
else
|
29
|
-
{}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.port_available? port
|
34
|
-
server = TCPServer.new('127.0.0.1', port)
|
35
|
-
true
|
36
|
-
rescue
|
37
|
-
false
|
38
|
-
ensure
|
39
|
-
server.close if server
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|