chef 17.6.18-universal-mingw32 → 17.7.22-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -0
- data/chef.gemspec +1 -0
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +1 -1
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/exceptions.rb +10 -0
- data/lib/chef/provider/cron.rb +4 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/ifconfig/debian.rb +1 -1
- data/lib/chef/provider/subversion.rb +5 -5
- data/lib/chef/resource/chocolatey_config.rb +1 -1
- data/lib/chef/resource/chocolatey_feature.rb +1 -1
- data/lib/chef/resource/chocolatey_source.rb +24 -2
- data/lib/chef/resource/directory.rb +1 -1
- data/lib/chef/resource/habitat_install.rb +3 -3
- data/lib/chef/resource/inspec_waiver.rb +1 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
- data/lib/chef/resource/kernel_module.rb +27 -2
- data/lib/chef/resource/macos_userdefaults.rb +43 -128
- data/lib/chef/resource/windows_auto_run.rb +1 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
- data/lib/chef/resource/windows_update_settings.rb +3 -3
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/secret_fetcher/azure_key_vault.rb +62 -8
- data/lib/chef/secret_fetcher.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/dsl/reboot_pending_spec.rb +3 -3
- data/spec/functional/dsl/registry_helper_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -2
- data/spec/functional/resource/macos_userdefaults_spec.rb +119 -0
- data/spec/functional/resource/registry_spec.rb +81 -81
- data/spec/functional/win32/registry_spec.rb +8 -8
- data/spec/unit/data_collector_spec.rb +24 -1
- data/spec/unit/dsl/reboot_pending_spec.rb +1 -1
- data/spec/unit/mixin/default_paths_spec.rb +1 -1
- data/spec/unit/mixin/securable_spec.rb +3 -3
- data/spec/unit/provider/cron_spec.rb +45 -0
- data/spec/unit/provider/package/rubygems_spec.rb +5 -5
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/registry_key_spec.rb +4 -4
- data/spec/unit/provider/service/windows_spec.rb +5 -5
- data/spec/unit/provider/subversion_spec.rb +4 -4
- data/spec/unit/provider/windows_env_spec.rb +1 -1
- data/spec/unit/provider/zypper_repository_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_config_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_feature_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_source_spec.rb +1 -1
- data/spec/unit/resource/kernel_module_spec.rb +2 -1
- data/spec/unit/resource/macos_user_defaults_spec.rb +36 -96
- data/spec/unit/resource/registry_key_spec.rb +10 -10
- data/spec/unit/resource/windows_auto_run_spec.rb +1 -1
- data/spec/unit/resource/windows_feature_powershell_spec.rb +1 -1
- data/spec/unit/resource/windows_firewall_rule_spec.rb +2 -2
- data/spec/unit/resource/windows_task_spec.rb +3 -3
- data/spec/unit/resource_reporter_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +5 -0
- data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +99 -20
- data/spec/unit/util/backup_spec.rb +1 -1
- data/spec/unit/win32/registry_spec.rb +3 -3
- metadata +21 -6
@@ -503,11 +503,11 @@ describe Chef::Provider::Package::Rubygems do
|
|
503
503
|
platform_mock :windows do
|
504
504
|
allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin')
|
505
505
|
allow(ENV).to receive(:[]).with("PATHEXT").and_return(nil)
|
506
|
-
allow(File).to receive(:executable?).with(
|
507
|
-
allow(File).to receive(:executable?).with(
|
508
|
-
allow(File).to receive(:executable?).with(
|
509
|
-
allow(File).to receive(:executable?).with(
|
510
|
-
allow(File).to receive(:executable?).with(
|
506
|
+
allow(File).to receive(:executable?).with("C:\\windows\\system32/gem").and_return(false)
|
507
|
+
allow(File).to receive(:executable?).with("C:\\windows/gem").and_return(false)
|
508
|
+
allow(File).to receive(:executable?).with("C:\\Ruby186\\bin/gem").and_return(true)
|
509
|
+
allow(File).to receive(:executable?).with("d:\\opscode\\chef\\bin/gem").and_return(false) # should not get here
|
510
|
+
allow(File).to receive(:executable?).with("d:\\opscode\\chef\\bin/gem").and_return(false) # should not get here
|
511
511
|
allow(File).to receive(:executable?).with("d:/opscode/chef/embedded/bin/gem").and_return(false) # should not get here
|
512
512
|
expect(provider.gem_env.gem_binary_location).to eq('C:\Ruby186\bin/gem')
|
513
513
|
end
|
@@ -39,7 +39,7 @@ describe Chef::Provider::Package::Windows, :windows_only do
|
|
39
39
|
new_resource
|
40
40
|
end
|
41
41
|
let(:provider) { Chef::Provider::Package::Windows.new(new_resource, run_context) }
|
42
|
-
let(:cache_path) {
|
42
|
+
let(:cache_path) { "c:\\cache\\" }
|
43
43
|
|
44
44
|
before(:each) do
|
45
45
|
allow(::File).to receive(:exist?).with(new_resource.source).and_return(true)
|
@@ -274,7 +274,7 @@ describe Chef::Provider::RegistryKey do
|
|
274
274
|
end
|
275
275
|
|
276
276
|
context "when the key data is safe" do
|
277
|
-
let(:keyname) {
|
277
|
+
let(:keyname) { "HKLM\\Software\\Opscode\\Testing\\Safe" }
|
278
278
|
let(:testval1) { { name: "one", type: :string, data: "1" } }
|
279
279
|
let(:testval1_wrong_type) { { name: "one", type: :multi_string, data: "1" } }
|
280
280
|
let(:testval1_wrong_data) { { name: "one", type: :string, data: "2" } }
|
@@ -295,7 +295,7 @@ describe Chef::Provider::RegistryKey do
|
|
295
295
|
|
296
296
|
describe "action_create" do
|
297
297
|
context "when key exists and type matches" do
|
298
|
-
let(:keyname) {
|
298
|
+
let(:keyname) { "hklm\\software\\opscode\\testing\\dword" }
|
299
299
|
let(:dword_passed_as_integer) { { name: "one", type: :dword, data: 12345 } }
|
300
300
|
let(:testval1) { { name: "one", type: :dword, data: "12345" } }
|
301
301
|
before do
|
@@ -349,7 +349,7 @@ describe Chef::Provider::RegistryKey do
|
|
349
349
|
end
|
350
350
|
|
351
351
|
context "and key does not exist" do
|
352
|
-
let(:keyname) {
|
352
|
+
let(:keyname) { "hklm\\software\\opscode\\testing\\sensitive\\missing" }
|
353
353
|
let(:testval1) { { name: "one", type: :string, data: "first_value" } }
|
354
354
|
|
355
355
|
before(:each) do
|
@@ -368,7 +368,7 @@ describe Chef::Provider::RegistryKey do
|
|
368
368
|
|
369
369
|
describe "action_create_if_missing" do
|
370
370
|
context "when sensitive is true" do
|
371
|
-
let(:keyname) {
|
371
|
+
let(:keyname) { "hklm\\software\\opscode\\testing\\create_if_missing\\sensitive" }
|
372
372
|
let(:testval1) { { name: "one", type: :string, data: "first_value" } }
|
373
373
|
|
374
374
|
before(:each) do
|
@@ -33,7 +33,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
33
33
|
|
34
34
|
# Actual response from Win32::Service.config_info('chef-client')
|
35
35
|
let(:chef_service_binary_path_name) do
|
36
|
-
|
36
|
+
"C:\\opscode\\chef\\embedded\\bin\\ruby.exe C:\\opscode\\chef\\bin\\chef-windows-service"
|
37
37
|
end
|
38
38
|
let(:chef_service_config_info) do
|
39
39
|
double("Struct::ServiceConfigInfo",
|
@@ -153,11 +153,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
153
153
|
service_type: "share process",
|
154
154
|
start_type: "demand start",
|
155
155
|
error_control: "normal",
|
156
|
-
binary_path_name:
|
156
|
+
binary_path_name: "C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted",
|
157
157
|
load_order_group: "TDI",
|
158
158
|
tag_id: 0,
|
159
159
|
dependencies: %w{NSI Tdx Afd},
|
160
|
-
service_start_name:
|
160
|
+
service_start_name: "NT Authority\\LocalService",
|
161
161
|
display_name: "DHCP Client")
|
162
162
|
)
|
163
163
|
end
|
@@ -169,11 +169,11 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
169
169
|
service_type: "share process",
|
170
170
|
start_type: "demand start",
|
171
171
|
error_control: "normal",
|
172
|
-
binary_path_name:
|
172
|
+
binary_path_name: "C:\\Windows\\system32\\svchost.exe -k LocalServiceNetworkRestricted",
|
173
173
|
load_order_group: "TDI",
|
174
174
|
tag_id: 0,
|
175
175
|
dependencies: %w{NSI Tdx Afd},
|
176
|
-
service_start_name:
|
176
|
+
service_start_name: "NT Authority\\LocalService",
|
177
177
|
display_name: "DHCP Client")
|
178
178
|
)
|
179
179
|
end
|
@@ -190,7 +190,7 @@ describe Chef::Provider::Subversion do
|
|
190
190
|
it "runs an export with the --force option" do
|
191
191
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
192
192
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
193
|
-
expect(@provider).to receive(:shell_out!).with(expected_cmd
|
193
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd)
|
194
194
|
@provider.run_action(:force_export)
|
195
195
|
expect(@resource).to be_updated
|
196
196
|
end
|
@@ -198,7 +198,7 @@ describe Chef::Provider::Subversion do
|
|
198
198
|
it "runs the checkout command for action_checkout" do
|
199
199
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
200
200
|
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
201
|
-
expect(@provider).to receive(:shell_out!).with(expected_cmd
|
201
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd)
|
202
202
|
@provider.run_action(:checkout)
|
203
203
|
expect(@resource).to be_updated
|
204
204
|
end
|
@@ -248,7 +248,7 @@ describe Chef::Provider::Subversion do
|
|
248
248
|
allow(@provider).to receive(:find_current_revision).and_return("11410")
|
249
249
|
allow(@provider).to receive(:current_revision_matches_target_revision?).and_return(false)
|
250
250
|
expected_cmd = "svn update -q -r12345 /my/deploy/dir"
|
251
|
-
expect(@provider).to receive(:shell_out!).with(expected_cmd
|
251
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd)
|
252
252
|
@provider.run_action(:sync)
|
253
253
|
expect(@resource).to be_updated
|
254
254
|
end
|
@@ -265,7 +265,7 @@ describe Chef::Provider::Subversion do
|
|
265
265
|
it "runs the export_command on action_export" do
|
266
266
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
267
267
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
268
|
-
expect(@provider).to receive(:shell_out!).with(expected_cmd
|
268
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd)
|
269
269
|
@provider.run_action(:export)
|
270
270
|
expect(@resource).to be_updated
|
271
271
|
end
|
@@ -358,7 +358,7 @@ describe "windows_env provider", :windows_only do
|
|
358
358
|
context "when environment is PATH" do
|
359
359
|
describe "for PATH" do
|
360
360
|
let(:system_root) { "%SystemRoot%" }
|
361
|
-
let(:system_root_value) {
|
361
|
+
let(:system_root_value) { "D:\\Windows" }
|
362
362
|
let(:new_resource) do
|
363
363
|
new_resource = Chef::Resource::WindowsEnv.new("PATH", run_context)
|
364
364
|
new_resource.value(system_root)
|
@@ -103,7 +103,7 @@ describe Chef::Provider::ZypperRepository do
|
|
103
103
|
|
104
104
|
describe "#escaped_repo_name" do
|
105
105
|
it "returns an escaped repo name" do
|
106
|
-
expect(provider.escaped_repo_name).to eq(
|
106
|
+
expect(provider.escaped_repo_name).to eq("Nginx\\ Repository")
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -41,7 +41,7 @@ describe Chef::Resource::ChocolateyConfig do
|
|
41
41
|
# we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs
|
42
42
|
before(:each) do
|
43
43
|
@original_env = ENV.to_hash
|
44
|
-
ENV["ALLUSERSPROFILE"] =
|
44
|
+
ENV["ALLUSERSPROFILE"] = "C:\\ProgramData"
|
45
45
|
end
|
46
46
|
|
47
47
|
after(:each) do
|
@@ -41,7 +41,7 @@ describe Chef::Resource::ChocolateyFeature do
|
|
41
41
|
# we save off the ENV and set ALLUSERSPROFILE so these specs will work on *nix and non-C drive Windows installs
|
42
42
|
before(:each) do
|
43
43
|
@original_env = ENV.to_hash
|
44
|
-
ENV["ALLUSERSPROFILE"] =
|
44
|
+
ENV["ALLUSERSPROFILE"] = "C:\\ProgramData"
|
45
45
|
end
|
46
46
|
|
47
47
|
after(:each) do
|
@@ -54,7 +54,7 @@ describe Chef::Resource::ChocolateySource do
|
|
54
54
|
allow(resource).to receive(:provider_for_action).and_return(enable_provider)
|
55
55
|
allow(resource.class).to receive(:new).and_return(current_resource)
|
56
56
|
@original_env = ENV.to_hash
|
57
|
-
ENV["ALLUSERSPROFILE"] =
|
57
|
+
ENV["ALLUSERSPROFILE"] = "C:\\ProgramData"
|
58
58
|
end
|
59
59
|
|
60
60
|
after(:each) do
|
@@ -32,10 +32,11 @@ describe Chef::Resource::KernelModule do
|
|
32
32
|
expect(resource.modname).to eql("foo")
|
33
33
|
end
|
34
34
|
|
35
|
-
it "supports
|
35
|
+
it "supports various actions" do
|
36
36
|
expect { resource.action :install }.not_to raise_error
|
37
37
|
expect { resource.action :uninstall }.not_to raise_error
|
38
38
|
expect { resource.action :blacklist }.not_to raise_error
|
39
|
+
expect { resource.action :enable }.not_to raise_error
|
39
40
|
expect { resource.action :disable }.not_to raise_error
|
40
41
|
expect { resource.action :load }.not_to raise_error
|
41
42
|
expect { resource.action :unload }.not_to raise_error
|
@@ -17,120 +17,60 @@
|
|
17
17
|
|
18
18
|
require "spec_helper"
|
19
19
|
|
20
|
-
describe Chef::Resource::MacosUserDefaults do
|
21
|
-
|
22
|
-
let(:
|
23
|
-
let(:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(resource.domain).to eq("NSGlobalDomain")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "the value property coerces keys in hashes to strings so we can compare them with plist data" do
|
34
|
-
resource.value "User": "/Library/Managed Installs/way_fake.log"
|
35
|
-
expect(resource.value).to eq({ "User" => "/Library/Managed Installs/way_fake.log" })
|
36
|
-
end
|
37
|
-
|
38
|
-
it "the host property defaults to nil" do
|
39
|
-
expect(resource.host).to be_nil
|
40
|
-
end
|
41
|
-
|
42
|
-
it "the sudo property defaults to false" do
|
43
|
-
expect(resource.sudo).to be false
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets the default action as :write" do
|
47
|
-
expect(resource.action).to eq([:write])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "supports :write action" do
|
51
|
-
expect { resource.action :write }.not_to raise_error
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#defaults_export_cmd" do
|
55
|
-
it "exports NSGlobalDomain if no domain is set" do
|
56
|
-
expect(provider.defaults_export_cmd(resource)).to eq(["/usr/bin/defaults", "export", "NSGlobalDomain", "-"])
|
20
|
+
describe Chef::Resource::MacosUserDefaults, :macos_only, requires_root: true do
|
21
|
+
let(:test_value) { "fakest_key_value" }
|
22
|
+
let(:test_key) { "fakest_key" }
|
23
|
+
let(:node) { Chef::Node.new }
|
24
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
25
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
26
|
+
let(:resource) {
|
27
|
+
Chef::Resource::MacosUserDefaults.new("foo", run_context).tap do |r|
|
28
|
+
r.value test_value
|
29
|
+
r.key test_key
|
57
30
|
end
|
31
|
+
}
|
58
32
|
|
59
|
-
|
60
|
-
|
61
|
-
expect(
|
33
|
+
context "has a default value" do
|
34
|
+
it ":macos_userdefaults for resource name" do
|
35
|
+
expect(resource.resource_name).to eq(:macos_userdefaults)
|
62
36
|
end
|
63
37
|
|
64
|
-
it "
|
65
|
-
resource.
|
66
|
-
expect(provider.defaults_export_cmd(resource)).to eq(["/usr/bin/defaults", "-currentHost", "export", "NSGlobalDomain", "-"])
|
38
|
+
it "NSGlobalDomain for the domain property" do
|
39
|
+
expect(resource.domain).to eq("NSGlobalDomain")
|
67
40
|
end
|
68
41
|
|
69
|
-
it "
|
70
|
-
resource.host
|
71
|
-
expect(provider.defaults_export_cmd(resource)).to eq(["/usr/bin/defaults", "-host", "tim-laptop", "export", "NSGlobalDomain", "-"])
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "#defaults_modify_cmd" do
|
76
|
-
# avoid needing to set these required values over and over. We'll overwrite them where necessary
|
77
|
-
before do
|
78
|
-
resource.key = "foo"
|
79
|
-
resource.value = "bar"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "writes to NSGlobalDomain if domain isn't specified" do
|
83
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "write", "NSGlobalDomain", "foo", "-string", "bar"])
|
84
|
-
end
|
85
|
-
|
86
|
-
it "uses the domain property if set" do
|
87
|
-
resource.domain = "MyCustomDomain"
|
88
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "write", "MyCustomDomain", "foo", "-string", "bar"])
|
42
|
+
it "nil for the host property" do
|
43
|
+
expect(resource.host).to be_nil
|
89
44
|
end
|
90
45
|
|
91
|
-
it "
|
92
|
-
resource.
|
93
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "-host", "tims_laptop", "write", "NSGlobalDomain", "foo", "-string", "bar"])
|
46
|
+
it "nil for the user property" do
|
47
|
+
expect(resource.user).to be_nil
|
94
48
|
end
|
95
49
|
|
96
|
-
it "
|
97
|
-
resource.
|
98
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "-currentHost", "write", "NSGlobalDomain", "foo", "-string", "bar"])
|
99
|
-
end
|
100
|
-
|
101
|
-
it "raises ArgumentError if bool is specified, but the value can't be made into a bool" do
|
102
|
-
resource.type "bool"
|
103
|
-
expect { provider.defaults_modify_cmd }.to raise_error(ArgumentError)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "autodetects array type and passes individual values" do
|
107
|
-
resource.value = %w{one two three}
|
108
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "write", "NSGlobalDomain", "foo", "-array", "one", "two", "three"])
|
109
|
-
end
|
110
|
-
|
111
|
-
it "autodetects string type and passes a single value" do
|
112
|
-
resource.value = "one"
|
113
|
-
expect(provider.defaults_modify_cmd).to eq(["/usr/bin/defaults", "write", "NSGlobalDomain", "foo", "-string", "one"])
|
50
|
+
it ":write for resource action" do
|
51
|
+
expect(resource.action).to eq([:write])
|
114
52
|
end
|
53
|
+
end
|
115
54
|
|
116
|
-
|
117
|
-
|
118
|
-
expect
|
55
|
+
context ":write" do
|
56
|
+
it "is a supported action" do
|
57
|
+
expect { resource.action :write }.not_to raise_error
|
119
58
|
end
|
120
59
|
|
121
|
-
it "
|
122
|
-
resource.
|
123
|
-
expect(
|
60
|
+
it "successfully updates the preference" do
|
61
|
+
resource.run_action(:write)
|
62
|
+
expect(resource.get_preference resource).eql? test_value
|
124
63
|
end
|
64
|
+
end
|
125
65
|
|
126
|
-
|
127
|
-
|
128
|
-
expect
|
66
|
+
context ":delete" do
|
67
|
+
it "is a supported action" do
|
68
|
+
expect { resource.action :delete }.not_to raise_error
|
129
69
|
end
|
130
70
|
|
131
|
-
it "
|
132
|
-
resource.
|
133
|
-
expect(
|
71
|
+
it "successfully deletes the preference" do
|
72
|
+
resource.run_action(:delete)
|
73
|
+
expect(resource.get_preference resource).to be_nil
|
134
74
|
end
|
135
75
|
end
|
136
76
|
end
|
@@ -19,14 +19,14 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::RegistryKey, "initialize" do
|
22
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
22
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
23
23
|
|
24
24
|
it "sets the resource_name to :registry_key" do
|
25
25
|
expect(resource.resource_name).to eql(:registry_key)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "the key property is the name_property" do
|
29
|
-
expect(resource.key).to eql(
|
29
|
+
expect(resource.key).to eql("HKCU\\Software\\Raxicoricofallapatorius")
|
30
30
|
end
|
31
31
|
|
32
32
|
it "sets the default action as :create" do
|
@@ -60,11 +60,11 @@ describe Chef::Resource::RegistryKey, "initialize" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe Chef::Resource::RegistryKey, "key" do
|
63
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
63
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
64
64
|
|
65
65
|
it "allows a string" do
|
66
|
-
resource.key
|
67
|
-
expect(resource.key).to eql(
|
66
|
+
resource.key "HKCU\\Software\\Poosh"
|
67
|
+
expect(resource.key).to eql("HKCU\\Software\\Poosh")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "does not allow an integer" do
|
@@ -77,7 +77,7 @@ describe Chef::Resource::RegistryKey, "key" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe Chef::Resource::RegistryKey, "values" do
|
80
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
80
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
81
81
|
|
82
82
|
it "allows a single proper hash of registry values" do
|
83
83
|
resource.values( { name: "poosh", type: :string, data: "carmen" } )
|
@@ -140,7 +140,7 @@ describe Chef::Resource::RegistryKey, "values" do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
describe Chef::Resource::RegistryKey, "recursive" do
|
143
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
143
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
144
144
|
|
145
145
|
it "allows a boolean" do
|
146
146
|
resource.recursive(true)
|
@@ -165,7 +165,7 @@ describe Chef::Resource::RegistryKey, "recursive" do
|
|
165
165
|
end
|
166
166
|
|
167
167
|
describe Chef::Resource::RegistryKey, "architecture" do
|
168
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
168
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
169
169
|
|
170
170
|
%i{i386 x86_64 machine}.each do |arch|
|
171
171
|
it "allows #{arch} as a symbol" do
|
@@ -196,7 +196,7 @@ describe Chef::Resource::RegistryKey, "architecture" do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
|
199
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
199
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
200
200
|
|
201
201
|
it "returns unsafe data as-is" do
|
202
202
|
key_values = [ { name: "poosh", type: :binary, data: 255.chr * 1 } ]
|
@@ -206,7 +206,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
|
|
206
206
|
end
|
207
207
|
|
208
208
|
describe Chef::Resource::RegistryKey, "state" do
|
209
|
-
let(:resource) { Chef::Resource::RegistryKey.new(
|
209
|
+
let(:resource) { Chef::Resource::RegistryKey.new("HKCU\\Software\\Raxicoricofallapatorius") }
|
210
210
|
|
211
211
|
it "returns scrubbed values" do
|
212
212
|
resource.values([ { name: "poosh", type: :binary, data: 255.chr * 1 } ])
|
@@ -45,6 +45,6 @@ describe Chef::Resource::WindowsAutorun do
|
|
45
45
|
|
46
46
|
it "coerces forward slashes to backslashes for the path" do
|
47
47
|
resource.path "C:/something.exe"
|
48
|
-
expect(resource.path).to eql(
|
48
|
+
expect(resource.path).to eql("C:\\something.exe")
|
49
49
|
end
|
50
50
|
end
|
@@ -76,7 +76,7 @@ describe Chef::Resource::WindowsFeaturePowershell do
|
|
76
76
|
node.default["powershell_features_cache"]["disabled"] = ["dhcp"]
|
77
77
|
node.default["powershell_features_cache"]["removed"] = ["snmp"]
|
78
78
|
resource.feature_name "dhcp, snmp"
|
79
|
-
resource.source
|
79
|
+
resource.source "D:\\sources\\sxs"
|
80
80
|
|
81
81
|
expect(provider.features_to_install).to eq(%w{dhcp snmp})
|
82
82
|
end
|
@@ -377,7 +377,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
377
377
|
resource.icmp_type("Any")
|
378
378
|
resource.firewall_action(:notconfigured)
|
379
379
|
resource.profile(:domain)
|
380
|
-
resource.program(
|
380
|
+
resource.program("%WINDIR%\\System32\\lsass.exe")
|
381
381
|
resource.service("SomeService")
|
382
382
|
resource.interface_type(:remoteaccess)
|
383
383
|
resource.enabled(false)
|
@@ -499,7 +499,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
499
499
|
resource.icmp_type("Any")
|
500
500
|
resource.firewall_action(:notconfigured)
|
501
501
|
resource.profile(:domain)
|
502
|
-
resource.program(
|
502
|
+
resource.program("%WINDIR%\\System32\\lsass.exe")
|
503
503
|
resource.service("SomeService")
|
504
504
|
resource.interface_type(:remoteaccess)
|
505
505
|
resource.enabled(false)
|
@@ -75,7 +75,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
75
75
|
context "a System User" do
|
76
76
|
before do
|
77
77
|
resource.frequency :hourly
|
78
|
-
resource.user
|
78
|
+
resource.user "NT AUTHORITY\\SYSTEM"
|
79
79
|
end
|
80
80
|
|
81
81
|
context "for an interactive task" do
|
@@ -88,7 +88,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
88
88
|
expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.")
|
89
89
|
end
|
90
90
|
it "does not raises an error even when user is in lowercase" do
|
91
|
-
resource.user
|
91
|
+
resource.user "nt authority\\system"
|
92
92
|
expect { resource.after_created }.to_not raise_error
|
93
93
|
end
|
94
94
|
end
|
@@ -103,7 +103,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
103
103
|
expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.")
|
104
104
|
end
|
105
105
|
it "does not raises an error even when user is in lowercase" do
|
106
|
-
resource.user
|
106
|
+
resource.user "nt authority\\system"
|
107
107
|
expect { resource.after_created }.to_not raise_error
|
108
108
|
end
|
109
109
|
end
|
@@ -494,7 +494,7 @@ describe Chef::ResourceReporter do
|
|
494
494
|
|
495
495
|
context "when the resource is a RegistryKey with binary data" do
|
496
496
|
let(:new_resource) do
|
497
|
-
resource = Chef::Resource::RegistryKey.new(
|
497
|
+
resource = Chef::Resource::RegistryKey.new("Wubba\\Lubba\\Dub\\Dubs")
|
498
498
|
resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ])
|
499
499
|
allow(resource).to receive(:cookbook_name).and_return(cookbook_name)
|
500
500
|
allow(resource).to receive(:cookbook_version).and_return(cookbook_version)
|
@@ -502,7 +502,7 @@ describe Chef::ResourceReporter do
|
|
502
502
|
end
|
503
503
|
|
504
504
|
let(:current_resource) do
|
505
|
-
resource = Chef::Resource::RegistryKey.new(
|
505
|
+
resource = Chef::Resource::RegistryKey.new("Wubba\\Lubba\\Dub\\Dubs")
|
506
506
|
resource.values([ { name: "rick", type: :binary, data: 255.chr * 1 } ])
|
507
507
|
resource
|
508
508
|
end
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -348,6 +348,11 @@ describe Chef::Resource do
|
|
348
348
|
it "should recognize dynamically defined resources" do
|
349
349
|
expect(resource.defined_at).to eq("dynamically defined")
|
350
350
|
end
|
351
|
+
|
352
|
+
it "should return nil for the cookbook_version when the cookbook_name is @recipe_files" do
|
353
|
+
resource.cookbook_name = "@recipe_files"
|
354
|
+
expect(resource.cookbook_version).to be nil
|
355
|
+
end
|
351
356
|
end
|
352
357
|
|
353
358
|
describe "to_s" do
|