chef 13.6.4 → 13.7.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +6 -6
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
@@ -229,7 +229,7 @@ module ResourceActionSpec
|
|
229
229
|
end
|
230
230
|
|
231
231
|
context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
|
232
|
-
before(:
|
232
|
+
before(:each) do
|
233
233
|
class ActionJackgrandson < ActionJackson
|
234
234
|
use_automatic_resource_name
|
235
235
|
end
|
@@ -509,7 +509,7 @@ module ResourceActionSpec
|
|
509
509
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
510
510
|
expect_converge do
|
511
511
|
has_property_named_template "hi"
|
512
|
-
end.to raise_error(/Property `template` of `has_property_named_template\[hi\]` was incorrectly passed a block.
|
512
|
+
end.to raise_error(/Property `template` of `has_property_named_template\[hi\]` was incorrectly passed a block. Possible property-resource collision. To call a resource named `template` either rename the property or else use `declare_resource\(:template, ...\)`/)
|
513
513
|
end
|
514
514
|
end
|
515
515
|
|
@@ -17,7 +17,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
17
17
|
before { Namer.current_index += 1 }
|
18
18
|
before { Namer.incrementing_value = 0 }
|
19
19
|
|
20
|
-
context "when the resource has identity, state and
|
20
|
+
context "when the resource has identity, state, control, and sensitive properties" do
|
21
21
|
let(:resource_name) { :"converge_if_changed_dsl#{Namer.current_index}" }
|
22
22
|
let(:resource_class) do
|
23
23
|
result = Class.new(Chef::Resource) do
|
@@ -28,6 +28,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
28
28
|
property :control1, desired_state: false, default: "default_control1"
|
29
29
|
property :state1, default: "default_state1"
|
30
30
|
property :state2, default: "default_state2"
|
31
|
+
property :sensitive1, default: "default_dontprintme", sensitive: true
|
31
32
|
attr_accessor :converged
|
32
33
|
def initialize(*args)
|
33
34
|
super
|
@@ -54,6 +55,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
54
55
|
resource_class.load_current_value do
|
55
56
|
state1 "current_state1"
|
56
57
|
state2 "current_state2"
|
58
|
+
sensitive1 "current_dontprintme"
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -134,6 +136,26 @@ EOM
|
|
134
136
|
end
|
135
137
|
end
|
136
138
|
|
139
|
+
context "and sensitive1 is set to a new value" do
|
140
|
+
let(:converge_recipe) do
|
141
|
+
<<-EOM
|
142
|
+
#{resource_name} 'blah' do
|
143
|
+
sensitive1 'new_dontprintme'
|
144
|
+
end
|
145
|
+
EOM
|
146
|
+
end
|
147
|
+
|
148
|
+
it "the resource updates sensitive1" do
|
149
|
+
expect(resource.converged).to eq 1
|
150
|
+
expect(resource.updated?).to be_truthy
|
151
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
152
|
+
* #{resource_name}[blah] action create
|
153
|
+
- update default_identity1
|
154
|
+
- set sensitive1 to (suppressed sensitive property)
|
155
|
+
EOM
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
137
159
|
context "and state1 is set to its current value but state2 is set to a new value" do
|
138
160
|
let(:converge_recipe) do
|
139
161
|
<<-EOM
|
@@ -244,19 +266,21 @@ EOM
|
|
244
266
|
expect(converged_recipe.stdout).to eq <<-EOM
|
245
267
|
* #{resource_name}[blah] action create
|
246
268
|
- create default_identity1
|
247
|
-
- set identity1
|
248
|
-
- set state1
|
249
|
-
- set state2
|
269
|
+
- set identity1 to "default_identity1" (default value)
|
270
|
+
- set state1 to "default_state1" (default value)
|
271
|
+
- set state2 to "default_state2" (default value)
|
272
|
+
- set sensitive1 to (suppressed sensitive property) (default value)
|
250
273
|
EOM
|
251
274
|
end
|
252
275
|
end
|
253
276
|
|
254
|
-
context "and state1 and
|
277
|
+
context "and state1, state2, and sensitive1 are set" do
|
255
278
|
let(:converge_recipe) do
|
256
279
|
<<-EOM
|
257
280
|
#{resource_name} 'blah' do
|
258
281
|
state1 'new_state1'
|
259
282
|
state2 'new_state2'
|
283
|
+
sensitive1 'new_dontprintme'
|
260
284
|
end
|
261
285
|
EOM
|
262
286
|
end
|
@@ -267,9 +291,10 @@ EOM
|
|
267
291
|
expect(converged_recipe.stdout).to eq <<-EOM
|
268
292
|
* #{resource_name}[blah] action create
|
269
293
|
- create default_identity1
|
270
|
-
- set identity1
|
271
|
-
- set state1
|
272
|
-
- set state2
|
294
|
+
- set identity1 to "default_identity1" (default value)
|
295
|
+
- set state1 to "new_state1"
|
296
|
+
- set state2 to "new_state2"
|
297
|
+
- set sensitive1 to (suppressed sensitive property)
|
273
298
|
EOM
|
274
299
|
end
|
275
300
|
end
|
@@ -291,9 +316,10 @@ EOM
|
|
291
316
|
expect(converged_recipe.stdout).to eq <<-EOM
|
292
317
|
* #{resource_name}[blah] action create
|
293
318
|
- create default_identity1
|
294
|
-
- set identity1
|
295
|
-
- set state1
|
296
|
-
- set state2
|
319
|
+
- set identity1 to (suppressed sensitive property) (default value)
|
320
|
+
- set state1 to (suppressed sensitive property)
|
321
|
+
- set state2 to (suppressed sensitive property)
|
322
|
+
- set sensitive1 to (suppressed sensitive property) (default value)
|
297
323
|
EOM
|
298
324
|
end
|
299
325
|
end
|
@@ -309,6 +335,9 @@ EOM
|
|
309
335
|
converge_if_changed :state2 do
|
310
336
|
new_resource.converged += 1
|
311
337
|
end
|
338
|
+
converge_if_changed :sensitive1 do
|
339
|
+
new_resource.converged += 1
|
340
|
+
end
|
312
341
|
end
|
313
342
|
end
|
314
343
|
|
@@ -412,6 +441,26 @@ EOM
|
|
412
441
|
expect(resource.updated?).to be_falsey
|
413
442
|
expect(converged_recipe.stdout).to eq <<-EOM
|
414
443
|
* #{resource_name}[blah] action create (up to date)
|
444
|
+
EOM
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
context "and sensitive1 is set to a new value" do
|
449
|
+
let(:converge_recipe) do
|
450
|
+
<<-EOM
|
451
|
+
#{resource_name} 'blah' do
|
452
|
+
sensitive1 'new_dontprintme'
|
453
|
+
end
|
454
|
+
EOM
|
455
|
+
end
|
456
|
+
|
457
|
+
it "the resource updates sensitive1" do
|
458
|
+
expect(resource.converged).to eq 1
|
459
|
+
expect(resource.updated?).to be_truthy
|
460
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
461
|
+
* #{resource_name}[blah] action create
|
462
|
+
- update default_identity1
|
463
|
+
- set sensitive1 to (suppressed sensitive property)
|
415
464
|
EOM
|
416
465
|
end
|
417
466
|
end
|
@@ -430,7 +479,7 @@ EOM
|
|
430
479
|
end
|
431
480
|
|
432
481
|
it "the resource is created" do
|
433
|
-
expect(resource.converged).to eq
|
482
|
+
expect(resource.converged).to eq 3
|
434
483
|
expect(resource.updated?).to be_truthy
|
435
484
|
expect(converged_recipe.stdout).to eq <<-EOM
|
436
485
|
* #{resource_name}[blah] action create
|
@@ -438,22 +487,25 @@ EOM
|
|
438
487
|
- set state1 to "default_state1" (default value)
|
439
488
|
- create default_identity1
|
440
489
|
- set state2 to "default_state2" (default value)
|
490
|
+
- create default_identity1
|
491
|
+
- set sensitive1 to (suppressed sensitive property) (default value)
|
441
492
|
EOM
|
442
493
|
end
|
443
494
|
end
|
444
495
|
|
445
|
-
context "and state1 and
|
496
|
+
context "and state1, state2, and sensitive1 are set to new values" do
|
446
497
|
let(:converge_recipe) do
|
447
498
|
<<-EOM
|
448
499
|
#{resource_name} 'blah' do
|
449
500
|
state1 'new_state1'
|
450
501
|
state2 'new_state2'
|
502
|
+
sensitive1 'new_dontprintme'
|
451
503
|
end
|
452
504
|
EOM
|
453
505
|
end
|
454
506
|
|
455
507
|
it "the resource is created" do
|
456
|
-
expect(resource.converged).to eq
|
508
|
+
expect(resource.converged).to eq 3
|
457
509
|
expect(resource.updated?).to be_truthy
|
458
510
|
expect(converged_recipe.stdout).to eq <<-EOM
|
459
511
|
* #{resource_name}[blah] action create
|
@@ -461,6 +513,8 @@ EOM
|
|
461
513
|
- set state1 to "new_state1"
|
462
514
|
- create default_identity1
|
463
515
|
- set state2 to "new_state2"
|
516
|
+
- create default_identity1
|
517
|
+
- set sensitive1 to (suppressed sensitive property)
|
464
518
|
EOM
|
465
519
|
end
|
466
520
|
end
|
@@ -477,7 +531,7 @@ EOM
|
|
477
531
|
end
|
478
532
|
|
479
533
|
it "the resource is created" do
|
480
|
-
expect(resource.converged).to eq
|
534
|
+
expect(resource.converged).to eq 3
|
481
535
|
expect(resource.updated?).to be_truthy
|
482
536
|
expect(converged_recipe.stdout).to eq <<-EOM
|
483
537
|
* #{resource_name}[blah] action create
|
@@ -485,6 +539,8 @@ EOM
|
|
485
539
|
- set state1 to (suppressed sensitive property)
|
486
540
|
- create default_identity1
|
487
541
|
- set state2 to (suppressed sensitive property)
|
542
|
+
- create default_identity1
|
543
|
+
- set sensitive1 to (suppressed sensitive property) (default value)
|
488
544
|
EOM
|
489
545
|
end
|
490
546
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -111,6 +111,11 @@ TEST_PLATFORM = TEST_NODE["platform"]
|
|
111
111
|
TEST_PLATFORM_VERSION = TEST_NODE["platform_version"]
|
112
112
|
TEST_PLATFORM_FAMILY = TEST_NODE["platform_family"]
|
113
113
|
|
114
|
+
provider_priority_map ||= nil
|
115
|
+
resource_priority_map ||= nil
|
116
|
+
provider_handler_map ||= nil
|
117
|
+
resource_handler_map ||= nil
|
118
|
+
|
114
119
|
RSpec.configure do |config|
|
115
120
|
config.include(Matchers)
|
116
121
|
config.include(MockShellout::RSpec)
|
@@ -233,6 +238,20 @@ RSpec.configure do |config|
|
|
233
238
|
|
234
239
|
# Set environment variable so the setting persists in child processes
|
235
240
|
ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"] = "1"
|
241
|
+
|
242
|
+
# we don't perfectly reset the priority/handler maps here, but by dup'ing the top level hash we
|
243
|
+
# throw away all the garbage resources and providers that we setup. if we mutate something like
|
244
|
+
# :package then that'll carry over from test-to-test, but the solution would be to deep-dup on every
|
245
|
+
# single test we run which is much more expensive. by throwing away the garbage top level keys we
|
246
|
+
# significantly speed up test runs.
|
247
|
+
provider_handler_map ||= Chef.provider_handler_map.send(:map).dup
|
248
|
+
resource_handler_map ||= Chef.resource_handler_map.send(:map).dup
|
249
|
+
provider_priority_map ||= Chef.provider_priority_map.send(:map).dup
|
250
|
+
resource_priority_map ||= Chef.resource_priority_map.send(:map).dup
|
251
|
+
Chef.provider_handler_map.instance_variable_set(:@map, provider_handler_map.dup)
|
252
|
+
Chef.resource_handler_map.instance_variable_set(:@map, resource_handler_map.dup)
|
253
|
+
Chef.provider_priority_map.instance_variable_set(:@map, provider_priority_map.dup)
|
254
|
+
Chef.resource_priority_map.instance_variable_set(:@map, resource_priority_map.dup)
|
236
255
|
end
|
237
256
|
|
238
257
|
# raise if anyone commits any test to CI with :focus set on it
|
@@ -63,7 +63,7 @@ shared_context "a command that can be executed as an alternate user" do
|
|
63
63
|
|
64
64
|
after do
|
65
65
|
File.delete(script_output_path) if File.exists?(script_output_path)
|
66
|
-
Dir.rmdir(script_output_dir) if Dir.
|
66
|
+
Dir.rmdir(script_output_dir) if Dir.exist?(script_output_dir)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -38,9 +38,11 @@ shared_examples_for "an application that loads a dot d" do
|
|
38
38
|
it "loads the configuration in order" do
|
39
39
|
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("foo 0")
|
40
40
|
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("bar 0")
|
41
|
+
expect(IO).to receive(:read).with(Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_return("strings 0")
|
41
42
|
allow(app).to receive(:apply_config).with(anything(), Chef::Config.platform_specific_path("/etc/chef/client.rb")).and_call_original.ordered
|
42
43
|
expect(app).to receive(:apply_config).with("foo 0", Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered
|
43
44
|
expect(app).to receive(:apply_config).with("bar 0", Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered
|
45
|
+
expect(app).to receive(:apply_config).with("strings 0", Pathname.new("#{client_d_dir}/02-strings.rb").cleanpath.to_s).and_call_original.ordered
|
44
46
|
app.reconfigure
|
45
47
|
end
|
46
48
|
end
|
@@ -139,7 +139,14 @@ shared_examples_for "an execute resource" do
|
|
139
139
|
it "should be true if the password is non-nil but the value is explicitly set to false" do
|
140
140
|
@resource.password("we.funk!")
|
141
141
|
@resource.sensitive false
|
142
|
-
expect(@resource.sensitive).to eq(
|
142
|
+
expect(@resource.sensitive).to eq(false)
|
143
|
+
end
|
144
|
+
|
145
|
+
# added this test to ensure setting of password property after or before sensitive does not matter
|
146
|
+
it "should be false if the sensitive is set before password property" do
|
147
|
+
@resource.sensitive false
|
148
|
+
@resource.password("we.funk!")
|
149
|
+
expect(@resource.sensitive).to eq(false)
|
143
150
|
end
|
144
151
|
|
145
152
|
end
|
@@ -476,7 +476,15 @@ shared_examples_for Chef::Provider::File do
|
|
476
476
|
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
|
477
477
|
provider.new_resource.verify windows? ? "REM" : "true"
|
478
478
|
provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
|
479
|
-
expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed)
|
479
|
+
expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, "Proposed content for #{provider.new_resource.path} failed verification #{windows? ? "cmd.exe /c exit 1" : "false"}")
|
480
|
+
end
|
481
|
+
|
482
|
+
it "does not show verification for sensitive resources" do
|
483
|
+
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
|
484
|
+
provider.new_resource.verify windows? ? "REM" : "true"
|
485
|
+
provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
|
486
|
+
provider.new_resource.sensitive true
|
487
|
+
expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, "Proposed content for #{provider.new_resource.path} failed verification [sensitive]")
|
480
488
|
end
|
481
489
|
end
|
482
490
|
end
|
@@ -66,14 +66,17 @@ describe Chef::ChefFS::DataHandler::DataBagItemDataHandler do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
context "
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
69
|
+
context "using a reserved word as part of the data bag name" do
|
70
|
+
%w{xnode rolex xenvironmentx xclientx}.each do |bag_name|
|
71
|
+
let(:entry) { TestDataBagItem.new("#{bag_name}", "bag") }
|
72
|
+
let(:object) do
|
73
|
+
{ "raw_data" => { "id" => "bag" } }
|
74
|
+
end
|
75
|
+
it "allows the data bag name '#{bag_name}'" do
|
76
|
+
expect(handler.verify_integrity(object, entry)).to be_nil
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
80
|
+
|
78
81
|
end
|
79
82
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Thom May (<thom@chef.io>)
|
3
|
-
# Copyright:: Copyright 2012-
|
3
|
+
# Copyright:: Copyright 2012-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -152,7 +152,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
after do
|
155
|
-
FileUtils.
|
155
|
+
FileUtils.rm_rf(tmp_dir)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
data/spec/unit/client_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe Chef::Client do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "runs ohai with only the minimum required plugins" do
|
41
|
-
expected_filter = %w{fqdn machinename hostname platform platform_version os os_version}
|
41
|
+
expected_filter = %w{fqdn machinename hostname platform platform_version ohai_time os os_version}
|
42
42
|
expect(ohai_system).to receive(:all_plugins).with(expected_filter)
|
43
43
|
client.run_ohai
|
44
44
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright 2013-
|
2
|
+
# Copyright:: Copyright 2013-2018, Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -29,7 +29,7 @@ describe Chef::Deprecated do
|
|
29
29
|
|
30
30
|
context "loading a deprecation class" do
|
31
31
|
it "loads the correct class" do
|
32
|
-
expect(Chef::Deprecated.create(:test_deprecation)).to be_an_instance_of(
|
32
|
+
expect(Chef::Deprecated.create(:test_deprecation)).to be_an_instance_of(TestDeprecation)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "optionally sets a message" do
|
@@ -49,11 +49,11 @@ describe Chef::Deprecated do
|
|
49
49
|
let(:location) { "the location" }
|
50
50
|
|
51
51
|
it "displays the full URL" do
|
52
|
-
expect(
|
52
|
+
expect(TestDeprecation.new().url).to eql("#{base_url}test.html")
|
53
53
|
end
|
54
54
|
|
55
55
|
it "formats a complete deprecation message" do
|
56
|
-
expect(
|
56
|
+
expect(TestDeprecation.new(message, location).inspect).to eql("#{message} (CHEF-999)#{location}.\nhttps://docs.chef.io/deprecations_test.html")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/spec/unit/http_spec.rb
CHANGED
@@ -93,6 +93,15 @@ describe Chef::HTTP do
|
|
93
93
|
expect { http.send(:stream_to_tempfile, uri, resp) }.to raise_error("TestError")
|
94
94
|
end
|
95
95
|
|
96
|
+
it "accepts a tempfile" do
|
97
|
+
resp = Net::HTTPOK.new("1.1", 200, "OK")
|
98
|
+
http = Chef::HTTP.new(uri)
|
99
|
+
tempfile = Tempfile.open("tempy-mctempfile")
|
100
|
+
expect(Tempfile).not_to receive(:open)
|
101
|
+
expect(resp).to receive(:read_body).and_yield("conty-mccontent")
|
102
|
+
http.send(:stream_to_tempfile, uri, resp, tempfile)
|
103
|
+
expect(IO.read(tempfile.path)).to eql("conty-mccontent")
|
104
|
+
end
|
96
105
|
end
|
97
106
|
|
98
107
|
describe "head" do
|
@@ -516,6 +516,11 @@ describe Chef::Knife::Bootstrap do
|
|
516
516
|
end
|
517
517
|
|
518
518
|
context "a flat directory structure" do
|
519
|
+
it "escapes single-quotes" do
|
520
|
+
expect(rendered_template).to match("cat > /etc/chef/client.d/02-strings.rb <<'EOP'")
|
521
|
+
expect(rendered_template).to match("something '\\\\''/foo/bar'\\\\''")
|
522
|
+
end
|
523
|
+
|
519
524
|
it "creates a file 00-foo.rb" do
|
520
525
|
expect(rendered_template).to match("cat > /etc/chef/client.d/00-foo.rb <<'EOP'")
|
521
526
|
expect(rendered_template).to match("d6f9b976-289c-4149-baf7-81e6ffecf228")
|
@@ -124,55 +124,12 @@ describe Chef::Knife::Configure do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
it "asks the user for the location of a chef repo" do
|
128
|
-
@knife.ask_user_for_config
|
129
|
-
expect(@out.string).to match(Regexp.escape("Please enter the path to a chef repository (or leave blank):"))
|
130
|
-
expect(@knife.chef_repo).to eq("")
|
131
|
-
end
|
132
|
-
|
133
|
-
it "asks the users for the name of the validation client" do
|
134
|
-
@knife.ask_user_for_config
|
135
|
-
expect(@out.string).to match(Regexp.escape("Please enter the validation clientname: [chef-validator]"))
|
136
|
-
expect(@knife.validation_client_name).to eq("chef-validator")
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should not ask the users for the name of the validation client if --validation_client_name is specified" do
|
140
|
-
@knife.config[:validation_client_name] = "my-validator"
|
141
|
-
@knife.ask_user_for_config
|
142
|
-
expect(@out.string).not_to match(Regexp.escape("Please enter the validation clientname:"))
|
143
|
-
expect(@knife.validation_client_name).to eq("my-validator")
|
144
|
-
end
|
145
|
-
|
146
|
-
it "asks the users for the location of the validation key" do
|
147
|
-
@knife.ask_user_for_config
|
148
|
-
expect(@out.string).to match(Regexp.escape("Please enter the location of the validation key: [#{default_validator_key}]"))
|
149
|
-
if windows?
|
150
|
-
expect(@knife.validation_key.capitalize).to eq(default_validator_key_win32.capitalize)
|
151
|
-
else
|
152
|
-
expect(@knife.validation_key).to eq(default_validator_key)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should not ask the users for the location of the validation key if --validation_key is specified" do
|
157
|
-
@knife.config[:validation_key] = "/home/you/.chef/my-validation.pem"
|
158
|
-
@knife.ask_user_for_config
|
159
|
-
expect(@out.string).not_to match(Regexp.escape("Please enter the location of the validation key:"))
|
160
|
-
if windows?
|
161
|
-
expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$}
|
162
|
-
else
|
163
|
-
expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem")
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
127
|
it "should not ask the user for anything if -i and all other properties are specified" do
|
168
128
|
@knife.config[:initial] = true
|
169
129
|
@knife.config[:chef_server_url] = "http://localhost:5000"
|
170
130
|
@knife.config[:node_name] = "testnode"
|
171
131
|
@knife.config[:admin_client_name] = "my-webui"
|
172
132
|
@knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem"
|
173
|
-
@knife.config[:validation_client_name] = "my-validator"
|
174
|
-
@knife.config[:validation_key] = "/home/you/.chef/my-validation.pem"
|
175
|
-
@knife.config[:repository] = ""
|
176
133
|
@knife.config[:client_key] = "/home/you/a-new-user.pem"
|
177
134
|
allow(Etc).to receive(:getlogin).and_return("a-new-user")
|
178
135
|
|
@@ -184,40 +141,33 @@ describe Chef::Knife::Configure do
|
|
184
141
|
expect(@knife.admin_client_name).to eq("my-webui")
|
185
142
|
if windows?
|
186
143
|
expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$}
|
187
|
-
expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$}
|
188
144
|
expect(@knife.new_client_key).to match %r{^[A-Za-z]:/home/you/a-new-user\.pem$}
|
189
145
|
else
|
190
146
|
expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem")
|
191
|
-
expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem")
|
192
147
|
expect(@knife.new_client_key).to eq("/home/you/a-new-user.pem")
|
193
148
|
end
|
194
|
-
expect(@knife.validation_client_name).to eq("my-validator")
|
195
|
-
expect(@knife.chef_repo).to eq("")
|
196
149
|
end
|
197
150
|
|
198
151
|
it "writes the new data to a config file" do
|
199
|
-
allow(
|
152
|
+
allow(Chef::Util::PathHelper).to receive(:home).with(".chef").and_return("/home/you/.chef")
|
153
|
+
allow(File).to receive(:expand_path).with("/home/you/.chef/credentials").and_return("/home/you/.chef/credentials")
|
200
154
|
allow(File).to receive(:expand_path).with("/home/you/.chef/#{Etc.getlogin}.pem").and_return("/home/you/.chef/#{Etc.getlogin}.pem")
|
201
|
-
allow(File).to receive(:expand_path).with(default_validator_key).and_return(default_validator_key)
|
202
155
|
allow(File).to receive(:expand_path).with(default_admin_key).and_return(default_admin_key)
|
203
156
|
expect(FileUtils).to receive(:mkdir_p).with("/home/you/.chef")
|
204
157
|
config_file = StringIO.new
|
205
|
-
expect(::File).to receive(:open).with("/home/you/.chef/
|
158
|
+
expect(::File).to receive(:open).with("/home/you/.chef/credentials", "w").and_yield config_file
|
206
159
|
@knife.config[:repository] = "/home/you/chef-repo"
|
207
160
|
@knife.run
|
208
|
-
expect(config_file.string).to match(/^
|
209
|
-
expect(config_file.string).to match(%r{^client_key[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$})
|
210
|
-
expect(config_file.string).to match(
|
211
|
-
expect(config_file.string).to match(%r{^validation_key\s+'#{default_validator_key}'$})
|
212
|
-
expect(config_file.string).to match(%r{^chef_server_url\s+'#{default_server_url}'$})
|
213
|
-
expect(config_file.string).to match(%r{cookbook_path\s+\[ '/home/you/chef-repo/cookbooks' \]})
|
161
|
+
expect(config_file.string).to match(/^client_name[\s]+=[\s]+'#{Etc.getlogin}'$/)
|
162
|
+
expect(config_file.string).to match(%r{^client_key[\s]+=[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$})
|
163
|
+
expect(config_file.string).to match(%r{^chef_server_url\s+=[\s]+'#{default_server_url}'$})
|
214
164
|
end
|
215
165
|
|
216
166
|
it "creates a new client when given the --initial option" do
|
217
|
-
|
167
|
+
allow(Chef::Util::PathHelper).to receive(:home).with(".chef").and_return("/home/you/.chef")
|
168
|
+
expect(File).to receive(:expand_path).with("/home/you/.chef/credentials").and_return("/home/you/.chef/credentials")
|
218
169
|
expect(File).to receive(:expand_path).with("/home/you/.chef/a-new-user.pem").and_return("/home/you/.chef/a-new-user.pem")
|
219
|
-
|
220
|
-
expect(File).to receive(:expand_path).with(default_admin_key).and_return(default_admin_key)
|
170
|
+
allow(File).to receive(:expand_path).with(default_admin_key).and_return(default_admin_key)
|
221
171
|
Chef::Config[:node_name] = "webmonkey.example.com"
|
222
172
|
|
223
173
|
user_command = Chef::Knife::UserCreate.new
|
@@ -227,7 +177,7 @@ describe Chef::Knife::Configure do
|
|
227
177
|
|
228
178
|
allow(Chef::Knife::UserCreate).to receive(:new).and_return(user_command)
|
229
179
|
expect(FileUtils).to receive(:mkdir_p).with("/home/you/.chef")
|
230
|
-
expect(::File).to receive(:open).with("/home/you/.chef/
|
180
|
+
expect(::File).to receive(:open).with("/home/you/.chef/credentials", "w")
|
231
181
|
@knife.config[:initial] = true
|
232
182
|
@knife.config[:user_password] = "blah"
|
233
183
|
@knife.run
|