cheffish 1.1.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28db1ebb5c3ef956150fcdc87b75c67903fe729a
4
- data.tar.gz: 3b06780cf90fc6b5b2af4a5b4a49ddad9535b59d
3
+ metadata.gz: 0667c4e296b1e3be43fefe384509dbc22e10202b
4
+ data.tar.gz: 35be2921f6449bc5f84ff3b3a16e11e3b228e465
5
5
  SHA512:
6
- metadata.gz: a1c94c6da71dce1bbe8ba0e21043027e8a89c227591e728c87dcc1a32ea48a9bc72d674b6b1b2d511e48b64f1b8877be1f01446512276df705d27abdf5ebfcdd
7
- data.tar.gz: eff6bbc45687d8dfaf2790fe79da4fd3d6d5f9d8540b7706dad8f498c5f96e8051e3ad6562cf13fa2af411310efed998f62e9fa482e97fd66964e79413ca1e70
6
+ metadata.gz: 3c4f73cd2e4b8619091566b49638bc5db5e8b8e5d4bb85bf6b0230d9ec9dab7d4f5ea9b24284a01c97a46eb0b48fea91c95bd9dee4e86816b08989ad1c7fe135
7
+ data.tar.gz: 8b149e416f184c91e452448fde3f0ebd195d8a4c3ae7c11328238915e1c11f41d197a6a59b57b6c3673607aa18d9894442a5ede6c8743bfc7de4c92ead990133
data/lib/cheffish.rb CHANGED
@@ -83,12 +83,13 @@ module Cheffish
83
83
 
84
84
  def self.get_private_key_with_path(name, config = profiled_config)
85
85
  if config[:private_keys] && config[:private_keys][name]
86
- if config[:private_keys][name].is_a?(String)
87
- Chef::Log.info("Got key #{name} from Chef::Config.private_keys.#{name}, which points at #{config[:private_keys[name]]}. Reading key from there ...")
88
- return [ IO.read(config[:private_keys][name]), config[:private_keys][name] ]
86
+ named_key = config[:private_keys][name]
87
+ if named_key.is_a?(String)
88
+ Chef::Log.info("Got key #{name} from Chef::Config.private_keys.#{name}, which points at #{named_key}. Reading key from there ...")
89
+ return [ IO.read(named_key), named_key]
89
90
  else
90
91
  Chef::Log.info("Got key #{name} raw from Chef::Config.private_keys.#{name}.")
91
- return [ config[:private_keys][name].to_pem, nil ]
92
+ return [ named_key.to_pem, nil ]
92
93
  end
93
94
  elsif config[:private_key_paths]
94
95
  config[:private_key_paths].each do |private_key_path|
@@ -1,3 +1,3 @@
1
1
  module Cheffish
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -23,6 +23,7 @@ describe Cheffish do
23
23
  File.open(key_file, "w+") do |f|
24
24
  f.write private_key_contents
25
25
  end
26
+ key_file
26
27
  end
27
28
 
28
29
  def setup_pem_key
@@ -30,6 +31,7 @@ describe Cheffish do
30
31
  File.open(key_file, "w+") do |f|
31
32
  f.write private_key_pem_contents
32
33
  end
34
+ key_file
33
35
  end
34
36
 
35
37
  def setup_garbage_key
@@ -37,6 +39,7 @@ describe Cheffish do
37
39
  File.open(key_file, "w+") do |f|
38
40
  f.write private_key_garbage_contents
39
41
  end
42
+ key_file
40
43
  end
41
44
 
42
45
  shared_examples_for "returning the contents of the key file if it finds one" do
@@ -62,7 +65,7 @@ describe Cheffish do
62
65
  end
63
66
  end
64
67
 
65
- context "#get_private_key" do
68
+ describe "#get_private_key" do
66
69
  context "when private_key_paths has a directory which is empty" do
67
70
  let(:config) {
68
71
  { :private_key_paths => [ directory_that_exists ] }
@@ -90,5 +93,39 @@ describe Cheffish do
90
93
 
91
94
  it_behaves_like "returning the contents of the key file if it finds one"
92
95
  end
96
+
97
+ context "when private_keys is empty" do
98
+ let(:config) {
99
+ { :private_keys => {} }
100
+ }
101
+
102
+ it "returns nil" do
103
+ expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
104
+ end
105
+ end
106
+
107
+ context "when private_keys contains the path to a key" do
108
+ let(:name) { "ned_stark" }
109
+ let(:config) {
110
+ { :private_keys => {name => setup_key} }
111
+ }
112
+
113
+ it "returns the contents of the key file" do
114
+ setup_key
115
+ expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
116
+ end
117
+ end
118
+
119
+ context "when private_keys contains the path to a key" do
120
+ let(:name) { "ned_stark" }
121
+ let(:key) {double("key", :to_pem => private_key_contents)}
122
+ let(:config) {
123
+ { :private_keys => {name => key} }
124
+ }
125
+
126
+ it "returns the contents of the key file" do
127
+ expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
128
+ end
129
+ end
93
130
  end
94
131
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-zero