hutch 0.4.5 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 107ee67686b10db84f9e890b9f0f082a2c155b41
4
- data.tar.gz: 23465bcdb425ffdd3fe1411d88e91b5817f8aeb1
3
+ metadata.gz: 9ad4ea66e507cf8c01b3e402c933223e0c525503
4
+ data.tar.gz: 736c571f2a6cc790ab2b3dda796a1c29b624ec74
5
5
  SHA512:
6
- metadata.gz: 8ae2a6b72c937256009cab231cc45b3b63b45e9915cdde0ea1d08408c9b4d9560de053d24bb30f72afdd9e72d1687b39bbfe6cbf5aed6246ff96bba903648616
7
- data.tar.gz: 915f42a2056f6449693f5b05ff4ae7645231a1d9a42d94760cfe7548f5bb4bf0ed6cb2bce9c897bea4ee33d8ed1c86295ddc6b4f715e30f2448ac472b351f8b4
6
+ metadata.gz: d16e7ef03f63fdedf9501bee91dd49e6b5edb03db74e1027d7a0fa1ed140994dd9e545f757484f86441d078271523df98d3d9d9d83156ad33329ca761cfbaae9
7
+ data.tar.gz: 719bd84eced5c8876a2dbc43b785db900bc7300a091ffb479a6949fb0797ef66eb354a273b438f92ef3932eba07a1e1703dc8c2abed31cea7fd4bbd52f109a83
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  .bundle
2
2
  hutch-*.gem
3
3
  Gemfile.lock
4
+ .ruby-version
5
+ .ruby-gemset
6
+ .idea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.0 - October 17, 2013
2
+
3
+ - Support for the `--mq-tls-key` and `--mq-tls-cert` configuration options.
4
+
1
5
  ## 0.4.5 - October 15, 2013
2
6
 
3
7
  - No exception raised when hutch is run with no consumers. Instead, a warning
data/README.md CHANGED
@@ -29,7 +29,7 @@ gem install hutch
29
29
  To use in a project managed with Bundler:
30
30
 
31
31
  ``` ruby
32
- gem "hutch", "~> 0.4.1"
32
+ gem "hutch", "~> 0.5.0"
33
33
  ```
34
34
 
35
35
  ## Overview
data/lib/hutch/broker.rb CHANGED
@@ -37,11 +37,13 @@ module Hutch
37
37
  host, port, vhost = @config[:mq_host], @config[:mq_port]
38
38
  username, password = @config[:mq_username], @config[:mq_password]
39
39
  vhost, tls = @config[:mq_vhost], @config[:mq_tls]
40
+ tls_key, tls_cert = @config[:mq_tls_key], @config[:mq_tls_cert]
40
41
  protocol = tls ? "amqps://" : "amqp://"
41
42
  uri = "#{username}:#{password}@#{host}:#{port}/#{vhost.sub(/^\//, '')}"
42
43
  logger.info "connecting to rabbitmq (#{protocol}#{uri})"
43
44
 
44
- @connection = Bunny.new(host: host, port: port, vhost: vhost, tls: tls,
45
+ @connection = Bunny.new(host: host, port: port, vhost: vhost,
46
+ tls: tls, tls_key: tls_key, tls_cert: tls_cert,
45
47
  username: username, password: password,
46
48
  heartbeat: 1, automatically_recover: true,
47
49
  network_recovery_interval: 1)
data/lib/hutch/cli.rb CHANGED
@@ -101,6 +101,16 @@ module Hutch
101
101
  Hutch::Config.mq_tls = tls
102
102
  end
103
103
 
104
+ opts.on('--mq-tls-cert FILE', 'Certificate for TLS client verification') do |file|
105
+ abort "Certificate file '#{file}' not found" unless File.exists?(file)
106
+ Hutch::Config.mq_tls_cert = file
107
+ end
108
+
109
+ opts.on('--mq-tls-key FILE', 'Private key for TLS client verification') do |file|
110
+ abort "Private key file '#{file}' not found" unless File.exists?(file)
111
+ Hutch::Config.mq_tls_key = file
112
+ end
113
+
104
114
  opts.on('--mq-exchange EXCHANGE',
105
115
  'Set the RabbitMQ exchange') do |exchange|
106
116
  Hutch::Config.mq_exchange = exchange
data/lib/hutch/config.rb CHANGED
@@ -14,6 +14,8 @@ module Hutch
14
14
  mq_exchange: 'hutch', # TODO: should this be required?
15
15
  mq_vhost: '/',
16
16
  mq_tls: false,
17
+ mq_tls_cert: nil,
18
+ mq_tls_key: nil,
17
19
  mq_username: 'guest',
18
20
  mq_password: 'guest',
19
21
  mq_api_host: 'localhost',
data/lib/hutch/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Hutch
2
- VERSION = '0.4.5'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
4
4
 
@@ -28,5 +28,53 @@ describe Hutch::CLI do
28
28
  end
29
29
  end
30
30
  end
31
+
32
+ context "--mq-tls-key" do
33
+ context "when the keyfile file does not exist" do
34
+ let(:file) { "/path/to/nonexistant/file" }
35
+ before { STDERR.stub(:write) }
36
+
37
+ it "bails" do
38
+ expect {
39
+ cli.parse_options(["--mq-tls-key=#{file}"])
40
+ }.to raise_error SystemExit
41
+ end
42
+ end
43
+
44
+ context "when the keyfile file exists" do
45
+ let(:file) do
46
+ Tempfile.new("hutch-test-key.pem").to_path
47
+ end
48
+
49
+ it "sets mq_tls_key to the file" do
50
+ Hutch::Config.should_receive(:mq_tls_key=)
51
+ cli.parse_options(["--mq-tls-key=#{file}"])
52
+ end
53
+ end
54
+ end
55
+
56
+ context "--mq-tls-cert" do
57
+ context "when the certfile file does not exist" do
58
+ let(:file) { "/path/to/nonexistant/file" }
59
+ before { STDERR.stub(:write) }
60
+
61
+ it "bails" do
62
+ expect {
63
+ cli.parse_options(["--mq-tls-cert=#{file}"])
64
+ }.to raise_error SystemExit
65
+ end
66
+ end
67
+
68
+ context "when the certfile file exists" do
69
+ let(:file) do
70
+ Tempfile.new("hutch-test-cert.pem").to_path
71
+ end
72
+
73
+ it "sets mq_tls_cert to the file" do
74
+ Hutch::Config.should_receive(:mq_tls_cert=)
75
+ cli.parse_options(["--mq-tls-cert=#{file}"])
76
+ end
77
+ end
78
+ end
31
79
  end
32
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2013-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny