chef 12.14.89-universal-mingw32 → 12.15.19-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +76 -51
  3. data/Gemfile +1 -1
  4. data/README.md +9 -7
  5. data/Rakefile +1 -1
  6. data/VERSION +1 -1
  7. data/acceptance/Gemfile +3 -0
  8. data/acceptance/Gemfile.lock +19 -18
  9. data/acceptance/fips/.kitchen.yml +1 -1
  10. data/lib/chef/application/exit_code.rb +9 -0
  11. data/lib/chef/cookbook/file_system_file_vendor.rb +7 -8
  12. data/lib/chef/cookbook/metadata.rb +8 -0
  13. data/lib/chef/exceptions.rb +5 -0
  14. data/lib/chef/knife.rb +14 -15
  15. data/lib/chef/knife/ssh.rb +1 -0
  16. data/lib/chef/node/attribute.rb +1 -3
  17. data/lib/chef/node/attribute_collections.rb +20 -0
  18. data/lib/chef/provider/apt_repository.rb +1 -1
  19. data/lib/chef/provider/apt_update.rb +1 -1
  20. data/lib/chef/provider/group/groupadd.rb +2 -1
  21. data/lib/chef/provider/package/cab.rb +150 -0
  22. data/lib/chef/provider/package/rubygems.rb +0 -1
  23. data/lib/chef/provider/registry_key.rb +26 -2
  24. data/lib/chef/provider/remote_file/content.rb +1 -1
  25. data/lib/chef/provider/user.rb +10 -0
  26. data/lib/chef/provider/user/dscl.rb +2 -2
  27. data/lib/chef/provider/user/linux.rb +4 -14
  28. data/lib/chef/provider/user/pw.rb +2 -2
  29. data/lib/chef/provider/user/solaris.rb +15 -0
  30. data/lib/chef/provider/user/useradd.rb +1 -5
  31. data/lib/chef/providers.rb +1 -0
  32. data/lib/chef/resource/cab_package.rb +44 -0
  33. data/lib/chef/resource/registry_key.rb +3 -3
  34. data/lib/chef/resource/yum_repository.rb +1 -1
  35. data/lib/chef/resources.rb +1 -0
  36. data/lib/chef/server_api.rb +1 -1
  37. data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
  38. data/lib/chef/version.rb +1 -1
  39. data/spec/data/templates/chef-seattle20160930-4388-1crv7ef.txt +1 -0
  40. data/spec/data/templates/chef-seattle20160930-4388-jjfoae.txt +1 -0
  41. data/spec/data/templates/chef-seattle20160930-4388-umeq2c.txt +1 -0
  42. data/spec/functional/knife/cookbook_delete_spec.rb +48 -59
  43. data/spec/functional/resource/ifconfig_spec.rb +6 -0
  44. data/spec/functional/resource/registry_spec.rb +110 -4
  45. data/spec/unit/application/exit_code_spec.rb +10 -0
  46. data/spec/unit/cookbook/file_vendor_spec.rb +15 -0
  47. data/spec/unit/cookbook/metadata_spec.rb +19 -0
  48. data/spec/unit/exceptions_spec.rb +2 -0
  49. data/spec/unit/node/attribute_spec.rb +23 -1
  50. data/spec/unit/node/vivid_mash_spec.rb +27 -0
  51. data/spec/unit/provider/group/groupadd_spec.rb +118 -99
  52. data/spec/unit/provider/package/cab_spec.rb +218 -0
  53. data/spec/unit/provider/package/rubygems_spec.rb +2 -4
  54. data/spec/unit/provider/registry_key_spec.rb +94 -0
  55. data/spec/unit/provider/remote_file/content_spec.rb +1 -0
  56. data/spec/unit/provider/user/solaris_spec.rb +52 -40
  57. data/spec/unit/resource/apt_update_spec.rb +25 -17
  58. data/spec/unit/resource/cab_package_spec.rb +38 -0
  59. data/spec/unit/resource/registry_key_spec.rb +26 -10
  60. data/spec/unit/server_api_spec.rb +50 -0
  61. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +10 -4
  62. metadata +13 -5
@@ -735,10 +735,9 @@ describe Chef::Provider::Package::Rubygems do
735
735
  context "when source is a path" do
736
736
  let(:source) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
737
737
  let(:target_version) { ">= 0" }
738
- let(:domain) { " --local" }
739
738
 
740
739
  it "installs the gem by shelling out to gem install" do
741
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"#{domain}", env: nil, timeout: 900)
740
+ expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
742
741
  provider.run_action(:install)
743
742
  expect(new_resource).to be_updated_by_last_action
744
743
  end
@@ -747,11 +746,10 @@ describe Chef::Provider::Package::Rubygems do
747
746
  context "when the package is a path and source is nil" do
748
747
  let(:gem_name) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
749
748
  let(:target_version) { ">= 0" }
750
- let(:domain) { " --local" }
751
749
 
752
750
  it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
753
751
  expect(new_resource.source).to eq(gem_name)
754
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"#{domain}", env: nil, timeout: 900)
752
+ expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
755
753
  provider.run_action(:install)
756
754
  expect(new_resource).to be_updated_by_last_action
757
755
  end
@@ -311,3 +311,97 @@ describe Chef::Provider::RegistryKey do
311
311
  end
312
312
  end
313
313
  end
314
+
315
+ describe Chef::Provider::RegistryKey, "key_missing?" do
316
+ let(:provider) { Chef::Provider::RegistryKey.new(nil, nil) }
317
+ let(:all_keys_present_in_all_hash) do
318
+ [ { :name => "input1_value1", :type => :string, :data => "my_value1" },
319
+ { :name => "input1_value2", :type => :string, :data => "my_value2" },
320
+ ]
321
+ end
322
+ let(:type_key_not_present_in_any_hash) do
323
+ [ { :name => "input2_value1", :data => "my_value1" },
324
+ { :name => "input2_value2", :data => "my_value2" },
325
+ ]
326
+ end
327
+ let(:type_key_not_present_in_some_hash) do
328
+ [ { :name => "input3_value1", :data => "my_value1" },
329
+ { :name => "input3_value2", :type => :string, :data => "my_value2" },
330
+ ]
331
+ end
332
+ let(:data_key_not_present_in_any_hash) do
333
+ [ { :name => "input4_value1", :type => :string },
334
+ { :name => "input4_value2", :type => :string },
335
+ ]
336
+ end
337
+ let(:data_key_not_present_in_some_hash) do
338
+ [ { :name => "input5_value1", :type => :string, :data => "my_value1" },
339
+ { :name => "input5_value2", :type => :string },
340
+ ]
341
+ end
342
+ let(:only_name_key_present_in_all_hash) do
343
+ [ { :name => "input6_value1" },
344
+ { :name => "input6_value2" },
345
+ ]
346
+ end
347
+
348
+ context "type key" do
349
+ context "when type key is present in all the values hash of registry_key resource" do
350
+ it "returns false" do
351
+ response = provider.key_missing?(all_keys_present_in_all_hash, :type)
352
+ expect(response).to be == false
353
+ end
354
+ end
355
+
356
+ context "when type key is not present in any of the values hash of registry_key resource" do
357
+ it "returns true" do
358
+ response = provider.key_missing?(type_key_not_present_in_any_hash, :type)
359
+ expect(response).to be == true
360
+ end
361
+ end
362
+
363
+ context "when type key is not present only in some of the values hash of registry_key resource" do
364
+ it "returns true" do
365
+ response = provider.key_missing?(type_key_not_present_in_some_hash, :type)
366
+ expect(response).to be == true
367
+ end
368
+ end
369
+
370
+ context "when only name key is present in all the values hash of registry_key resource" do
371
+ it "returns true" do
372
+ response = provider.key_missing?(only_name_key_present_in_all_hash, :type)
373
+ expect(response).to be == true
374
+ end
375
+ end
376
+ end
377
+
378
+ context "data key" do
379
+ context "when data key is present in all the values hash of registry_key resource" do
380
+ it "returns false" do
381
+ response = provider.key_missing?(all_keys_present_in_all_hash, :data)
382
+ expect(response).to be == false
383
+ end
384
+ end
385
+
386
+ context "when data key is not present in any of the values hash of registry_key resource" do
387
+ it "returns true" do
388
+ response = provider.key_missing?(data_key_not_present_in_any_hash, :data)
389
+ expect(response).to be == true
390
+ end
391
+ end
392
+
393
+ context "when data key is not present only in some of the values hash of registry_key resource" do
394
+ it "returns true" do
395
+ response = provider.key_missing?(data_key_not_present_in_some_hash, :data)
396
+ expect(response).to be == true
397
+ end
398
+ end
399
+
400
+ context "when only name key is present in all the values hash of registry_key resource" do
401
+ it "returns true" do
402
+ response = provider.key_missing?(only_name_key_present_in_all_hash, :data)
403
+ expect(response).to be == true
404
+ end
405
+ end
406
+ end
407
+ end
@@ -180,6 +180,7 @@ describe Chef::Provider::RemoteFile::Content do
180
180
  Net::HTTPServerException,
181
181
  Net::HTTPFatalError,
182
182
  Net::FTPError,
183
+ Errno::ETIMEDOUT,
183
184
  ].each do |exception|
184
185
  describe "with an exception of #{exception}" do
185
186
  before do
@@ -29,26 +29,31 @@ describe Chef::Provider::User::Solaris do
29
29
  Struct.new(:stdout, :stderr, :exitstatus)
30
30
  end
31
31
 
32
- subject(:provider) do
33
- p = described_class.new(@new_resource, @run_context)
34
- p.current_resource = @current_resource
32
+ let(:node) do
33
+ Chef::Node.new.tap do |node|
34
+ node.automatic["platform"] = "solaris2"
35
+ end
36
+ end
37
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
38
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
39
+ let(:new_resource) do
40
+ Chef::Resource::User::SolarisUser.new("adam", @run_context)
41
+ end
42
+ let(:current_resource) do
43
+ Chef::Resource::User::SolarisUser.new("adam", @run_context)
44
+ end
35
45
 
36
- # Prevent the useradd-based provider tests from trying to write /etc/shadow
37
- allow(p).to receive(:write_shadow_file)
38
- p
46
+ subject(:provider) do
47
+ described_class.new(new_resource, run_context).tap do |p|
48
+ p.current_resource = current_resource
49
+ # Prevent the useradd-based provider tests from trying to write /etc/shadow
50
+ allow(p).to receive(:write_shadow_file)
51
+ end
39
52
  end
40
53
 
41
54
  describe "when we want to set a password" do
42
55
  before(:each) do
43
- @node = Chef::Node.new
44
- @events = Chef::EventDispatch::Dispatcher.new
45
- @run_context = Chef::RunContext.new(@node, {}, @events)
46
-
47
- @new_resource = Chef::Resource::User::SolarisUser.new("adam", @run_context)
48
- @current_resource = Chef::Resource::User::SolarisUser.new("adam", @run_context)
49
-
50
- @new_resource.password "hocus-pocus"
51
-
56
+ new_resource.password "hocus-pocus"
52
57
  end
53
58
 
54
59
  it "should use its own shadow file writer to set the password" do
@@ -68,53 +73,60 @@ describe Chef::Provider::User::Solaris do
68
73
  # may not be able to write to /etc for tests...
69
74
  temp_file = Tempfile.new("shadow")
70
75
  allow(Tempfile).to receive(:new).with("shadow", "/etc").and_return(temp_file)
71
- @new_resource.password "verysecurepassword"
76
+ new_resource.password "verysecurepassword"
72
77
  provider.manage_user
73
78
  expect(::File.open(password_file.path, "r").read).to match(/adam:verysecurepassword:/)
74
79
  password_file.unlink
75
80
  end
76
81
  end
77
82
 
78
- describe "when managing user locked status" do
79
- before(:each) do
80
- @node = Chef::Node.new
81
- @events = Chef::EventDispatch::Dispatcher.new
82
- @run_context = Chef::RunContext.new(@node, {}, @events)
83
-
84
- @new_resource = Chef::Resource::User::SolarisUser.new("dave")
85
- @current_resource = @new_resource.dup
83
+ describe "#create_user" do
84
+ context "with a system user" do
85
+ before { new_resource.system(true) }
86
+ it "should not pass -r" do
87
+ expect(provider).to receive(:shell_out!).with("useradd", "adam")
88
+ provider.create_user
89
+ end
90
+ end
86
91
 
87
- @provider = Chef::Provider::User::Solaris.new(@new_resource, @run_context)
88
- @provider.current_resource = @current_resource
92
+ context "with manage_home" do
93
+ before { new_resource.manage_home(true) }
94
+ it "should not pass -r" do
95
+ expect(provider).to receive(:shell_out!).with("useradd", "-m", "adam")
96
+ provider.create_user
97
+ end
89
98
  end
99
+ end
100
+
101
+ describe "when managing user locked status" do
90
102
  describe "when determining if the user is locked" do
91
103
 
92
104
  # locked shadow lines
93
105
  [
94
- "dave:LK:::::::",
95
- "dave:*LK*:::::::",
96
- "dave:*LK*foobar:::::::",
97
- "dave:*LK*bahamas10:::::::",
98
- "dave:*LK*L....:::::::",
106
+ "adam:LK:::::::",
107
+ "adam:*LK*:::::::",
108
+ "adam:*LK*foobar:::::::",
109
+ "adam:*LK*bahamas10:::::::",
110
+ "adam:*LK*L....:::::::",
99
111
  ].each do |shadow|
100
112
  it "should return true if user is locked with #{shadow}" do
101
113
  shell_return = shellcmdresult.new(shadow + "\n", "", 0)
102
- expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
114
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", "adam").and_return(shell_return)
103
115
  expect(provider.check_lock).to eql(true)
104
116
  end
105
117
  end
106
118
 
107
119
  # unlocked shadow lines
108
120
  [
109
- "dave:NP:::::::",
110
- "dave:*NP*:::::::",
111
- "dave:foobar:::::::",
112
- "dave:bahamas10:::::::",
113
- "dave:L...:::::::",
121
+ "adam:NP:::::::",
122
+ "adam:*NP*:::::::",
123
+ "adam:foobar:::::::",
124
+ "adam:bahamas10:::::::",
125
+ "adam:L...:::::::",
114
126
  ].each do |shadow|
115
127
  it "should return false if user is unlocked with #{shadow}" do
116
128
  shell_return = shellcmdresult.new(shadow + "\n", "", 0)
117
- expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
129
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", "adam").and_return(shell_return)
118
130
  expect(provider.check_lock).to eql(false)
119
131
  end
120
132
  end
@@ -123,7 +135,7 @@ describe Chef::Provider::User::Solaris do
123
135
  describe "when locking the user" do
124
136
  it "should run passwd -l with the new resources username" do
125
137
  shell_return = shellcmdresult.new("", "", 0)
126
- expect(provider).to receive(:shell_out!).with("passwd", "-l", @new_resource.username).and_return(shell_return)
138
+ expect(provider).to receive(:shell_out!).with("passwd", "-l", "adam").and_return(shell_return)
127
139
  provider.lock_user
128
140
  end
129
141
  end
@@ -131,7 +143,7 @@ describe Chef::Provider::User::Solaris do
131
143
  describe "when unlocking the user" do
132
144
  it "should run passwd -u with the new resources username" do
133
145
  shell_return = shellcmdresult.new("", "", 0)
134
- expect(provider).to receive(:shell_out!).with("passwd", "-u", @new_resource.username).and_return(shell_return)
146
+ expect(provider).to receive(:shell_out!).with("passwd", "-u", "adam").and_return(shell_return)
135
147
  provider.unlock_user
136
148
  end
137
149
  end
@@ -24,27 +24,35 @@ describe Chef::Resource::AptUpdate do
24
24
  let(:run_context) { Chef::RunContext.new(node, {}, events) }
25
25
  let(:resource) { Chef::Resource::AptUpdate.new("update", run_context) }
26
26
 
27
- it "should create a new Chef::Resource::AptUpdate" do
28
- expect(resource).to be_a_kind_of(Chef::Resource)
29
- expect(resource).to be_a_kind_of(Chef::Resource::AptUpdate)
30
- end
27
+ context "on linux", :linux_only do
28
+ it "should create a new Chef::Resource::AptUpdate" do
29
+ expect(resource).to be_a_kind_of(Chef::Resource)
30
+ expect(resource).to be_a_kind_of(Chef::Resource::AptUpdate)
31
+ end
31
32
 
32
- it "the default frequency should be 1 day" do
33
- expect(resource.frequency).to eql(86_400)
34
- end
33
+ it "the default frequency should be 1 day" do
34
+ expect(resource.frequency).to eql(86_400)
35
+ end
35
36
 
36
- it "the frequency should accept integers" do
37
- resource.frequency(400)
38
- expect(resource.frequency).to eql(400)
39
- end
37
+ it "the frequency should accept integers" do
38
+ resource.frequency(400)
39
+ expect(resource.frequency).to eql(400)
40
+ end
41
+
42
+ it "should resolve to a Noop class when apt-get is not found" do
43
+ expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(false)
44
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
45
+ end
40
46
 
41
- it "should resolve to a Noop class when apt-get is not found" do
42
- expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(false)
43
- expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
47
+ it "should resolve to a AptUpdate class when apt-get is found" do
48
+ expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(true)
49
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptUpdate)
50
+ end
44
51
  end
45
52
 
46
- it "should resolve to a AptUpdate class when apt-get is found" do
47
- expect(Chef::Provider::AptUpdate).to receive(:which).with("apt-get").and_return(true)
48
- expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptUpdate)
53
+ context "on windows", :windows_only do
54
+ it "should resolve to a NoOp provider" do
55
+ expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop)
56
+ end
49
57
  end
50
58
  end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@msystechnologies.com>)
3
+ # Copyright:: Copyright 2008-2016, Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+
21
+ describe Chef::Resource::CabPackage do
22
+
23
+ let(:resource) { Chef::Resource::CabPackage.new("test_pkg") }
24
+
25
+ it "creates a new Chef::Resource::CabPackage" do
26
+ expect(resource).to be_a_kind_of(Chef::Resource)
27
+ expect(resource).to be_a_kind_of(Chef::Resource::Package)
28
+ expect(resource).to be_a_instance_of(Chef::Resource::CabPackage)
29
+ end
30
+
31
+ it "sets resource name as :cab_package" do
32
+ expect(resource.resource_name).to eql(:cab_package)
33
+ end
34
+
35
+ it "coerce its name to a package_name" do
36
+ expect(resource.package_name).to eql("test_pkg")
37
+ end
38
+ end
@@ -94,19 +94,11 @@ describe Chef::Resource::RegistryKey, "values" do
94
94
  expect(@resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ])
95
95
  end
96
96
 
97
- it "should throw an exception if the name field is missing" do
97
+ it "should raise an exception if the name field is missing" do
98
98
  expect { @resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError)
99
99
  end
100
100
 
101
- it "should throw an exception if the type field is missing" do
102
- expect { @resource.values [ { :name => "poosh", :data => "carmen" } ] }.to raise_error(ArgumentError)
103
- end
104
-
105
- it "should throw an exception if the data field is missing" do
106
- expect { @resource.values [ { :name => "poosh", :type => :string } ] }.to raise_error(ArgumentError)
107
- end
108
-
109
- it "should throw an exception if extra fields are present" do
101
+ it "should raise an exception if extra fields are present" do
110
102
  expect { @resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError)
111
103
  end
112
104
 
@@ -117,6 +109,30 @@ describe Chef::Resource::RegistryKey, "values" do
117
109
  it "should not allow an integer" do
118
110
  expect { @resource.send(:values, 100) }.to raise_error(ArgumentError)
119
111
  end
112
+
113
+ it "should raise an exception if type of name is not string" do
114
+ expect { @resource.values([ { :name => 123, :type => :string, :data => "carmen" } ]) }.to raise_error(ArgumentError)
115
+ end
116
+
117
+ it "should not raise an exception if type of name is string" do
118
+ expect { @resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
119
+ end
120
+
121
+ context "type key not given" do
122
+ it "should not raise an exception" do
123
+ expect { @resource.values([ { :name => "123", :data => "carmen" } ]) }.to_not raise_error
124
+ end
125
+ end
126
+
127
+ context "type key given" do
128
+ it "should raise an exception if type of type is not symbol" do
129
+ expect { @resource.values([ { :name => "123", :type => "string", :data => "carmen" } ]) }.to raise_error(ArgumentError)
130
+ end
131
+
132
+ it "should not raise an exception if type of type is symbol" do
133
+ expect { @resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
134
+ end
135
+ end
120
136
  end
121
137
 
122
138
  describe Chef::Resource::RegistryKey, "recursive" do
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ SIGNING_KEY_DOT_PEM = "-----BEGIN RSA PRIVATE KEY-----
4
+ MIIEpAIBAAKCAQEA49TA0y81ps0zxkOpmf5V4/c4IeR5yVyQFpX3JpxO4TquwnRh
5
+ 8VSUhrw8kkTLmB3cS39Db+3HadvhoqCEbqPE6915kXSuk/cWIcNozujLK7tkuPEy
6
+ YVsyTioQAddSdfe+8EhQVf3oHxaKmUd6waXrWqYCnhxgOjxocenREYNhZ/OETIei
7
+ PbOku47vB4nJK/0GhKBytL2XnsRgfKgDxf42BqAi1jglIdeq8lAWZNF9TbNBU21A
8
+ O1iuT7Pm6LyQujhggPznR5FJhXKRUARXBJZawxpGV4dGtdcahwXNE4601aXPra+x
9
+ PcRd2puCNoEDBzgVuTSsLYeKBDMSfs173W1QYwIDAQABAoIBAGF05q7vqOGbMaSD
10
+ 2Q7YbuE/JTHKTBZIlBI1QC2x+0P5GDxyEFttNMOVzcs7xmNhkpRw8eX1LrInrpMk
11
+ WsIBKAFFEfWYlf0RWtRChJjNl+szE9jQxB5FJnWtJH/FHa78tR6PsF24aQyzVcJP
12
+ g0FGujBihwgfV0JSCNOBkz8MliQihjQA2i8PGGmo4R4RVzGfxYKTIq9vvRq/+QEa
13
+ Q4lpVLoBqnENpnY/9PTl6JMMjW2b0spbLjOPVwDaIzXJ0dChjNXo15K5SHI5mALJ
14
+ I5gN7ODGb8PKUf4619ez194FXq+eob5YJdilTFKensIUvt3YhP1ilGMM+Chi5Vi/
15
+ /RCTw3ECgYEA9jTw4wv9pCswZ9wbzTaBj9yZS3YXspGg26y6Ohq3ZmvHz4jlT6uR
16
+ xK+DDcUiK4072gci8S4Np0fIVS7q6ivqcOdzXPrTF5/j+MufS32UrBbUTPiM1yoO
17
+ ECcy+1szl/KoLEV09bghPbvC58PFSXV71evkaTETYnA/F6RK12lEepcCgYEA7OSy
18
+ bsMrGDVU/MKJtwqyGP9ubA53BorM4Pp9VVVSCrGGVhb9G/XNsjO5wJC8J30QAo4A
19
+ s59ZzCpyNRy046AB8jwRQuSwEQbejSdeNgQGXhZ7aIVUtuDeFFdaIz/zjVgxsfj4
20
+ DPOuzieMmJ2MLR4F71ocboxNoDI7xruPSE8dDhUCgYA3vx732cQxgtHwAkeNPJUz
21
+ dLiE/JU7CnxIoSB9fYUfPLI+THnXgzp7NV5QJN2qzMzLfigsQcg3oyo6F2h7Yzwv
22
+ GkjlualIRRzCPaCw4Btkp7qkPvbs1QngIHALt8fD1N69P3DPHkTwjG4COjKWgnJq
23
+ qoHKS6Fe/ZlbigikI6KsuwKBgQCTlSLoyGRHr6oj0hqz01EDK9ciMJzMkZp0Kvn8
24
+ OKxlBxYW+jlzut4MQBdgNYtS2qInxUoAnaz2+hauqhSzntK3k955GznpUatCqx0R
25
+ b857vWviwPX2/P6+E3GPdl8IVsKXCvGWOBZWTuNTjQtwbDzsUepWoMgXnlQJSn5I
26
+ YSlLxQKBgQD16Gw9kajpKlzsPa6XoQeGmZALT6aKWJQlrKtUQIrsIWM0Z6eFtX12
27
+ 2jjHZ0awuCQ4ldqwl8IfRogWMBkHOXjTPVK0YKWWlxMpD/5+bGPARa5fir8O1Zpo
28
+ Y6S6MeZ69Rp89ma4ttMZ+kwi1+XyHqC/dlcVRW42Zl5Dc7BALRlJjQ==
29
+ -----END RSA PRIVATE KEY-----"
30
+
31
+ describe Chef::ServerAPI do
32
+ let(:url) { "http://chef.example.com:4000" }
33
+ let(:key_path) { "/tmp/foo" }
34
+
35
+ describe "#initialize" do
36
+ it "uses the configured key file" do
37
+ allow(IO).to receive(:read).with(key_path).and_return(SIGNING_KEY_DOT_PEM)
38
+ Chef::Config[:client_key] = key_path
39
+
40
+ api = described_class.new(url)
41
+ expect(api.options[:signing_key_filename]).to eql(key_path)
42
+ end
43
+
44
+ it "allows a user to set a raw_key" do
45
+ api = described_class.new(url, raw_key: SIGNING_KEY_DOT_PEM)
46
+ expect(api.options[:signing_key_filename]).to be_nil
47
+ expect(api.options[:raw_key]).to eql(SIGNING_KEY_DOT_PEM)
48
+ end
49
+ end
50
+ end