pact-mock_service 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 207e3adbdfa76860c388e16fc932dfd42eb5e177
4
- data.tar.gz: a17b48e942fd043e9fdcf618d1a2d04e9422ab0a
3
+ metadata.gz: e77168f9641588d6ec47fe593121d77d565343ad
4
+ data.tar.gz: 044252d86c6ab72a47c6a60fde2d52113ba14a70
5
5
  SHA512:
6
- metadata.gz: b9c71128f5a6a02e1468ff2272c32628ac3d7dca2891f1d7e30a42aae82af4bea331497b08c0c6578fc10d80e71e413da6cd01f1ca7ff1d524d0c5e369e627f2
7
- data.tar.gz: 9c9983c2ae0c8dbd421102b9f8120515ecff87a4624d0227d320b6a8a919bbc840007bc255dd1e10b45165b93f900a3b9a4b3c1bc09dd517cee37e2c549a4097
6
+ metadata.gz: aae2a208b45ebeac035cce148b288183e1b21cb107c00574a1f93e97e5c20a3cfed8356d6656a8f3683ca3e06987ec57c2dd38a8f62ea3fae483d474211cdc67
7
+ data.tar.gz: 33f2051b010e0cbab1ed5a85d630eb50a5bde8231bfab08b1ecdd434681ee22e229857f6a6c31ace6ae028f1f2c77b45aa24772d21d9bccd6607b82099b839ab
@@ -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
+ [![Build Status](https://travis-ci.org/bethesque/pact-mock_service.svg?branch=master)](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
- res = Net::HTTP.start("localhost", port) do |http|
21
- request = Net::HTTP::Get.new "http://localhost:#{port}/"
22
- request['X-Pact-Mock-Service'] = 'true'
23
- response = http.request request
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
- res.code == '200'
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
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "0.10.1"
3
+ VERSION = "0.10.2"
4
4
  end
5
5
  end
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.1
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-06-27 00:00:00.000000000 Z
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.1
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