chef 16.7.61-universal-mingw32 → 16.9.20-universal-mingw32
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 +4 -4
- data/Gemfile +3 -5
- data/README.md +2 -2
- data/chef.gemspec +12 -2
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/client.rb +3 -0
- data/lib/chef/compliance/default_attributes.rb +93 -0
- data/lib/chef/compliance/fetcher/automate.rb +69 -0
- data/lib/chef/compliance/fetcher/chef_server.rb +134 -0
- data/lib/chef/compliance/reporter/automate.rb +201 -0
- data/lib/chef/compliance/reporter/chef_server_automate.rb +94 -0
- data/lib/chef/compliance/reporter/compliance_enforcer.rb +20 -0
- data/lib/chef/compliance/reporter/json_file.rb +19 -0
- data/lib/chef/compliance/runner.rb +262 -0
- data/lib/chef/cookbook_manifest.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
- data/lib/chef/exceptions.rb +4 -0
- data/lib/chef/http/ssl_policies.rb +33 -14
- data/lib/chef/knife/bootstrap/train_connector.rb +1 -1
- data/lib/chef/knife/core/formatting_options.rb +49 -0
- data/lib/chef/knife/core/node_presenter.rb +0 -25
- data/lib/chef/knife/core/status_presenter.rb +1 -26
- data/lib/chef/knife/core/ui.rb +4 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
- data/lib/chef/knife/node_show.rb +2 -1
- data/lib/chef/knife/search.rb +2 -1
- data/lib/chef/knife/ssh.rb +3 -1
- data/lib/chef/knife/status.rb +8 -11
- data/lib/chef/mixin/powershell_exec.rb +3 -1
- data/lib/chef/platform/query_helpers.rb +4 -4
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +2 -0
- data/lib/chef/provider/dsc_resource.rb +12 -24
- data/lib/chef/provider/dsc_script.rb +16 -20
- data/lib/chef/provider/git.rb +5 -5
- data/lib/chef/provider/package.rb +53 -19
- data/lib/chef/provider/package/dnf.rb +39 -12
- data/lib/chef/provider/package/dnf/dnf_helper.py +18 -5
- data/lib/chef/provider/package/dnf/python_helper.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
- data/lib/chef/provider/yum_repository.rb +2 -2
- data/lib/chef/resource/chef_client_config.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +2 -2
- data/lib/chef/resource/cron/cron_d.rb +1 -0
- data/lib/chef/resource/dsc_script.rb +8 -1
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/gem_package.rb +2 -2
- data/lib/chef/resource/homebrew_cask.rb +3 -3
- data/lib/chef/resource/hostname.rb +3 -3
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/mdadm.rb +2 -2
- data/lib/chef/resource/osx_profile.rb +7 -7
- data/lib/chef/resource/remote_directory.rb +1 -1
- data/lib/chef/resource/ruby.rb +1 -5
- data/lib/chef/resource/ruby_block.rb +1 -1
- data/lib/chef/resource/template.rb +2 -2
- data/lib/chef/resource/user/windows_user.rb +5 -0
- data/lib/chef/resource/windows_certificate.rb +9 -13
- data/lib/chef/resource/yum_repository.rb +5 -0
- data/lib/chef/resource_collection/resource_set.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +52 -11
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -4
- data/lib/chef/util/dsc/local_configuration_manager.rb +17 -14
- data/lib/chef/util/dsc/resource_store.rb +5 -11
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +4 -0
- data/spec/data/rubygems.org/latest_specs.4.8.gz +0 -0
- data/spec/data/rubygems.org/nonexistent_gem +0 -0
- data/spec/data/rubygems.org/sexp_processor +0 -0
- data/spec/data/rubygems.org/sexp_processor-4.15.1.gemspec.rz +0 -0
- data/spec/data/ssl/binary/chef-rspec-der.cert +0 -0
- data/spec/data/ssl/binary/chef-rspec-der.key +0 -0
- data/spec/functional/resource/dnf_package_spec.rb +319 -16
- data/spec/functional/resource/dsc_script_spec.rb +3 -6
- data/spec/functional/resource/windows_certificate_spec.rb +204 -384
- data/spec/integration/client/client_spec.rb +2 -1
- data/spec/integration/compliance/compliance_spec.rb +81 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/client_spec.rb +1 -0
- data/spec/unit/compliance/fetcher/automate_spec.rb +134 -0
- data/spec/unit/compliance/fetcher/chef_server_spec.rb +93 -0
- data/spec/unit/compliance/reporter/automate_spec.rb +427 -0
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +177 -0
- data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +48 -0
- data/spec/unit/compliance/runner_spec.rb +167 -0
- data/spec/unit/http/ssl_policies_spec.rb +107 -68
- data/spec/unit/knife/bootstrap_spec.rb +5 -17
- data/spec/unit/knife/core/node_editor_spec.rb +1 -1
- data/spec/unit/knife/core/status_presenter_spec.rb +54 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +0 -7
- data/spec/unit/mixin/powershell_exec_spec.rb +1 -1
- data/spec/unit/platform/query_helpers_spec.rb +11 -12
- data/spec/unit/provider/dsc_resource_spec.rb +10 -27
- data/spec/unit/provider/dsc_script_spec.rb +1 -1
- data/spec/unit/provider/mount/windows_spec.rb +1 -0
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
- data/spec/unit/provider/package/rubygems_spec.rb +39 -7
- data/spec/unit/provider/systemd_unit_spec.rb +1 -1
- data/spec/unit/resource/user/windows_user_spec.rb +36 -0
- data/spec/unit/resource/windows_certificate_spec.rb +12 -0
- data/spec/unit/util/dsc/configuration_generator_spec.rb +79 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +27 -35
- metadata +55 -18
- data/lib/chef/util/powershell/cmdlet.rb +0 -169
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -61
- data/spec/data/trusted_certs_empty/.gitkeep +0 -0
- data/spec/data/trusted_certs_empty/README.md +0 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -111
- data/spec/scripts/ssl-serve.rb +0 -47
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -472,21 +472,13 @@ describe Chef::Knife::Bootstrap do
|
|
472
472
|
end
|
473
473
|
|
474
474
|
describe "when transferring trusted certificates" do
|
475
|
-
let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(__dir__, "../../data/trusted_certs")) }
|
476
|
-
|
477
475
|
let(:rendered_template) do
|
478
476
|
knife.merge_configs
|
479
477
|
knife.render_template
|
480
478
|
end
|
481
479
|
|
482
480
|
before do
|
483
|
-
Chef::Config[:trusted_certs_dir] =
|
484
|
-
allow(IO).to receive(:read).and_call_original
|
485
|
-
allow(IO).to receive(:read).with(File.expand_path(Chef::Config[:validation_key])).and_return("")
|
486
|
-
end
|
487
|
-
|
488
|
-
def certificates
|
489
|
-
Dir[File.join(trusted_certs_dir, "*.{crt,pem}")]
|
481
|
+
Chef::Config[:trusted_certs_dir] = Chef::Util::PathHelper.cleanpath(File.join(CHEF_SPEC_DATA, "trusted_certs"))
|
490
482
|
end
|
491
483
|
|
492
484
|
it "creates /etc/chef/trusted_certs" do
|
@@ -494,27 +486,23 @@ describe Chef::Knife::Bootstrap do
|
|
494
486
|
end
|
495
487
|
|
496
488
|
it "copies the certificates in the directory" do
|
497
|
-
certificates.
|
498
|
-
expect(IO).to receive(:read).with(File.expand_path(cert))
|
499
|
-
end
|
489
|
+
certificates = Dir[File.join(Chef::Config[:trusted_certs_dir], "*.{crt,pem}")]
|
500
490
|
|
501
491
|
certificates.each do |cert|
|
502
492
|
expect(rendered_template).to match(%r{cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'})
|
503
493
|
end
|
504
494
|
end
|
505
495
|
|
506
|
-
|
507
|
-
|
508
|
-
|
496
|
+
it "doesn't create /etc/chef/trusted_certs if :trusted_certs_dir is empty" do
|
497
|
+
Dir.mktmpdir do |dir|
|
498
|
+
Chef::Config[:trusted_certs_dir] = dir
|
509
499
|
expect(rendered_template).not_to match(%r{mkdir -p /etc/chef/trusted_certs})
|
510
500
|
end
|
511
501
|
end
|
512
|
-
|
513
502
|
end
|
514
503
|
|
515
504
|
context "when doing fips things" do
|
516
505
|
let(:template_file) { File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "no_proxy.erb")) }
|
517
|
-
let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(__dir__, "../../data/trusted_certs")) }
|
518
506
|
|
519
507
|
before do
|
520
508
|
Chef::Config[:knife][:bootstrap_template] = template_file
|
@@ -74,7 +74,7 @@ describe Chef::Knife::NodeEditor do
|
|
74
74
|
|
75
75
|
expect(ui).to have_received(:warn)
|
76
76
|
.with "Changing the name of a node results in a new node being " +
|
77
|
-
|
77
|
+
"created, test_node will not be modified or removed."
|
78
78
|
|
79
79
|
expect(ui).to have_received(:confirm)
|
80
80
|
.with("Proceed with creation of new node")
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "spec_helper"
|
18
|
+
|
19
|
+
describe Chef::Knife::Core::StatusPresenter do
|
20
|
+
describe "#summarize_json" do
|
21
|
+
let(:presenter) { Chef::Knife::Core::StatusPresenter.new(double(:ui), double(:config, :[] => "")) }
|
22
|
+
|
23
|
+
let(:node) do
|
24
|
+
Chef::Node.new.tap do |n|
|
25
|
+
n.automatic_attrs["name"] = "my_node"
|
26
|
+
n.automatic_attrs["ipaddress"] = "127.0.0.1"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:result) { JSON.parse(presenter.summarize_json([node])).first }
|
31
|
+
|
32
|
+
it "uses the first of public_ipv4_addrs when present" do
|
33
|
+
node.automatic_attrs["cloud"] = { "public_ipv4_addrs" => ["2.2.2.2"] }
|
34
|
+
|
35
|
+
expect(result["ip"]).to eq("2.2.2.2")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "falls back to ipaddress when public_ipv4_addrs is empty" do
|
39
|
+
node.automatic_attrs["cloud"] = { "public_ipv4_addrs" => [] }
|
40
|
+
|
41
|
+
expect(result["ip"]).to eq("127.0.0.1")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "falls back to ipaddress when cloud attributes are empty" do
|
45
|
+
node.automatic_attrs["cloud"] = {}
|
46
|
+
|
47
|
+
expect(result["ip"]).to eq("127.0.0.1")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "falls back to ipaddress when cloud attributes is not present" do
|
51
|
+
expect(result["ip"]).to eq("127.0.0.1")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -21,13 +21,6 @@ describe Chef::Mixin::OpenSSLHelper do
|
|
21
21
|
Class.new { include Chef::Mixin::OpenSSLHelper }.new
|
22
22
|
end
|
23
23
|
|
24
|
-
describe ".included" do
|
25
|
-
it "requires openssl" do
|
26
|
-
instance
|
27
|
-
expect(defined?(OpenSSL)).to_not be(false)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
24
|
# Path helpers
|
32
25
|
describe "#get_key_filename" do
|
33
26
|
context "When the input is not a string" do
|
@@ -66,7 +66,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
|
|
66
66
|
execution = object.powershell_exec("this-should-error")
|
67
67
|
expect(execution.errors).to be_a_kind_of(Array)
|
68
68
|
expect(execution.errors[0]).to be_a_kind_of(String)
|
69
|
-
expect(execution.errors[0]).to include("
|
69
|
+
expect(execution.errors[0]).to include("The term 'this-should-error' is not recognized")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "raises an error if the interpreter is invalid" do
|
@@ -41,24 +41,23 @@ end
|
|
41
41
|
|
42
42
|
describe "Chef::Platform#dsc_refresh_mode_disabled?" do
|
43
43
|
let(:node) { instance_double("Chef::Node") }
|
44
|
-
let(:
|
45
|
-
let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult") }
|
44
|
+
let(:powershell) { instance_double("Chef::PowerShell") }
|
46
45
|
|
47
46
|
it "returns true when RefreshMode is Disabled" do
|
48
|
-
expect(Chef::
|
49
|
-
.with(
|
50
|
-
.and_return(
|
51
|
-
expect(
|
52
|
-
expect(
|
47
|
+
expect(Chef::PowerShell).to receive(:new)
|
48
|
+
.with("Get-DscLocalConfigurationManager")
|
49
|
+
.and_return(powershell)
|
50
|
+
expect(powershell).to receive(:error!)
|
51
|
+
expect(powershell).to receive(:result).and_return({ "RefreshMode" => "Disabled" })
|
53
52
|
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true
|
54
53
|
end
|
55
54
|
|
56
55
|
it "returns false when RefreshMode is not Disabled" do
|
57
|
-
expect(Chef::
|
58
|
-
.with(
|
59
|
-
.and_return(
|
60
|
-
expect(
|
61
|
-
expect(
|
56
|
+
expect(Chef::PowerShell).to receive(:new)
|
57
|
+
.with("Get-DscLocalConfigurationManager")
|
58
|
+
.and_return(powershell)
|
59
|
+
expect(powershell).to receive(:error!)
|
60
|
+
expect(powershell).to receive(:result).and_return({ "RefreshMode" => "LaLaLa" })
|
62
61
|
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false
|
63
62
|
end
|
64
63
|
end
|
@@ -85,14 +85,13 @@ describe Chef::Provider::DscResource do
|
|
85
85
|
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
|
86
86
|
node
|
87
87
|
end
|
88
|
-
let(:resource_result) { double("
|
89
|
-
let(:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
|
88
|
+
let(:resource_result) { double("PowerShell", result: { "InDesiredState" => true }, verbose: ["description"]) }
|
90
89
|
let(:store) { double("ResourceStore", find: resource_records) }
|
91
90
|
let(:resource_records) { [] }
|
92
91
|
|
93
92
|
before do
|
94
93
|
allow(Chef::Util::DSC::ResourceStore).to receive(:instance).and_return(store)
|
95
|
-
allow(
|
94
|
+
allow(provider).to receive(:powershell_exec!).and_return(resource_result)
|
96
95
|
allow(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
|
97
96
|
end
|
98
97
|
|
@@ -112,9 +111,8 @@ describe Chef::Provider::DscResource do
|
|
112
111
|
it "flags the resource as reboot required when required" do
|
113
112
|
expect(provider).to receive(:test_resource).and_return(false)
|
114
113
|
expect(provider).to receive(:invoke_resource)
|
115
|
-
.and_return(double(
|
114
|
+
.and_return(double(result: { "RebootRequired" => true }))
|
116
115
|
expect(provider).to receive(:add_dsc_verbose_log)
|
117
|
-
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
|
118
116
|
expect(provider).to receive(:create_reboot_resource)
|
119
117
|
provider.run_action(:run)
|
120
118
|
end
|
@@ -122,9 +120,8 @@ describe Chef::Provider::DscResource do
|
|
122
120
|
it "does not flag the resource as reboot required when not required" do
|
123
121
|
expect(provider).to receive(:test_resource).and_return(false)
|
124
122
|
expect(provider).to receive(:invoke_resource)
|
125
|
-
.and_return(double(stdout: "",
|
123
|
+
.and_return(double(stdout: "", result: {}))
|
126
124
|
expect(provider).to receive(:add_dsc_verbose_log)
|
127
|
-
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
|
128
125
|
expect(provider).to_not receive(:create_reboot_resource)
|
129
126
|
provider.run_action(:run)
|
130
127
|
end
|
@@ -142,9 +139,7 @@ describe Chef::Provider::DscResource do
|
|
142
139
|
let(:resource_records) { [{}] }
|
143
140
|
|
144
141
|
it "returns the default dsc resource module" do
|
145
|
-
expect(
|
146
|
-
expect(cmdlet).to match(/Module PSDesiredStateConfiguration /)
|
147
|
-
end.and_return(invoke_dsc_resource)
|
142
|
+
expect(provider).to receive(:powershell_exec!).with(/Module PSDesiredStateConfiguration /).and_return(resource_result)
|
148
143
|
provider.run_action(:run)
|
149
144
|
end
|
150
145
|
end
|
@@ -153,9 +148,7 @@ describe Chef::Provider::DscResource do
|
|
153
148
|
let(:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
|
154
149
|
|
155
150
|
it "returns the default dsc resource module" do
|
156
|
-
expect(
|
157
|
-
expect(cmdlet).to match(/Module ModuleName /)
|
158
|
-
end.and_return(invoke_dsc_resource)
|
151
|
+
expect(provider).to receive(:powershell_exec!).with(/Module ModuleName /).and_return(resource_result)
|
159
152
|
provider.run_action(:run)
|
160
153
|
end
|
161
154
|
end
|
@@ -286,8 +279,6 @@ describe Chef::Provider::DscResource do
|
|
286
279
|
end
|
287
280
|
|
288
281
|
describe "invoke_resource" do
|
289
|
-
let(:cmdlet) { double(run!: nil) }
|
290
|
-
|
291
282
|
before(:each) do
|
292
283
|
allow(provider).to receive(:translate_type).and_return("my_properties")
|
293
284
|
provider.instance_variable_set(:@new_resource, double(
|
@@ -301,12 +292,8 @@ describe Chef::Provider::DscResource do
|
|
301
292
|
end
|
302
293
|
|
303
294
|
it "invokes Invoke-DscResource command with module name" do
|
304
|
-
expect(
|
305
|
-
|
306
|
-
"Invoke-DscResource -Method my_method -Name my_resource -Property my_properties -Module my_module -Verbose",
|
307
|
-
"my_output_format"
|
308
|
-
).and_return(cmdlet)
|
309
|
-
provider.send(:invoke_resource, "my_method", "my_output_format")
|
295
|
+
expect(provider).to receive(:powershell_exec!).with("Invoke-DscResource -Method my_method -Name my_resource -Property my_properties -Module my_module -Verbose").and_return(nil)
|
296
|
+
provider.send(:invoke_resource, "my_method")
|
310
297
|
end
|
311
298
|
end
|
312
299
|
|
@@ -318,12 +305,8 @@ describe Chef::Provider::DscResource do
|
|
318
305
|
end
|
319
306
|
|
320
307
|
it "invokes Invoke-DscResource command with module info object" do
|
321
|
-
expect(
|
322
|
-
|
323
|
-
"Invoke-DscResource -Method my_method -Name my_resource -Property my_properties -Module @{ModuleName='my_module';ModuleVersion='my_module_version'} -Verbose",
|
324
|
-
"my_output_format"
|
325
|
-
).and_return(cmdlet)
|
326
|
-
provider.send(:invoke_resource, "my_method", "my_output_format")
|
308
|
+
expect(provider).to receive(:powershell_exec!).with("Invoke-DscResource -Method my_method -Name my_resource -Property my_properties -Module @{ModuleName='my_module';ModuleVersion='my_module_version'} -Verbose").and_return(nil)
|
309
|
+
provider.send(:invoke_resource, "my_method")
|
327
310
|
end
|
328
311
|
end
|
329
312
|
end
|
@@ -99,7 +99,7 @@ describe Chef::Provider::DscScript do
|
|
99
99
|
it "should noop if neither code or command are provided" do
|
100
100
|
allow(provider).to receive(:load_current_resource)
|
101
101
|
generator = double("Chef::Util::DSC::ConfigurationGenerator")
|
102
|
-
expect(generator).to receive(:configuration_document_from_script_code).with("", anything, anything
|
102
|
+
expect(generator).to receive(:configuration_document_from_script_code).with("", anything, anything)
|
103
103
|
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
|
104
104
|
provider.send(:generate_configuration_document, "tmp", nil)
|
105
105
|
end
|
@@ -66,7 +66,7 @@ describe Chef::Provider::Package::Freebsd::Port do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should query pkg database" do
|
69
|
-
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
|
69
|
+
expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 1, 70], timeout: 900).and_return(@pkg_info)
|
70
70
|
expect(@provider.current_installed_version).to eq("3.1.7")
|
71
71
|
end
|
72
72
|
end
|
@@ -50,6 +50,8 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
|
|
50
50
|
before do
|
51
51
|
@gem_env = Chef::Provider::Package::Rubygems::CurrentGemEnvironment.new
|
52
52
|
allow(@gem_env).to receive(:logger).and_return(logger)
|
53
|
+
|
54
|
+
WebMock.disable_net_connect!
|
53
55
|
end
|
54
56
|
|
55
57
|
it "determines the gem paths from the in memory rubygems" do
|
@@ -113,28 +115,55 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
|
|
113
115
|
end
|
114
116
|
|
115
117
|
it "finds a matching gem candidate version on rubygems 2.0.0+" do
|
116
|
-
|
118
|
+
stub_request(:head, "https://rubygems.org/api/v1/dependencies")
|
119
|
+
|
120
|
+
stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=sexp_processor")
|
121
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
|
122
|
+
|
123
|
+
stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
|
124
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
|
125
|
+
|
126
|
+
dep = Gem::Dependency.new("sexp_processor", ">= 0")
|
117
127
|
expect(@gem_env.candidate_version_from_remote(dep)).to be_kind_of(Gem::Version)
|
118
128
|
end
|
119
129
|
|
120
130
|
it "gives the candidate version as nil if none is found" do
|
121
|
-
|
131
|
+
stub_request(:head, "https://rubygems.org/api/v1/dependencies")
|
132
|
+
|
133
|
+
stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=nonexistent_gem")
|
134
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "nonexistent_gem")))
|
135
|
+
|
136
|
+
dep = Gem::Dependency.new("nonexistent_gem", ">= 0")
|
122
137
|
expect(@gem_env.candidate_version_from_remote(dep)).to be_nil
|
123
138
|
end
|
124
139
|
|
125
140
|
it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do
|
126
|
-
|
127
|
-
|
141
|
+
stub_request(:head, "https://rubygems2.org/api/v1/dependencies")
|
142
|
+
|
143
|
+
stub_request(:get, "https://rubygems2.org/api/v1/dependencies?gems=sexp_processor")
|
144
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
|
145
|
+
|
146
|
+
stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
|
147
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
|
148
|
+
|
149
|
+
dep = Gem::Dependency.new("sexp_processor", ">= 0")
|
150
|
+
expect(@gem_env.candidate_version_from_remote(dep, "https://rubygems2.org")).to be_kind_of(Gem::Version)
|
128
151
|
end
|
129
152
|
end
|
130
153
|
|
131
154
|
context "old rubygems caching behavior" do
|
132
155
|
before do
|
133
156
|
Chef::Config[:rubygems_cache_enabled] = true
|
157
|
+
|
158
|
+
stub_request(:get, "https://rubygems.org/latest_specs.4.8.gz")
|
159
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "latest_specs.4.8.gz")))
|
134
160
|
end
|
135
161
|
|
136
162
|
it "finds a matching gem candidate version on rubygems 2.0.0+" do
|
137
|
-
|
163
|
+
stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
|
164
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
|
165
|
+
|
166
|
+
dep = Gem::Dependency.new("sexp_processor", ">= 0")
|
138
167
|
expect(@gem_env.candidate_version_from_remote(dep)).to be_kind_of(Gem::Version)
|
139
168
|
end
|
140
169
|
|
@@ -144,8 +173,11 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
|
|
144
173
|
end
|
145
174
|
|
146
175
|
it "finds a matching gem from a specific gemserver when explicit sources are given" do
|
147
|
-
|
148
|
-
|
176
|
+
stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
|
177
|
+
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
|
178
|
+
|
179
|
+
dep = Gem::Dependency.new("sexp_processor", ">= 0")
|
180
|
+
expect(@gem_env.candidate_version_from_remote(dep, "http://rubygems2.org")).to be_kind_of(Gem::Version)
|
149
181
|
end
|
150
182
|
end
|
151
183
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
|
20
|
+
describe Chef::Resource::User::WindowsUser, "#uid" do
|
21
|
+
let(:resource) { Chef::Resource::User::WindowsUser.new("notarealuser") }
|
22
|
+
|
23
|
+
it "allows a string" do
|
24
|
+
resource.uid "100"
|
25
|
+
expect(resource.uid).to eql(100)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "allows an integer" do
|
29
|
+
resource.uid 100
|
30
|
+
expect(resource.uid).to eql(100)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "does not allow a hash" do
|
34
|
+
expect { resource.uid({ woot: "i found it" }) }.to raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
end
|
@@ -80,4 +80,16 @@ describe Chef::Resource::WindowsCertificate do
|
|
80
80
|
resource.store_name "MY"
|
81
81
|
expect { resource.action :create }.not_to raise_error
|
82
82
|
end
|
83
|
+
|
84
|
+
it "the exportable property defaults to false" do
|
85
|
+
expect(resource.exportable).to be false
|
86
|
+
end
|
87
|
+
|
88
|
+
it "doesn't raise error if exportable option is passed" do
|
89
|
+
resource.pfx_password "chef$123"
|
90
|
+
resource.source "C:\\certs\\test-cert.pfx"
|
91
|
+
resource.store_name "MY"
|
92
|
+
resource.exportable true
|
93
|
+
expect { resource.action :create }.not_to raise_error
|
94
|
+
end
|
83
95
|
end
|