pact-mock_service 0.10.1 → 0.10.2
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 +4 -0
- data/README.md +2 -0
- data/lib/pact/mock_service/cli.rb +8 -8
- data/lib/pact/mock_service/server/respawn.rb +2 -2
- data/lib/pact/mock_service/server/spawn.rb +2 -2
- data/lib/pact/mock_service/server/wait_for_server_up.rb +14 -5
- data/lib/pact/mock_service/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77168f9641588d6ec47fe593121d77d565343ad
|
4
|
+
data.tar.gz: 044252d86c6ab72a47c6a60fde2d52113ba14a70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae2a208b45ebeac035cce148b288183e1b21cb107c00574a1f93e97e5c20a3cfed8356d6656a8f3683ca3e06987ec57c2dd38a8f62ea3fae483d474211cdc67
|
7
|
+
data.tar.gz: 33f2051b010e0cbab1ed5a85d630eb50a5bde8231bfab08b1ecdd434681ee22e229857f6a6c31ace6ae028f1f2c77b45aa24772d21d9bccd6607b82099b839ab
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@ 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
|
+
### 0.10.2 (13 Aug 2016)
|
6
|
+
* 9352017 - Update .travis.yml (Beth Skurrie, Mon Aug 8 18:06:41 2016 +1000)
|
7
|
+
* f719415 - use ssl when checking if https server is up (Valeriy Kassenbaev, Thu Aug 4 01:37:50 2016 +0300)
|
8
|
+
|
5
9
|
### 0.10.1 (27 Jun 2016)
|
6
10
|
* a9fff79 - Add release instructions (Sergei Matheson, Mon Jun 27 10:47:12 2016 +1000)
|
7
11
|
* 28c11e7 - Clarify that pact-mock_service will only work with ruby >= 2.0 (Sergei Matheson, Mon Jun 27 10:27:12 2016 +1000)
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Pact Mock Service
|
2
2
|
|
3
|
+
[](https://travis-ci.org/bethesque/pact-mock_service)
|
4
|
+
|
3
5
|
This codebase provides the mock service used by implementations of [Pact][pact]. It is packaged as a gem, and as a standalone executable for Mac OSX and Linux (Windows coming soon.)
|
4
6
|
|
5
7
|
The mock service provides the following endpoints:
|
@@ -14,7 +14,7 @@ module Pact
|
|
14
14
|
method_option :port, aliases: "-p", desc: "Port on which to run the service"
|
15
15
|
method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost'
|
16
16
|
method_option :log, aliases: "-l", desc: "File to which to log output"
|
17
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
17
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
18
18
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
19
19
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
20
20
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
@@ -32,7 +32,7 @@ module Pact
|
|
32
32
|
method_option :log_dir, aliases: "-l", desc: "File to which to log output"
|
33
33
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
34
34
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
35
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
35
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
36
36
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
37
37
|
|
38
38
|
def control
|
@@ -44,7 +44,7 @@ module Pact
|
|
44
44
|
method_option :port, aliases: "-p", default: '1234', desc: "Port on which to run the service"
|
45
45
|
method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost'
|
46
46
|
method_option :log, aliases: "-l", desc: "File to which to log output"
|
47
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
47
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
48
48
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
49
49
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
50
50
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
@@ -70,7 +70,7 @@ module Pact
|
|
70
70
|
method_option :port, aliases: "-p", default: '1234', desc: "Port on which to run the service"
|
71
71
|
method_option :host, aliases: "-h", desc: "Host on which to bind the service", default: 'localhost'
|
72
72
|
method_option :log, aliases: "-l", desc: "File to which to log output"
|
73
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
73
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
74
74
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
75
75
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written"
|
76
76
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
@@ -87,7 +87,7 @@ module Pact
|
|
87
87
|
desc 'control-start', "Start a Pact mock service control server."
|
88
88
|
method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '1234'
|
89
89
|
method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log"
|
90
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
90
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
91
91
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
92
92
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written", default: "."
|
93
93
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
@@ -110,7 +110,7 @@ module Pact
|
|
110
110
|
desc 'control-restart', "Start a Pact mock service control server."
|
111
111
|
method_option :port, aliases: "-p", desc: "Port on which to run the service", default: '1234'
|
112
112
|
method_option :log_dir, aliases: "-l", desc: "File to which to log output", default: "log"
|
113
|
-
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS"
|
113
|
+
method_option :ssl, desc: "Use a self-signed SSL cert to run the service over HTTPS", type: :boolean, default: false
|
114
114
|
method_option :cors, aliases: "-o", desc: "Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses"
|
115
115
|
method_option :pact_dir, aliases: "-d", desc: "Directory to which the pacts will be written", default: "."
|
116
116
|
method_option :pact_specification_version, aliases: "-i", desc: "The pact specification version to use when writing the pact", default: '1'
|
@@ -144,14 +144,14 @@ module Pact
|
|
144
144
|
|
145
145
|
def start_server pidfile
|
146
146
|
require 'pact/mock_service/server/spawn'
|
147
|
-
Pact::MockService::Server::Spawn.(pidfile, options[:port]) do
|
147
|
+
Pact::MockService::Server::Spawn.(pidfile, options[:port], options[:ssl]) do
|
148
148
|
yield
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
def restart_server pidfile
|
153
153
|
require 'pact/mock_service/server/respawn'
|
154
|
-
Pact::MockService::Server::Respawn.(pidfile, options[:port]) do
|
154
|
+
Pact::MockService::Server::Respawn.(pidfile, options[:port], options[:ssl]) do
|
155
155
|
yield
|
156
156
|
end
|
157
157
|
end
|
@@ -5,12 +5,12 @@ module Pact
|
|
5
5
|
module Server
|
6
6
|
class Respawn
|
7
7
|
|
8
|
-
def self.call pidfile, port
|
8
|
+
def self.call pidfile, port, ssl = false
|
9
9
|
if pidfile.file_exists_and_process_running?
|
10
10
|
pidfile.kill_process
|
11
11
|
end
|
12
12
|
|
13
|
-
Spawn.(pidfile, port) do
|
13
|
+
Spawn.(pidfile, port, ssl) do
|
14
14
|
yield
|
15
15
|
end
|
16
16
|
end
|
@@ -7,7 +7,7 @@ module Pact
|
|
7
7
|
|
8
8
|
class PortUnavailableError < StandardError; end
|
9
9
|
|
10
|
-
def self.call pidfile, port
|
10
|
+
def self.call pidfile, port, ssl = false
|
11
11
|
if pidfile.can_start?
|
12
12
|
if port_available? port
|
13
13
|
pid = fork do
|
@@ -15,7 +15,7 @@ module Pact
|
|
15
15
|
end
|
16
16
|
pidfile.pid = pid
|
17
17
|
Process.detach(pid)
|
18
|
-
Server::WaitForServerUp.(port)
|
18
|
+
Server::WaitForServerUp.(port, {ssl: ssl})
|
19
19
|
pidfile.write
|
20
20
|
else
|
21
21
|
raise PortUnavailableError.new("ERROR: Port #{port} already in use.")
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
require 'net/http'
|
3
|
+
require 'openssl'
|
3
4
|
|
4
5
|
module Pact
|
5
6
|
module MockService
|
@@ -17,12 +18,20 @@ module Pact
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.responsive? port, options
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
http = Net::HTTP.new('localhost', port)
|
22
|
+
if options[:ssl]
|
23
|
+
http.use_ssl = true
|
24
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
25
|
+
scheme = 'https'
|
26
|
+
else
|
27
|
+
scheme = 'http'
|
24
28
|
end
|
25
|
-
|
29
|
+
http.start {
|
30
|
+
request = Net::HTTP::Get.new "#{scheme}://localhost:#{port}/"
|
31
|
+
request['X-Pact-Mock-Service'] = true
|
32
|
+
response = http.request request
|
33
|
+
response.code == '200'
|
34
|
+
}
|
26
35
|
rescue SystemCallError => e
|
27
36
|
return false
|
28
37
|
rescue EOFError
|
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: 0.10.
|
4
|
+
version: 0.10.2
|
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: 2016-
|
15
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
331
|
version: '0'
|
332
332
|
requirements: []
|
333
333
|
rubyforge_project:
|
334
|
-
rubygems_version: 2.5
|
334
|
+
rubygems_version: 2.4.5
|
335
335
|
signing_key:
|
336
336
|
specification_version: 4
|
337
337
|
summary: Provides a mock service for use with Pact
|