chef-vault 2.6.1 → 2.7.1

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -1
  3. data/.travis.yml +5 -6
  4. data/CONTRIBUTING.md +2 -2
  5. data/Gemfile +3 -1
  6. data/README.md +3 -3
  7. data/Rakefile +16 -20
  8. data/THEORY.md +1 -1
  9. data/UPGRADE.md +55 -0
  10. data/bin/chef-vault +8 -8
  11. data/chef-vault.gemspec +21 -21
  12. data/features/detect_and_warn_v1_vault.feature +15 -0
  13. data/features/step_definitions/chef-databag.rb +1 -1
  14. data/features/step_definitions/chef-repo.rb +7 -7
  15. data/features/step_definitions/chef-vault.rb +30 -22
  16. data/features/step_definitions/chef_databagitem.rb +2 -2
  17. data/features/support/env.rb +3 -3
  18. data/lib/chef-vault.rb +15 -15
  19. data/lib/chef-vault/chef_patch/api_client.rb +5 -5
  20. data/lib/chef-vault/chef_patch/user.rb +5 -5
  21. data/lib/chef-vault/exceptions.rb +3 -0
  22. data/lib/chef-vault/item.rb +13 -19
  23. data/lib/chef-vault/item_keys.rb +13 -13
  24. data/lib/chef-vault/mixins.rb +36 -0
  25. data/lib/chef-vault/version.rb +3 -2
  26. data/lib/chef/knife/decrypt.rb +2 -2
  27. data/lib/chef/knife/encrypt_create.rb +13 -13
  28. data/lib/chef/knife/encrypt_delete.rb +2 -2
  29. data/lib/chef/knife/encrypt_remove.rb +8 -8
  30. data/lib/chef/knife/encrypt_rotate_keys.rb +2 -2
  31. data/lib/chef/knife/encrypt_update.rb +13 -13
  32. data/lib/chef/knife/mixin/compat.rb +2 -2
  33. data/lib/chef/knife/vault_admins.rb +3 -3
  34. data/lib/chef/knife/vault_base.rb +9 -9
  35. data/lib/chef/knife/vault_create.rb +13 -13
  36. data/lib/chef/knife/vault_decrypt.rb +2 -2
  37. data/lib/chef/knife/vault_delete.rb +1 -1
  38. data/lib/chef/knife/vault_download.rb +2 -2
  39. data/lib/chef/knife/vault_edit.rb +6 -6
  40. data/lib/chef/knife/vault_isvault.rb +4 -4
  41. data/lib/chef/knife/vault_itemtype.rb +4 -4
  42. data/lib/chef/knife/vault_list.rb +4 -4
  43. data/lib/chef/knife/vault_refresh.rb +3 -3
  44. data/lib/chef/knife/vault_remove.rb +9 -9
  45. data/lib/chef/knife/vault_rotate_all_keys.rb +4 -4
  46. data/lib/chef/knife/vault_rotate_keys.rb +3 -3
  47. data/lib/chef/knife/vault_show.rb +12 -12
  48. data/lib/chef/knife/vault_update.rb +15 -15
  49. data/spec/chef-vault/certificate_spec.rb +7 -7
  50. data/spec/chef-vault/item_keys_spec.rb +53 -6
  51. data/spec/chef-vault/item_spec.rb +110 -110
  52. data/spec/chef-vault/user_spec.rb +6 -6
  53. data/spec/chef-vault_spec.rb +10 -10
  54. data/spec/spec_helper.rb +3 -3
  55. metadata +7 -6
  56. data/.rubocop_todo.yml +0 -101
@@ -7,7 +7,7 @@ RSpec.describe ChefVault::Certificate do
7
7
  allow(item).to receive(:[]).with("id"){ "bar" }
8
8
  allow(item).to receive(:[]).with("contents"){ "baz" }
9
9
  @orig_stdout = $stdout
10
- $stdout = File.open(File::NULL, 'w')
10
+ $stdout = File.open(File::NULL, "w")
11
11
  end
12
12
 
13
13
  after do
@@ -15,7 +15,7 @@ RSpec.describe ChefVault::Certificate do
15
15
  end
16
16
 
17
17
  describe '#new' do
18
- it 'loads item' do
18
+ it "loads item" do
19
19
  expect(ChefVault::Item).to receive(:load).with("foo", "bar")
20
20
 
21
21
  ChefVault::Certificate.new("foo", "bar")
@@ -24,21 +24,21 @@ RSpec.describe ChefVault::Certificate do
24
24
 
25
25
  describe '#[]' do
26
26
  it "given an 'id' parameter, returns its value" do
27
- expect(cert['id']).to eq 'bar'
27
+ expect(cert["id"]).to eq "bar"
28
28
  end
29
29
  end
30
30
 
31
- describe 'decrypt_contents' do
32
- it 'echoes warning' do
31
+ describe "decrypt_contents" do
32
+ it "echoes warning" do
33
33
  expect { cert.decrypt_contents }
34
34
  .to output("WARNING: This method is deprecated, please switch to item['value'] calls\n")
35
35
  .to_stdout
36
36
  end
37
37
 
38
- it 'returns items contents' do
38
+ it "returns items contents" do
39
39
  expect(item).to receive(:[]).with("contents")
40
40
 
41
- expect(cert.decrypt_contents).to eq 'baz'
41
+ expect(cert.decrypt_contents).to eq "baz"
42
42
  end
43
43
  end
44
44
  end
@@ -3,19 +3,66 @@ RSpec.describe ChefVault::ItemKeys do
3
3
  let(:keys) { ChefVault::ItemKeys.new("foo", "bar") }
4
4
 
5
5
  it "'foo' is assigned to @data_bag" do
6
- expect(keys.data_bag).to eq 'foo'
6
+ expect(keys.data_bag).to eq "foo"
7
7
  end
8
8
 
9
9
  it "sets the keys id to 'bar'" do
10
- expect(keys["id"]).to eq 'bar'
10
+ expect(keys["id"]).to eq "bar"
11
11
  end
12
12
 
13
- it 'initializes the keys[admin] to an empty array' do
14
- expect(keys['admins']).to eq []
13
+ it "initializes the keys[admin] to an empty array" do
14
+ expect(keys["admins"]).to eq []
15
15
  end
16
16
 
17
- it 'initializes the keys[clients] to an empty array' do
18
- expect(keys['admins']).to eq []
17
+ it "initializes the keys[clients] to an empty array" do
18
+ expect(keys["admins"]).to eq []
19
+ end
20
+
21
+ context "when running with chef-solo" do
22
+ describe "#find_solo_path" do
23
+ context "when data_bag_path is an array" do
24
+ before do
25
+ allow(File).to receive(:exist?)
26
+ Chef::Config[:data_bag_path] = ["/tmp/data_bag", "/tmp/site_data_bag"]
27
+ end
28
+
29
+ it "should return an existing item" do
30
+ expect(File).to receive(:exist?).with("/tmp/site_data_bag/foo/bar.json").and_return(true)
31
+ dbp, dbi = keys.find_solo_path("bar")
32
+ expect(dbp).to eql("/tmp/site_data_bag/foo")
33
+ expect(dbi).to eql("/tmp/site_data_bag/foo/bar.json")
34
+ end
35
+
36
+ it "should return the first item if none exist" do
37
+ dbp, dbi = keys.find_solo_path("bar")
38
+ expect(dbp).to eql("/tmp/data_bag/foo")
39
+ expect(dbi).to eql("/tmp/data_bag/foo/bar.json")
40
+ end
41
+ end
42
+
43
+ context "when data_bag_path is a string" do
44
+ it "should return the path to the bag and the item" do
45
+ Chef::Config[:data_bag_path] = "/tmp/data_bag"
46
+ dbp, dbi = keys.find_solo_path("bar")
47
+ expect(dbp).to eql("/tmp/data_bag/foo")
48
+ expect(dbi).to eql("/tmp/data_bag/foo/bar.json")
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "#save" do
54
+ let(:data_bag_path) { Dir.mktmpdir("vault_item_keys") }
55
+ before do
56
+ Chef::Config[:solo] = true
57
+ Chef::Config[:data_bag_path] = data_bag_path
58
+ end
59
+
60
+ it "should save the key data" do
61
+ expect(File).to receive(:exist?).with(File.join(data_bag_path, "foo")).and_call_original
62
+ keys.save("bar")
63
+ expect(File.read(File.join(data_bag_path, "foo", "bar.json"))).to match(/"id":.*"bar"/)
64
+ end
65
+ end
19
66
  end
20
67
  end
21
68
  end
@@ -1,5 +1,5 @@
1
- require 'openssl'
2
- require 'rspec/core/shared_context'
1
+ require "openssl"
2
+ require "rspec/core/shared_context"
3
3
 
4
4
  # it turns out that simulating a node that doesn't have a public
5
5
  # key is not a simple thing
@@ -8,18 +8,18 @@ module BorkedNodeWithoutPublicKey
8
8
 
9
9
  before do
10
10
  # a node 'foo' with a public key
11
- node_foo = double('chef node foo')
12
- allow(node_foo).to receive(:name).and_return('foo')
13
- client_foo = double('chef apiclient foo')
14
- allow(client_foo).to receive(:name).and_return('foo')
11
+ node_foo = double("chef node foo")
12
+ allow(node_foo).to receive(:name).and_return("foo")
13
+ client_foo = double("chef apiclient foo")
14
+ allow(client_foo).to receive(:name).and_return("foo")
15
15
  privkey = OpenSSL::PKey::RSA.new(1024)
16
16
  pubkey = privkey.public_key
17
17
  allow(client_foo).to receive(:public_key).and_return(pubkey.to_pem)
18
18
  # a node 'bar' without a public key
19
- node_bar = double('chef node bar')
20
- allow(node_bar).to receive(:name).and_return('bar')
19
+ node_bar = double("chef node bar")
20
+ allow(node_bar).to receive(:name).and_return("bar")
21
21
  # fake out searches to return both of our nodes
22
- query_result = double('chef search results')
22
+ query_result = double("chef search results")
23
23
  allow(query_result)
24
24
  .to receive(:search)
25
25
  .with(Symbol, String)
@@ -28,24 +28,24 @@ module BorkedNodeWithoutPublicKey
28
28
  .to receive(:new)
29
29
  .and_return(query_result)
30
30
  # create a new vault item
31
- @vaultitem = ChefVault::Item.new('foo', 'bar')
32
- @vaultitem['foo'] = 'bar'
31
+ @vaultitem = ChefVault::Item.new("foo", "bar")
32
+ @vaultitem["foo"] = "bar"
33
33
  # make the vault item return the apiclient for foo but raise for bar
34
- allow(@vaultitem).to receive(:load_client).with('foo')
34
+ allow(@vaultitem).to receive(:load_client).with("foo")
35
35
  .and_return(client_foo)
36
- allow(@vaultitem).to receive(:load_client).with('bar')
36
+ allow(@vaultitem).to receive(:load_client).with("bar")
37
37
  .and_raise(ChefVault::Exceptions::ClientNotFound)
38
38
  # make the vault item fall back to 'load-admin-as-client' behaviour
39
- http_response = double('http not found')
40
- allow(http_response).to receive(:code).and_return('404')
41
- http_not_found = Net::HTTPServerException.new('not found', http_response)
39
+ http_response = double("http not found")
40
+ allow(http_response).to receive(:code).and_return("404")
41
+ http_not_found = Net::HTTPServerException.new("not found", http_response)
42
42
  allow(ChefVault::ChefPatch::User)
43
43
  .to receive(:load)
44
- .with('foo')
44
+ .with("foo")
45
45
  .and_return(client_foo)
46
46
  allow(ChefVault::ChefPatch::User)
47
47
  .to receive(:load)
48
- .with('bar')
48
+ .with("bar")
49
49
  .and_raise(http_not_found)
50
50
  end
51
51
  end
@@ -53,7 +53,7 @@ end
53
53
  RSpec.describe ChefVault::Item do
54
54
  before do
55
55
  @orig_stdout = $stdout
56
- $stdout = File.open(File::NULL, 'w')
56
+ $stdout = File.open(File::NULL, "w")
57
57
  end
58
58
 
59
59
  after do
@@ -62,151 +62,151 @@ RSpec.describe ChefVault::Item do
62
62
 
63
63
  subject(:item) { ChefVault::Item.new("foo", "bar") }
64
64
 
65
- describe 'vault probe predicates' do
65
+ describe "vault probe predicates" do
66
66
  before do
67
67
  # a normal data bag item
68
- @db = { 'foo' => '...' }
68
+ @db = { "foo" => "..." }
69
69
  @dbi = Chef::DataBagItem.new
70
- @dbi.data_bag('normal')
71
- @dbi.raw_data = { 'id' => 'foo', 'foo' => 'bar' }
72
- allow(@db).to receive(:load).with('foo').and_return(@dbi)
73
- allow(Chef::DataBag).to receive(:load).with('normal').and_return(@db)
74
- allow(Chef::DataBagItem).to receive(:load).with('normal', 'foo').and_return(@dbi)
70
+ @dbi.data_bag("normal")
71
+ @dbi.raw_data = { "id" => "foo", "foo" => "bar" }
72
+ allow(@db).to receive(:load).with("foo").and_return(@dbi)
73
+ allow(Chef::DataBag).to receive(:load).with("normal").and_return(@db)
74
+ allow(Chef::DataBagItem).to receive(:load).with("normal", "foo").and_return(@dbi)
75
75
 
76
76
  # an encrypted data bag item (non-vault)
77
- @encdb = { 'foo' => '...' }
77
+ @encdb = { "foo" => "..." }
78
78
  @encdbi = Chef::DataBagItem.new
79
- @encdbi.data_bag('encrypted')
79
+ @encdbi.data_bag("encrypted")
80
80
  @encdbi.raw_data = {
81
- 'id' => 'foo',
82
- 'foo' => { 'encrypted_data' => '...' }
81
+ "id" => "foo",
82
+ "foo" => { "encrypted_data" => "..." },
83
83
  }
84
- allow(@encdb).to receive(:load).with('foo').and_return(@encdbi)
85
- allow(Chef::DataBag).to receive(:load).with('encrypted').and_return(@encdb)
86
- allow(Chef::DataBagItem).to receive(:load).with('encrypted', 'foo').and_return(@encdbi)
84
+ allow(@encdb).to receive(:load).with("foo").and_return(@encdbi)
85
+ allow(Chef::DataBag).to receive(:load).with("encrypted").and_return(@encdb)
86
+ allow(Chef::DataBagItem).to receive(:load).with("encrypted", "foo").and_return(@encdbi)
87
87
 
88
88
  # two items that make up a vault
89
- @vaultdb = { 'foo' => '...', 'foo_keys' => '...' }
89
+ @vaultdb = { "foo" => "...", "foo_keys" => "..." }
90
90
  @vaultdbi = Chef::DataBagItem.new
91
- @vaultdbi.data_bag('vault')
91
+ @vaultdbi.data_bag("vault")
92
92
  @vaultdbi.raw_data = {
93
- 'id' => 'foo',
94
- 'foo' => { 'encrypted_data' => '...' }
93
+ "id" => "foo",
94
+ "foo" => { "encrypted_data" => "..." },
95
95
  }
96
- allow(@vaultdb).to receive(:load).with('foo').and_return(@vaultdbi)
96
+ allow(@vaultdb).to receive(:load).with("foo").and_return(@vaultdbi)
97
97
  @vaultdbki = Chef::DataBagItem.new
98
- @vaultdbki.data_bag('vault')
99
- @vaultdbki.raw_data = { 'id' => 'foo_keys' }
100
- allow(@vaultdb).to receive(:load).with('foo_keys').and_return(@vaultdbki)
101
- allow(Chef::DataBag).to receive(:load).with('vault').and_return(@vaultdb)
102
- allow(Chef::DataBagItem).to receive(:load).with('vault', 'foo').and_return(@vaultdbi)
98
+ @vaultdbki.data_bag("vault")
99
+ @vaultdbki.raw_data = { "id" => "foo_keys" }
100
+ allow(@vaultdb).to receive(:load).with("foo_keys").and_return(@vaultdbki)
101
+ allow(Chef::DataBag).to receive(:load).with("vault").and_return(@vaultdb)
102
+ allow(Chef::DataBagItem).to receive(:load).with("vault", "foo").and_return(@vaultdbi)
103
103
  end
104
104
 
105
- describe '::vault?' do
106
- it 'should detect a vault item' do
107
- expect(ChefVault::Item.vault?('vault', 'foo')).to be_truthy
105
+ describe "::vault?" do
106
+ it "should detect a vault item" do
107
+ expect(ChefVault::Item.vault?("vault", "foo")).to be_truthy
108
108
  end
109
109
 
110
- it 'should detect non-vault items' do
111
- expect(ChefVault::Item.vault?('normal', 'foo')).not_to be_truthy
112
- expect(ChefVault::Item.vault?('encrypted', 'foo')).not_to be_truthy
110
+ it "should detect non-vault items" do
111
+ expect(ChefVault::Item.vault?("normal", "foo")).not_to be_truthy
112
+ expect(ChefVault::Item.vault?("encrypted", "foo")).not_to be_truthy
113
113
  end
114
114
  end
115
115
 
116
- describe '::data_bag_item_type' do
117
- it 'should detect a vault item' do
118
- expect(ChefVault::Item.data_bag_item_type('vault', 'foo')).to eq(:vault)
116
+ describe "::data_bag_item_type" do
117
+ it "should detect a vault item" do
118
+ expect(ChefVault::Item.data_bag_item_type("vault", "foo")).to eq(:vault)
119
119
  end
120
120
 
121
- it 'should detect an encrypted data bag item' do
122
- expect(ChefVault::Item.data_bag_item_type('encrypted', 'foo')).to eq(:encrypted)
121
+ it "should detect an encrypted data bag item" do
122
+ expect(ChefVault::Item.data_bag_item_type("encrypted", "foo")).to eq(:encrypted)
123
123
  end
124
124
 
125
- it 'should detect a normal data bag item' do
126
- expect(ChefVault::Item.data_bag_item_type('normal', 'foo')).to eq(:normal)
125
+ it "should detect a normal data bag item" do
126
+ expect(ChefVault::Item.data_bag_item_type("normal", "foo")).to eq(:normal)
127
127
  end
128
128
  end
129
129
  end
130
130
 
131
- describe '::new' do
132
- it 'item[keys] is an instance of ChefVault::ItemKeys' do
131
+ describe "::new" do
132
+ it "item[keys] is an instance of ChefVault::ItemKeys" do
133
133
  expect(item.keys).to be_an_instance_of(ChefVault::ItemKeys)
134
134
  end
135
135
 
136
136
  it "the item's 'vault' parameter is assigned to data_bag" do
137
- expect(item.data_bag).to eq 'foo'
137
+ expect(item.data_bag).to eq "foo"
138
138
  end
139
139
 
140
140
  it "the vault item name is assiged to the data bag ['id']" do
141
- expect(item['id']).to eq 'bar'
141
+ expect(item["id"]).to eq "bar"
142
142
  end
143
143
 
144
144
  it "creates a corresponding 'keys' data bag with an '_keys' id" do
145
- expect(item.keys['id']).to eq 'bar_keys'
145
+ expect(item.keys["id"]).to eq "bar_keys"
146
146
  end
147
147
 
148
148
  it "sets the item keys data bag to 'foo'" do
149
- expect(item.keys.data_bag).to eq 'foo'
149
+ expect(item.keys.data_bag).to eq "foo"
150
150
  end
151
151
 
152
- it 'defaults the node name' do
153
- item = ChefVault::Item.new('foo', 'bar')
152
+ it "defaults the node name" do
153
+ item = ChefVault::Item.new("foo", "bar")
154
154
  expect(item.node_name).to eq(Chef::Config[:node_name])
155
155
  end
156
156
 
157
- it 'defaults the client key path' do
158
- item = ChefVault::Item.new('foo', 'bar')
157
+ it "defaults the client key path" do
158
+ item = ChefVault::Item.new("foo", "bar")
159
159
  expect(item.client_key_path).to eq(Chef::Config[:client_key])
160
160
  end
161
161
 
162
- it 'allows for a node name override' do
163
- item = ChefVault::Item.new('foo', 'bar', node_name: 'baz')
164
- expect(item.node_name).to eq('baz')
162
+ it "allows for a node name override" do
163
+ item = ChefVault::Item.new("foo", "bar", node_name: "baz")
164
+ expect(item.node_name).to eq("baz")
165
165
  end
166
166
 
167
- it 'allows for a client key path override' do
168
- item = ChefVault::Item.new('foo', 'bar', client_key_path: '/foo/client.pem')
169
- expect(item.client_key_path).to eq('/foo/client.pem')
167
+ it "allows for a client key path override" do
168
+ item = ChefVault::Item.new("foo", "bar", client_key_path: "/foo/client.pem")
169
+ expect(item.client_key_path).to eq("/foo/client.pem")
170
170
  end
171
171
 
172
- it 'allows for both node name and client key overrides' do
172
+ it "allows for both node name and client key overrides" do
173
173
  item = ChefVault::Item.new(
174
- 'foo', 'bar',
175
- node_name: 'baz',
176
- client_key_path: '/foo/client.pem'
174
+ "foo", "bar",
175
+ node_name: "baz",
176
+ client_key_path: "/foo/client.pem"
177
177
  )
178
- expect(item.node_name).to eq('baz')
179
- expect(item.client_key_path).to eq('/foo/client.pem')
178
+ expect(item.node_name).to eq("baz")
179
+ expect(item.client_key_path).to eq("/foo/client.pem")
180
180
  end
181
181
  end
182
182
 
183
- describe '::load' do
184
- it 'allows for both node name and client key overrides' do
183
+ describe "::load" do
184
+ it "allows for both node name and client key overrides" do
185
185
  keys_db = Chef::DataBagItem.new
186
186
  keys_db.raw_data = {
187
- 'id' => 'bar_keys',
188
- 'baz' => '...'
187
+ "id" => "bar_keys",
188
+ "baz" => "...",
189
189
  }
190
190
  allow(ChefVault::ItemKeys)
191
191
  .to receive(:load)
192
192
  .and_return(keys_db)
193
- fh = double 'private key handle'
194
- allow(fh).to receive(:read).and_return('...')
193
+ fh = double "private key handle"
194
+ allow(fh).to receive(:read).and_return("...")
195
195
  allow(File).to receive(:open).and_return(fh)
196
- privkey = double 'private key contents'
197
- allow(privkey).to receive(:private_decrypt).and_return('sekrit')
196
+ privkey = double "private key contents"
197
+ allow(privkey).to receive(:private_decrypt).and_return("sekrit")
198
198
  allow(OpenSSL::PKey::RSA).to receive(:new).and_return(privkey)
199
199
  allow(Chef::EncryptedDataBagItem).to receive(:load).and_return(
200
- 'id' => 'bar',
201
- 'password' => '12345'
200
+ "id" => "bar",
201
+ "password" => "12345",
202
202
  )
203
203
  item = ChefVault::Item.load(
204
- 'foo', 'bar',
205
- node_name: 'baz',
206
- client_key_path: '/foo/client.pem'
204
+ "foo", "bar",
205
+ node_name: "baz",
206
+ client_key_path: "/foo/client.pem"
207
207
  )
208
- expect(item.node_name).to eq('baz')
209
- expect(item.client_key_path).to eq('/foo/client.pem')
208
+ expect(item.node_name).to eq("baz")
209
+ expect(item.client_key_path).to eq("/foo/client.pem")
210
210
  end
211
211
  end
212
212
 
@@ -219,10 +219,10 @@ RSpec.describe ChefVault::Item do
219
219
  end
220
220
  end
221
221
 
222
- it 'validates that the id of the vault matches the id of the keys data bag' do
223
- item = ChefVault::Item.new('foo', 'bar')
224
- item['id'] = 'baz'
225
- item.keys['clients'] = %w(admin)
222
+ it "validates that the id of the vault matches the id of the keys data bag" do
223
+ item = ChefVault::Item.new("foo", "bar")
224
+ item["id"] = "baz"
225
+ item.keys["clients"] = %w{admin}
226
226
  expect { item.save }.to raise_error(ChefVault::Exceptions::IdMismatch)
227
227
  end
228
228
  end
@@ -230,45 +230,45 @@ RSpec.describe ChefVault::Item do
230
230
  describe '#clients' do
231
231
  include BorkedNodeWithoutPublicKey
232
232
 
233
- it 'should not blow up when search returns a node without a public key' do
233
+ it "should not blow up when search returns a node without a public key" do
234
234
  # try to set clients when we know a node is missing a public key
235
235
  # this should not die as of v2.4.1
236
- expect { @vaultitem.clients('*:*') }.not_to raise_error
236
+ expect { @vaultitem.clients("*:*") }.not_to raise_error
237
237
  end
238
238
 
239
- it 'should emit a warning if search returns a node without a public key' do
239
+ it "should emit a warning if search returns a node without a public key" do
240
240
  # it should however emit a warning that you have a borked node
241
- expect { @vaultitem.clients('*:*') }
241
+ expect { @vaultitem.clients("*:*") }
242
242
  .to output(/node 'bar' has no private key; skipping/).to_stdout
243
243
  end
244
244
 
245
- it 'should accept a client object and not perform a search' do
245
+ it "should accept a client object and not perform a search" do
246
246
  client = Chef::ApiClient.new
247
- client.name 'foo'
247
+ client.name "foo"
248
248
  privkey = OpenSSL::PKey::RSA.new(1024)
249
249
  pubkey = privkey.public_key
250
250
  client.public_key(pubkey.to_pem)
251
251
  expect(Chef::Search::Query).not_to receive(:new)
252
252
  expect(ChefVault::ChefPatch::User).not_to receive(:load)
253
253
  @vaultitem.clients(client)
254
- expect(@vaultitem.clients).to include('foo')
254
+ expect(@vaultitem.clients).to include("foo")
255
255
  end
256
256
  end
257
257
 
258
258
  describe '#admins' do
259
259
  include BorkedNodeWithoutPublicKey
260
260
 
261
- it 'should blow up if you try to use a node without a public key as an admin' do
262
- expect { @vaultitem.admins('foo,bar') }
261
+ it "should blow up if you try to use a node without a public key as an admin" do
262
+ expect { @vaultitem.admins("foo,bar") }
263
263
  .to raise_error(ChefVault::Exceptions::AdminNotFound)
264
264
  end
265
265
  end
266
266
 
267
267
  describe '#raw_keys' do
268
- it 'should return the keys of the underlying data bag item' do
269
- item = ChefVault::Item.new('foo', 'bar')
270
- item['foo'] = 'bar'
271
- expect(item.raw_keys).to eq(%w(id foo))
268
+ it "should return the keys of the underlying data bag item" do
269
+ item = ChefVault::Item.new("foo", "bar")
270
+ item["foo"] = "bar"
271
+ expect(item.raw_keys).to eq(%w{id foo})
272
272
  end
273
273
  end
274
274
  end