chef 17.0.242-universal-mingw32 → 17.4.25-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 +4 -14
- data/Rakefile +2 -2
- data/chef.gemspec +10 -20
- data/lib/chef/action_collection.rb +6 -26
- data/lib/chef/application/base.rb +15 -0
- data/lib/chef/application.rb +4 -2
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/client.rb +7 -1
- data/lib/chef/compliance/default_attributes.rb +5 -3
- data/lib/chef/compliance/reporter/automate.rb +1 -1
- data/lib/chef/compliance/runner.rb +17 -3
- data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
- data/lib/chef/cookbook/gem_installer.rb +5 -1
- data/lib/chef/cookbook_version.rb +26 -4
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/data_collector.rb +0 -1
- data/lib/chef/deprecated.rb +14 -4
- data/lib/chef/dsl/declare_resource.rb +5 -10
- data/lib/chef/dsl/render_helpers.rb +44 -0
- data/lib/chef/dsl/secret.rb +64 -0
- data/lib/chef/dsl/toml.rb +116 -0
- data/lib/chef/dsl/universal.rb +5 -0
- data/lib/chef/dsl.rb +1 -0
- data/lib/chef/event_dispatch/base.rb +2 -1
- data/lib/chef/exceptions.rb +23 -0
- data/lib/chef/formatters/doc.rb +2 -1
- data/lib/chef/formatters/error_mapper.rb +2 -2
- data/lib/chef/handler/slow_report.rb +66 -0
- data/lib/chef/handler.rb +46 -8
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/node.rb +21 -20
- data/lib/chef/policy_builder/policyfile.rb +88 -45
- data/lib/chef/provider/directory.rb +6 -6
- data/lib/chef/provider/execute.rb +1 -1
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/launchd.rb +6 -6
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -1
- data/lib/chef/provider/package/dnf/dnf_helper.py +11 -10
- data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
- data/lib/chef/provider/package/habitat.rb +168 -0
- data/lib/chef/provider/package/powershell.rb +5 -0
- data/lib/chef/provider/package/yum/python_helper.rb +15 -10
- data/lib/chef/provider/package/yum/yum_helper.py +46 -62
- data/lib/chef/provider/package/yum.rb +1 -4
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +4 -4
- data/lib/chef/provider/support/yum_repo.erb +1 -1
- data/lib/chef/provider/support/zypper_repo.erb +4 -2
- data/lib/chef/provider/systemd_unit.rb +18 -17
- data/lib/chef/provider/template/content.rb +1 -1
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider/windows_script.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +27 -43
- data/lib/chef/provider/zypper_repository.rb +30 -34
- data/lib/chef/provider.rb +26 -1
- data/lib/chef/provider_resolver.rb +8 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/alternatives.rb +5 -5
- data/lib/chef/resource/apt_preference.rb +2 -2
- data/lib/chef/resource/apt_repository.rb +2 -2
- data/lib/chef/resource/apt_update.rb +4 -4
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/chef_client_config.rb +10 -5
- data/lib/chef/resource/chef_client_cron.rb +3 -3
- data/lib/chef/resource/chef_client_launchd.rb +3 -3
- data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
- data/lib/chef/resource/chef_client_systemd_timer.rb +3 -3
- data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/chef_vault_secret.rb +2 -2
- data/lib/chef/resource/chocolatey_feature.rb +2 -2
- data/lib/chef/resource/chocolatey_source.rb +1 -1
- data/lib/chef/resource/cron/cron_d.rb +4 -6
- data/lib/chef/resource/cron_access.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dsc_resource.rb +1 -1
- data/lib/chef/resource/execute.rb +5 -5
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +4 -4
- data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
- data/lib/chef/resource/habitat/habitat_package.rb +129 -0
- data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
- data/lib/chef/resource/habitat_config.rb +107 -0
- data/lib/chef/resource/habitat_install.rb +247 -0
- data/lib/chef/resource/habitat_service.rb +451 -0
- data/lib/chef/resource/habitat_user_toml.rb +92 -0
- data/lib/chef/resource/homebrew_cask.rb +18 -7
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +4 -3
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/hostname.rb +49 -7
- data/lib/chef/resource/inspec_waiver_file_entry.rb +156 -0
- data/lib/chef/resource/kernel_module.rb +6 -6
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/lwrp_base.rb +18 -3
- data/lib/chef/resource/macos_userdefaults.rb +2 -2
- data/lib/chef/resource/ohai_hint.rb +2 -6
- data/lib/chef/resource/openbsd_package.rb +17 -0
- data/lib/chef/resource/openssl_dhparam.rb +1 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -3
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -4
- data/lib/chef/resource/openssl_x509_crl.rb +1 -3
- data/lib/chef/resource/openssl_x509_request.rb +1 -3
- data/lib/chef/resource/osx_profile.rb +3 -3
- data/lib/chef/resource/plist.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +2 -4
- data/lib/chef/resource/reboot.rb +38 -9
- data/lib/chef/resource/remote_directory.rb +2 -2
- data/lib/chef/resource/remote_file.rb +3 -3
- data/lib/chef/resource/rhsm_errata.rb +0 -2
- data/lib/chef/resource/rhsm_errata_level.rb +1 -5
- data/lib/chef/resource/rhsm_repo.rb +15 -0
- data/lib/chef/resource/rhsm_subscription.rb +5 -5
- data/lib/chef/resource/ruby_block.rb +100 -0
- data/lib/chef/resource/scm/subversion.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
- data/lib/chef/resource/sudo.rb +2 -6
- data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
- data/lib/chef/resource/support/client.erb +8 -1
- data/lib/chef/resource/support/sup.toml.erb +179 -0
- data/lib/chef/resource/swap_file.rb +2 -6
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +3 -3
- data/lib/chef/resource/timezone.rb +1 -1
- data/lib/chef/resource/user_ulimit.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +2 -2
- data/lib/chef/resource/windows_audit_policy.rb +2 -2
- data/lib/chef/resource/windows_auto_run.rb +2 -2
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +163 -0
- data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
- data/lib/chef/resource/windows_dfs_folder.rb +2 -2
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
- data/lib/chef/resource/windows_dns_record.rb +2 -2
- data/lib/chef/resource/windows_dns_zone.rb +2 -2
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +3 -3
- data/lib/chef/resource/windows_feature_dism.rb +3 -5
- data/lib/chef/resource/windows_feature_powershell.rb +3 -3
- data/lib/chef/resource/windows_firewall_profile.rb +2 -2
- data/lib/chef/resource/windows_firewall_rule.rb +20 -6
- data/lib/chef/resource/windows_font.rb +2 -2
- data/lib/chef/resource/windows_pagefile.rb +104 -65
- data/lib/chef/resource/windows_path.rb +4 -4
- data/lib/chef/resource/windows_printer.rb +80 -61
- data/lib/chef/resource/windows_printer_port.rb +48 -65
- data/lib/chef/resource/windows_security_policy.rb +7 -4
- data/lib/chef/resource/windows_share.rb +2 -2
- data/lib/chef/resource/windows_shortcut.rb +1 -1
- data/lib/chef/resource/windows_task.rb +2 -2
- data/lib/chef/resource/windows_uac.rb +3 -5
- data/lib/chef/resource/windows_update_settings.rb +259 -0
- data/lib/chef/resource/windows_user_privilege.rb +2 -2
- data/lib/chef/resource/windows_workgroup.rb +2 -2
- data/lib/chef/resource/yum_package.rb +11 -15
- data/lib/chef/resource/zypper_package.rb +4 -4
- data/lib/chef/resource/zypper_repository.rb +28 -8
- data/lib/chef/resource.rb +20 -25
- data/lib/chef/resource_builder.rb +8 -2
- data/lib/chef/resource_inspector.rb +6 -2
- data/lib/chef/resource_reporter.rb +0 -1
- data/lib/chef/resources.rb +13 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
- data/lib/chef/secret_fetcher/azure_key_vault.rb +78 -0
- data/lib/chef/secret_fetcher/base.rb +76 -0
- data/lib/chef/secret_fetcher/example.rb +46 -0
- data/lib/chef/secret_fetcher.rb +55 -0
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +9 -2
- data/spec/data/knife-home/.chef/plugins/knife/example_home_subcommand.rb +0 -0
- data/spec/data/knife-site-subcommands/plugins/knife/example_subcommand.rb +0 -0
- data/spec/data/knife_subcommand/test_explicit_category.rb +7 -0
- data/spec/data/knife_subcommand/test_name_mapping.rb +4 -0
- data/spec/data/knife_subcommand/test_yourself.rb +21 -0
- data/spec/functional/mixin/from_file_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +857 -537
- data/spec/functional/resource/group_spec.rb +1 -1
- data/spec/functional/resource/link_spec.rb +1 -1
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/windows_env_spec.rb +2 -2
- data/spec/functional/resource/windows_hostname_spec.rb +91 -0
- data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
- data/spec/functional/resource/yum_package_spec.rb +495 -428
- data/spec/integration/client/client_spec.rb +0 -20
- data/spec/integration/compliance/compliance_spec.rb +1 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_action_spec.rb +6 -6
- data/spec/integration/recipes/unified_mode_spec.rb +70 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/knife.rb +37 -0
- data/spec/support/shared/integration/knife_support.rb +192 -0
- data/spec/support/shared/unit/knife_shared.rb +39 -0
- data/spec/support/shared/unit/provider/file.rb +3 -9
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
- data/spec/unit/compliance/runner_spec.rb +46 -2
- data/spec/unit/cookbook_version_spec.rb +52 -0
- data/spec/unit/data_collector_spec.rb +47 -1
- data/spec/unit/dsl/render_helpers_spec.rb +102 -0
- data/spec/unit/dsl/secret_spec.rb +71 -0
- data/spec/unit/handler_spec.rb +8 -2
- data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
- data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
- data/spec/unit/provider/apt_update_spec.rb +3 -1
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/mount/aix_spec.rb +1 -1
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
- data/spec/unit/provider/package/powershell_spec.rb +74 -12
- data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
- data/spec/unit/provider/service/systemd_service_spec.rb +2 -2
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/zypper_repository_spec.rb +3 -10
- data/spec/unit/provider_spec.rb +23 -0
- data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
- data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
- data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
- data/spec/unit/resource/systemd_unit_spec.rb +1 -1
- data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
- data/spec/unit/resource/windows_defender_spec.rb +71 -0
- data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
- data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
- data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
- data/spec/unit/resource/zypper_repository_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +19 -8
- data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
- data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +70 -0
- data/spec/unit/secret_fetcher_spec.rb +82 -0
- data/tasks/rspec.rb +4 -9
- metadata +65 -161
- data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
- data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
- data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
- data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
- data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
- data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
@@ -21,6 +21,7 @@ require "spec_helper"
|
|
21
21
|
|
22
22
|
describe Chef::Provider::Package::Yum::PythonHelper do
|
23
23
|
let(:helper) { Chef::Provider::Package::Yum::PythonHelper.instance }
|
24
|
+
before(:each) { Singleton.__init__(Chef::Provider::Package::Yum::PythonHelper) }
|
24
25
|
|
25
26
|
it "propagates stacktraces on stderr from the forked subprocess", :rhel do
|
26
27
|
allow(helper).to receive(:yum_command).and_return("ruby -e 'raise \"your hands in the air\"'")
|
@@ -313,7 +313,7 @@ describe Chef::Provider::Service::Systemd do
|
|
313
313
|
|
314
314
|
def with_systemctl_show(systemctl_path, stdout)
|
315
315
|
systemctl_show = [systemctl_path, "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", service_name]
|
316
|
-
expect(provider).to receive(:shell_out!).with(*systemctl_show
|
316
|
+
expect(provider).to receive(:shell_out!).with(*systemctl_show).and_return(double(stdout: stdout, exitstatus: 0, error?: false))
|
317
317
|
end
|
318
318
|
|
319
319
|
describe "systemd_service_status" do
|
@@ -341,7 +341,7 @@ describe Chef::Provider::Service::Systemd do
|
|
341
341
|
|
342
342
|
it "should error if '#{systemctl_path} --system show -p UnitFileState -p ActiveState service_name' returns non 0" do
|
343
343
|
systemctl_show = [systemctl_path, "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", service_name]
|
344
|
-
allow(provider).to receive(:shell_out!).with(*systemctl_show
|
344
|
+
allow(provider).to receive(:shell_out!).with(*systemctl_show).and_return(shell_out_failure)
|
345
345
|
expect { provider.systemd_service_status }.to raise_error(Chef::Exceptions::Service)
|
346
346
|
end
|
347
347
|
end
|
@@ -814,7 +814,7 @@ describe Chef::Provider::SystemdUnit, :linux_only do
|
|
814
814
|
|
815
815
|
def with_systemctl_show(systemctl_path, instance, opts, stdout)
|
816
816
|
systemctl_show = [systemctl_path, instance, "show", "-p", "UnitFileState", "-p", "ActiveState", unit_name]
|
817
|
-
expect(provider).to receive(:shell_out).with(*systemctl_show, opts).and_return(double(stdout: stdout, exitstatus: 0, error?: false))
|
817
|
+
expect(provider).to receive(:shell_out).with(*systemctl_show, **opts).and_return(double(stdout: stdout, exitstatus: 0, error?: false))
|
818
818
|
end
|
819
819
|
|
820
820
|
describe "systemd_unit_status" do
|
@@ -841,7 +841,7 @@ describe Chef::Provider::SystemdUnit, :linux_only do
|
|
841
841
|
current_resource.unit_name("foo@.service")
|
842
842
|
template_error = "Failed to get properties: Unit name foo@.service is neither a valid invocation ID nor unit name."
|
843
843
|
systemctl_show = [systemctl_path, "--system", "show", "-p", "UnitFileState", "-p", "ActiveState", "foo@.service"]
|
844
|
-
expect(provider).to receive(:shell_out).with(*systemctl_show
|
844
|
+
expect(provider).to receive(:shell_out).with(*systemctl_show).and_return(double(stdout: "", stderr: template_error, exitstatus: 1, error?: true))
|
845
845
|
expect(provider.systemd_unit_status).to eql({})
|
846
846
|
end
|
847
847
|
end
|
@@ -107,13 +107,6 @@ describe Chef::Provider::ZypperRepository do
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
describe "#cookbook_name" do
|
111
|
-
it "returns 'test' when the cookbook property is set" do
|
112
|
-
new_resource.cookbook("test")
|
113
|
-
expect(provider.cookbook_name).to eq("test")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
110
|
describe "#key_type" do
|
118
111
|
it "returns :remote_file with an http URL" do
|
119
112
|
expect(provider.key_type("https://www.chef.io/key")).to eq(:remote_file)
|
@@ -167,10 +160,10 @@ describe Chef::Provider::ZypperRepository do
|
|
167
160
|
end
|
168
161
|
end
|
169
162
|
|
170
|
-
describe "#
|
171
|
-
it "skips installing the key if
|
163
|
+
describe "#install_gpg_keys" do
|
164
|
+
it "skips installing the key if an empty array for key URL is passed" do
|
172
165
|
expect(logger).to receive(:debug)
|
173
|
-
provider.
|
166
|
+
provider.install_gpg_keys([])
|
174
167
|
end
|
175
168
|
end
|
176
169
|
end
|
data/spec/unit/provider_spec.rb
CHANGED
@@ -32,6 +32,21 @@ class NoWhyrunDemonstrator < Chef::Provider
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
class ActionDescriptionDemonstrator < Chef::Provider
|
36
|
+
def load_current_resource; end
|
37
|
+
|
38
|
+
action :foo, description: "foo described" do
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
action :foo2 do
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "blah" do
|
49
|
+
end
|
35
50
|
class ConvergeActionDemonstrator < Chef::Provider
|
36
51
|
attr_reader :system_state_altered
|
37
52
|
|
@@ -98,6 +113,14 @@ describe Chef::Provider do
|
|
98
113
|
expect(@provider.action_nothing).to eql(true)
|
99
114
|
end
|
100
115
|
|
116
|
+
it "should return an action description for action_description when one is available" do
|
117
|
+
expect(ActionDescriptionDemonstrator.action_description(:foo)).to eq "foo described"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return nil for action_description when no description is available" do
|
121
|
+
expect(ActionDescriptionDemonstrator.action_description(:none)).to eq nil
|
122
|
+
end
|
123
|
+
|
101
124
|
it "evals embedded recipes with a pristine resource collection" do
|
102
125
|
@provider.run_context.instance_variable_set(:@resource_collection, "doesn't matter what this is")
|
103
126
|
temporary_collection = nil
|
@@ -19,22 +19,40 @@ require "spec_helper"
|
|
19
19
|
|
20
20
|
describe Chef::Resource::HomebrewCask do
|
21
21
|
|
22
|
-
|
22
|
+
context "name with under bar" do
|
23
|
+
let(:resource) { Chef::Resource::HomebrewCask.new("fakey_fakerton") }
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
it "has a resource name of :homebrew_cask" do
|
26
|
+
expect(resource.resource_name).to eql(:homebrew_cask)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "the cask_name property is the name_property" do
|
30
|
+
expect(resource.cask_name).to eql("fakey_fakerton")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets the default action as :install" do
|
34
|
+
expect(resource.action).to eql([:install])
|
35
|
+
end
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
it "supports :install, :remove actions" do
|
38
|
+
expect { resource.action :install }.not_to raise_error
|
39
|
+
expect { resource.action :remove }.not_to raise_error
|
40
|
+
end
|
30
41
|
end
|
31
42
|
|
32
|
-
|
33
|
-
|
43
|
+
context "name with high fun" do
|
44
|
+
let(:resource) { Chef::Resource::HomebrewCask.new("fakey-fakerton") }
|
45
|
+
|
46
|
+
it "the cask_name property is the name_property" do
|
47
|
+
expect(resource.cask_name).to eql("fakey-fakerton")
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
|
-
|
37
|
-
|
38
|
-
|
51
|
+
context "name with at mark" do
|
52
|
+
let(:resource) { Chef::Resource::HomebrewCask.new("fakey-fakerton@10") }
|
53
|
+
|
54
|
+
it "the cask_name property is the name_property" do
|
55
|
+
expect(resource.cask_name).to eql("fakey-fakerton@10")
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Davin Taddeo (<davin@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 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::InspecWaiverFileEntry do
|
22
|
+
let(:log_str) { "this is my string to log" }
|
23
|
+
let(:resource) { Chef::Resource::InspecWaiverFileEntry.new("fakey_fakerton") }
|
24
|
+
|
25
|
+
it "has a name of inspec_waiver_file_entry" do
|
26
|
+
expect(resource.resource_name).to eq(:inspec_waiver_file_entry)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "setting the control property to a string does not raise error" do
|
30
|
+
expect { resource.control "my_test_control" }.not_to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets the default action as :add" do
|
34
|
+
expect(resource.action).to eql([:add])
|
35
|
+
end
|
36
|
+
|
37
|
+
it "supports :add action" do
|
38
|
+
expect { resource.action :add }.not_to raise_error
|
39
|
+
end
|
40
|
+
|
41
|
+
it "supports :remove action" do
|
42
|
+
expect { resource.action :remove }.not_to raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "expects expiration property to fail with date format YYYY/MM/DD" do
|
46
|
+
expect { resource.expiration "2022/09/23" }.to raise_error(Chef::Exceptions::ValidationFailed)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "expects expiration property to fail with invalid date 2022-02-31" do
|
50
|
+
expect { resource.expiration "2022-02-31" }.to raise_error(Chef::Exceptions::ValidationFailed)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "expects expiration property to match YYYY-MM-DD" do
|
54
|
+
expect { resource.expiration "2022-09-23" }.not_to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "expects the run_test property to fail validation when not a true/false value" do
|
58
|
+
expect { resource.run_test "yes" }.to raise_error(Chef::Exceptions::ValidationFailed)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "expects the run_test property to only accept true or false values" do
|
62
|
+
expect { resource.run_test true }.not_to raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
it "expects the justification property to accept a string value" do
|
66
|
+
expect { resource.justification "Because I don't want to run this compliance test" }.not_to raise_error
|
67
|
+
end
|
68
|
+
|
69
|
+
it "expects the justification property to fail if given a non-string value" do
|
70
|
+
expect { resource.justification true }.to raise_error(Chef::Exceptions::ValidationFailed)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "expects the backup property to fail validation when set to true" do
|
74
|
+
expect { resource.backup true }.to raise_error(Chef::Exceptions::ValidationFailed)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "expects the backup property to fail validation when passed a string" do
|
78
|
+
expect { resource.backup "please" }.to raise_error(Chef::Exceptions::ValidationFailed)
|
79
|
+
end
|
80
|
+
end
|
@@ -18,15 +18,24 @@
|
|
18
18
|
require "spec_helper"
|
19
19
|
|
20
20
|
describe Chef::Resource::RhsmSubscription do
|
21
|
-
let(:
|
22
|
-
let(:
|
21
|
+
let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new }
|
22
|
+
let(:node) { Chef::Node.new }
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, event_dispatch) }
|
24
|
+
|
25
|
+
let(:pool_id) { "8a8dd78c766232550226b46e59404aba" }
|
26
|
+
let(:resource) { Chef::Resource::RhsmSubscription.new(pool_id, run_context) }
|
27
|
+
let(:provider) { resource.provider_for_action(Array(resource.action).first) }
|
28
|
+
|
29
|
+
before do
|
30
|
+
allow(resource).to receive(:provider_for_action).with(:attach).and_return(provider)
|
31
|
+
end
|
23
32
|
|
24
33
|
it "has a resource name of :rhsm_subscription" do
|
25
34
|
expect(resource.resource_name).to eql(:rhsm_subscription)
|
26
35
|
end
|
27
36
|
|
28
37
|
it "the pool_id property is the name_property" do
|
29
|
-
expect(resource.pool_id).to eql(
|
38
|
+
expect(resource.pool_id).to eql(pool_id)
|
30
39
|
end
|
31
40
|
|
32
41
|
it "sets the default action as :attach" do
|
@@ -38,6 +47,44 @@ describe Chef::Resource::RhsmSubscription do
|
|
38
47
|
expect { resource.action :remove }.not_to raise_error
|
39
48
|
end
|
40
49
|
|
50
|
+
describe "#action_attach" do
|
51
|
+
let(:yum_package_double) { instance_double("Chef::Resource::YumPackage") }
|
52
|
+
let(:so_double) { instance_double("Mixlib::ShellOut", stdout: "Successfully attached a subscription for: My Subscription", exitstatus: 0, error?: false) }
|
53
|
+
|
54
|
+
before do
|
55
|
+
allow(provider).to receive(:shell_out!).with("subscription-manager attach --pool=#{resource.pool_id}").and_return(so_double)
|
56
|
+
allow(provider).to receive(:build_resource).with(:package, "rhsm_subscription-#{pool_id}-flush_cache").and_return(yum_package_double)
|
57
|
+
allow(yum_package_double).to receive(:run_action).with(:flush_cache)
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when already attached to pool" do
|
61
|
+
before do
|
62
|
+
allow(provider).to receive(:subscription_attached?).with(resource.pool_id).and_return(true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "does not attach to pool" do
|
66
|
+
expect(provider).not_to receive(:shell_out!)
|
67
|
+
resource.run_action(:attach)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when not attached to pool" do
|
72
|
+
before do
|
73
|
+
allow(provider).to receive(:subscription_attached?).with(resource.pool_id).and_return(false)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "attaches to pool" do
|
77
|
+
expect(provider).to receive(:shell_out!).with("subscription-manager attach --pool=#{resource.pool_id}")
|
78
|
+
resource.run_action(:attach)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "flushes package provider cache" do
|
82
|
+
expect(yum_package_double).to receive(:run_action).with(:flush_cache)
|
83
|
+
resource.run_action(:attach)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
41
88
|
describe "#subscription_attached?" do
|
42
89
|
let(:cmd) { double("cmd") }
|
43
90
|
let(:output) { "Pool ID: pool123" }
|
@@ -20,7 +20,7 @@ require "spec_helper"
|
|
20
20
|
|
21
21
|
describe Chef::Resource::SystemdUnit do
|
22
22
|
let(:resource) { Chef::Resource::SystemdUnit.new("sysstat-collect.timer") }
|
23
|
-
let(:unit_content_string) { "[Unit]\nDescription
|
23
|
+
let(:unit_content_string) { "[Unit]\nDescription=Run system activity accounting tool every 10 minutes\nDocumentation=foo\nDocumentation=bar\n\n[Timer]\nOnCalendar=*:00/10\n\n[Install]\nWantedBy=sysstat.service\n" }
|
24
24
|
let(:unit_content_hash) do
|
25
25
|
{
|
26
26
|
"Unit" => {
|
@@ -0,0 +1,62 @@
|
|
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::WindowsDefenderExclusion do
|
21
|
+
let(:resource) { Chef::Resource::WindowsDefenderExclusion.new("fakey_fakerton") }
|
22
|
+
|
23
|
+
it "sets resource name as :windows_defender_exclusion" do
|
24
|
+
expect(resource.resource_name).to eql(:windows_defender_exclusion)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets the default action as :add" do
|
28
|
+
expect(resource.action).to eql([:add])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "supports :add, :remove actions" do
|
32
|
+
expect { resource.action :add }.not_to raise_error
|
33
|
+
expect { resource.action :remove }.not_to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it "paths property defaults to []" do
|
37
|
+
expect(resource.paths).to eql([])
|
38
|
+
end
|
39
|
+
|
40
|
+
it "paths coerces strings to arrays" do
|
41
|
+
resource.paths "foo,bar"
|
42
|
+
expect(resource.paths).to eq(%w{foo bar})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "extensions property defaults to []" do
|
46
|
+
expect(resource.extensions).to eql([])
|
47
|
+
end
|
48
|
+
|
49
|
+
it "extensions coerces strings to arrays" do
|
50
|
+
resource.extensions "foo,bar"
|
51
|
+
expect(resource.extensions).to eq(%w{foo bar})
|
52
|
+
end
|
53
|
+
|
54
|
+
it "process_paths property defaults to []" do
|
55
|
+
expect(resource.process_paths).to eql([])
|
56
|
+
end
|
57
|
+
|
58
|
+
it "process_paths coerces strings to arrays" do
|
59
|
+
resource.process_paths "foo,bar"
|
60
|
+
expect(resource.process_paths).to eq(%w{foo bar})
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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::WindowsDefender do
|
21
|
+
let(:resource) { Chef::Resource::WindowsDefender.new("fakey_fakerton") }
|
22
|
+
|
23
|
+
it "sets resource name as :windows_defender" do
|
24
|
+
expect(resource.resource_name).to eql(:windows_defender)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets the default action as :enable" do
|
28
|
+
expect(resource.action).to eql([:enable])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "supports :enable, :disable actions" do
|
32
|
+
expect { resource.action :enable }.not_to raise_error
|
33
|
+
expect { resource.action :disable }.not_to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it "realtime_protection property defaults to true" do
|
37
|
+
expect(resource.realtime_protection).to eql(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "intrusion_protection_system property defaults to true" do
|
41
|
+
expect(resource.intrusion_protection_system).to eql(true)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "lock_ui property defaults to true" do
|
45
|
+
expect(resource.lock_ui).to eql(false)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "scan_archives property defaults to true" do
|
49
|
+
expect(resource.scan_archives).to eql(true)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "scan_scripts property defaults to true" do
|
53
|
+
expect(resource.scan_scripts).to eql(false)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "scan_email property defaults to true" do
|
57
|
+
expect(resource.scan_email).to eql(false)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "scan_removable_drives property defaults to true" do
|
61
|
+
expect(resource.scan_removable_drives).to eql(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "scan_network_files property defaults to true" do
|
65
|
+
expect(resource.scan_network_files).to eql(false)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "scan_mapped_drives property defaults to true" do
|
69
|
+
expect(resource.scan_mapped_drives).to eql(true)
|
70
|
+
end
|
71
|
+
end
|