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
@@ -85,7 +85,12 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
85
85
|
|
86
86
|
it "the remote_address property accepts strings" do
|
87
87
|
resource.remote_address("8.8.4.4")
|
88
|
-
expect(resource.remote_address).to eql("8.8.4.4")
|
88
|
+
expect(resource.remote_address).to eql(["8.8.4.4"])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "the remote_address property accepts comma separated lists" do
|
92
|
+
resource.remote_address(["10.17.3.101", "172.7.7.53"])
|
93
|
+
expect(resource.remote_address).to eql(%w{10.17.3.101 172.7.7.53})
|
89
94
|
end
|
90
95
|
|
91
96
|
it "the remote_port property accepts strings" do
|
@@ -223,8 +228,8 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
223
228
|
end
|
224
229
|
|
225
230
|
it "aliases :remoteip to :remote_address" do
|
226
|
-
resource.remoteip("8.8.8.8")
|
227
|
-
expect(resource.remote_address).to eql("8.8.8.8")
|
231
|
+
resource.remoteip(["8.8.8.8"])
|
232
|
+
expect(resource.remote_address).to eql(["8.8.8.8"])
|
228
233
|
end
|
229
234
|
|
230
235
|
it "aliases :localport to :local_port" do
|
@@ -288,7 +293,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
288
293
|
end
|
289
294
|
|
290
295
|
it "sets RemoteAddress" do
|
291
|
-
resource.remote_address("8.8.8.8")
|
296
|
+
resource.remote_address(["8.8.8.8"])
|
292
297
|
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -RemoteAddress '8.8.8.8' -Direction 'inbound' -Protocol 'TCP' -IcmpType 'Any' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
293
298
|
end
|
294
299
|
|
@@ -365,7 +370,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
365
370
|
resource.group("new group")
|
366
371
|
resource.local_address("192.168.40.40")
|
367
372
|
resource.local_port("80")
|
368
|
-
resource.remote_address("8.8.4.4")
|
373
|
+
resource.remote_address(["8.8.4.4"])
|
369
374
|
resource.remote_port("8081")
|
370
375
|
resource.direction(:outbound)
|
371
376
|
resource.protocol("UDP")
|
@@ -416,7 +421,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
416
421
|
end
|
417
422
|
|
418
423
|
it "sets RemoteAddress" do
|
419
|
-
resource.remote_address("8.8.8.8")
|
424
|
+
resource.remote_address(["8.8.8.8"])
|
420
425
|
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -NewDisplayName 'test_rule' -RemoteAddress '8.8.8.8' -Direction 'inbound' -Protocol 'TCP' -IcmpType 'Any' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
421
426
|
end
|
422
427
|
|
@@ -487,7 +492,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
487
492
|
resource.displayname("some cool display name")
|
488
493
|
resource.local_address("192.168.40.40")
|
489
494
|
resource.local_port("80")
|
490
|
-
resource.remote_address("8.8.4.4")
|
495
|
+
resource.remote_address(["8.8.4.4"])
|
491
496
|
resource.remote_port("8081")
|
492
497
|
resource.direction(:outbound)
|
493
498
|
resource.protocol("UDP")
|
@@ -18,14 +18,14 @@
|
|
18
18
|
require "spec_helper"
|
19
19
|
|
20
20
|
describe Chef::Resource::WindowsPagefile do
|
21
|
-
let(:resource) { Chef::Resource::WindowsPagefile.new("
|
21
|
+
let(:resource) { Chef::Resource::WindowsPagefile.new("c:\\pagefile.sys") }
|
22
22
|
|
23
23
|
it "sets resource name as :windows_pagefile" do
|
24
24
|
expect(resource.resource_name).to eql(:windows_pagefile)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "the path property is the name_property" do
|
28
|
-
expect(resource.path).to eql("
|
28
|
+
expect(resource.path).to eql("c:\\pagefile.sys")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "sets the default action as :set" do
|
@@ -38,12 +38,7 @@ describe Chef::Resource::WindowsPagefile do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "coerces forward slashes in the path property to back slashes" do
|
41
|
-
resource.path "
|
42
|
-
expect(resource.path).to eql("
|
41
|
+
resource.path "c:/pagefile.sys"
|
42
|
+
expect(resource.path).to eql("c:\\pagefile.sys")
|
43
43
|
end
|
44
|
-
|
45
|
-
it "automatic_managed property defaults to false" do
|
46
|
-
expect(resource.automatic_managed).to eql(false)
|
47
|
-
end
|
48
|
-
|
49
44
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
# Author:: Tim Smith (tsmith@chef.io)
|
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::WindowsUpdateSettings do
|
22
|
+
let(:resource) { Chef::Resource::WindowsUpdateSettings.new("foobar") }
|
23
|
+
|
24
|
+
it "sets resource name as :windows_update_settings" do
|
25
|
+
expect(resource.resource_name).to eql(:windows_update_settings)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the default action as :set" do
|
29
|
+
expect(resource.action).to eql([:set])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "supports :set and legacy :enable actions" do
|
33
|
+
expect { resource.action :set }.not_to raise_error
|
34
|
+
expect { resource.action :enable }.not_to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it "raises an error if scheduled_install_day isn't a validate day" do
|
38
|
+
expect { resource.scheduled_install_day "Saturday" }.not_to raise_error
|
39
|
+
expect { resource.scheduled_install_day "Sunday" }.not_to raise_error
|
40
|
+
expect { resource.scheduled_install_day "Extraday" }.to raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an error if automatic_update_option isn't a validate option" do
|
44
|
+
expect { resource.automatic_update_option 2 }.not_to raise_error
|
45
|
+
expect { resource.automatic_update_option :notify }.not_to raise_error
|
46
|
+
expect { resource.automatic_update_option :nope }.to raise_error(ArgumentError)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "coerces legacy Integer value in automatic_update_option to friendly symbol" do
|
50
|
+
resource.automatic_update_option 2
|
51
|
+
expect(resource.automatic_update_option).to eql(:notify)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "raises an error if scheduled_install_hour isn't a 24 hour clock hour" do
|
55
|
+
expect { resource.scheduled_install_hour 2 }.not_to raise_error
|
56
|
+
expect { resource.scheduled_install_hour 0 }.to raise_error(ArgumentError)
|
57
|
+
expect { resource.scheduled_install_hour 25 }.to raise_error(ArgumentError)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "raises an error if custom_detection_frequency isn't a valid frequency" do
|
61
|
+
expect { resource.custom_detection_frequency 0 }.not_to raise_error
|
62
|
+
expect { resource.custom_detection_frequency 23 }.to raise_error(ArgumentError)
|
63
|
+
end
|
64
|
+
end
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -1172,21 +1172,23 @@ describe Chef::Resource do
|
|
1172
1172
|
action :base_action3, description: "unmodified base action 3 desc" do; end
|
1173
1173
|
end
|
1174
1174
|
|
1175
|
+
let(:resource_inst) { TestResource.new("TestResource", nil) }
|
1176
|
+
|
1175
1177
|
it "returns nil when no description was provided for the action" do
|
1176
|
-
expect(
|
1178
|
+
expect(resource_inst.action_description(:base_action0)).to eql(nil)
|
1177
1179
|
end
|
1178
1180
|
|
1179
1181
|
context "when action definition is a string" do
|
1180
1182
|
it "returns the description whether a symbol or string is used to look it up" do
|
1181
|
-
expect(
|
1182
|
-
expect(
|
1183
|
+
expect(resource_inst.action_description("string_action")).to eql("a string test")
|
1184
|
+
expect(resource_inst.action_description(:string_action)).to eql("a string test")
|
1183
1185
|
end
|
1184
1186
|
end
|
1185
1187
|
|
1186
1188
|
context "when action definition is a symbol" do
|
1187
1189
|
it "returns the description whether a symbol or string is used to look up" do
|
1188
|
-
expect(
|
1189
|
-
expect(
|
1190
|
+
expect(resource_inst.action_description("symbol_action")).to eql("a symbol test")
|
1191
|
+
expect(resource_inst.action_description(:symbol_action)).to eql("a symbol test")
|
1190
1192
|
end
|
1191
1193
|
end
|
1192
1194
|
|
@@ -1196,14 +1198,23 @@ describe Chef::Resource do
|
|
1196
1198
|
action :base_action3 do; end
|
1197
1199
|
end
|
1198
1200
|
|
1201
|
+
class TestResourceChild2 < TestResource
|
1202
|
+
# We should never see this description
|
1203
|
+
action :base_action2, description: "if you see this in an error, TestResourceChild was polluted with this description" do; end
|
1204
|
+
end
|
1205
|
+
let(:resource_inst) { TestResourceChild.new("TestResource", nil) }
|
1206
|
+
|
1199
1207
|
it "returns original description when a described action is not overridden in child resource" do
|
1200
|
-
expect(
|
1208
|
+
expect(resource_inst.action_description(:base_action1)).to eq "unmodified base action 1 desc"
|
1201
1209
|
end
|
1202
1210
|
it "returns original description when the child resource overrides an inherited action but NOT its description" do
|
1203
|
-
expect(
|
1211
|
+
expect(resource_inst.action_description(:base_action3)).to eq "unmodified base action 3 desc"
|
1212
|
+
end
|
1213
|
+
it "returns new description when the child resource overrides an inherited action and its description" do
|
1214
|
+
expect(resource_inst.action_description(:base_action2)).to eq "modified base action 2 desc"
|
1204
1215
|
end
|
1205
1216
|
it "returns new description when the child resource overrides an inherited action and its description" do
|
1206
|
-
expect(
|
1217
|
+
expect(resource_inst.action_description(:base_action2)).to eq "modified base action 2 desc"
|
1207
1218
|
end
|
1208
1219
|
end
|
1209
1220
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Marc Paradise <marc@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
|
+
|
20
|
+
require_relative "../../spec_helper"
|
21
|
+
require "chef/secret_fetcher/aws_secrets_manager"
|
22
|
+
|
23
|
+
describe Chef::SecretFetcher::AWSSecretsManager do
|
24
|
+
let(:node) { {} }
|
25
|
+
let(:aws_global_config) { {} }
|
26
|
+
let(:fetcher_config) { {} }
|
27
|
+
let(:run_context) { double("run_context", node: node) }
|
28
|
+
let(:fetcher) {
|
29
|
+
Chef::SecretFetcher::AWSSecretsManager.new( fetcher_config, run_context )
|
30
|
+
}
|
31
|
+
|
32
|
+
before do
|
33
|
+
allow(Aws).to receive(:config).and_return(aws_global_config)
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when region is provided" do
|
37
|
+
let(:fetcher_config) { { region: "region-from-caller" } }
|
38
|
+
it "uses the provided region" do
|
39
|
+
fetcher.validate!
|
40
|
+
expect(fetcher.config[:region]).to eq "region-from-caller"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when region is not provided" do
|
45
|
+
context "and no region exists in AWS config or node attributes" do
|
46
|
+
it "raises a ConfigurationInvalid error" do
|
47
|
+
expect { fetcher.validate! }.to raise_error Chef::Exceptions::Secret::ConfigurationInvalid
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and region exists in AWS config and node attributes" do
|
52
|
+
let(:aws_global_config) { { region: "region-from-aws-global-config" } }
|
53
|
+
let(:node) { { "ec2" => { "region" => "region-from-ohai-data" } } }
|
54
|
+
it "uses the region from AWS config" do
|
55
|
+
fetcher.validate!
|
56
|
+
expect(fetcher.config[:region]).to eq "region-from-aws-global-config"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "and region exists only in node attributes" do
|
61
|
+
let(:node) { { "ec2" => { "region" => "region-from-ohai-data" } } }
|
62
|
+
it "uses the region from AWS config" do
|
63
|
+
fetcher.validate!
|
64
|
+
expect(fetcher.config[:region]).to eq "region-from-ohai-data"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# Author:: Marc Paradise <marc@chef.io>
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require_relative "../../spec_helper"
|
21
|
+
require "chef/secret_fetcher"
|
22
|
+
require "chef/secret_fetcher/azure_key_vault"
|
23
|
+
|
24
|
+
describe Chef::SecretFetcher::AzureKeyVault do
|
25
|
+
let(:config) { { vault: "my_vault" } }
|
26
|
+
let(:fetcher) { Chef::SecretFetcher::AzureKeyVault.new(config, nil) }
|
27
|
+
|
28
|
+
context "when performing a fetch" do
|
29
|
+
let(:body) { '{ "value" : "my secret value" }' }
|
30
|
+
let(:response_mock) { double("response", body: body) }
|
31
|
+
let(:http_mock) { double("http", :get => response_mock, :use_ssl= => nil) }
|
32
|
+
|
33
|
+
before do
|
34
|
+
allow(fetcher).to receive(:fetch_token).and_return "a token"
|
35
|
+
allow(Net::HTTP).to receive(:new).and_return(http_mock)
|
36
|
+
end
|
37
|
+
|
38
|
+
context "and vault name is only provided in the secret name" do
|
39
|
+
let(:body) { '{ "value" : "my secret value" }' }
|
40
|
+
let(:config) { {} }
|
41
|
+
it "fetches the value" do
|
42
|
+
expect(fetcher.fetch("my_vault/value")).to eq "my secret value"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "and vault name is not provided in the secret name" do
|
47
|
+
context "and vault name is not provided in config" do
|
48
|
+
let(:config) { {} }
|
49
|
+
it "raises a ConfigurationInvalid exception" do
|
50
|
+
expect { fetcher.fetch("value") }.to raise_error(Chef::Exceptions::Secret::ConfigurationInvalid)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "and vault name is provided in config" do
|
55
|
+
let(:config) { { vault: "my_vault" } }
|
56
|
+
it "fetches the value" do
|
57
|
+
expect(fetcher.fetch("value")).to eq "my secret value"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
context "and an error response is received in the body" do
|
62
|
+
let(:config) { { vault: "my_vault" } }
|
63
|
+
let(:body) { '{ "error" : { "code" : 404, "message" : "secret not found" } }' }
|
64
|
+
it "raises FetchFailed" do
|
65
|
+
expect { fetcher.fetch("value") }.to raise_error(Chef::Exceptions::Secret::FetchFailed)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Marc Paradise <marc@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 "chef/secret_fetcher"
|
20
|
+
require "chef/secret_fetcher/example"
|
21
|
+
|
22
|
+
class SecretFetcherImpl < Chef::SecretFetcher::Base
|
23
|
+
def do_fetch(name, version)
|
24
|
+
name
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate!; end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe Chef::SecretFetcher do
|
31
|
+
let(:fetcher_impl) { SecretFetcherImpl.new({}, nil) }
|
32
|
+
|
33
|
+
before do
|
34
|
+
allow(Chef::SecretFetcher::Example).to receive(:new).and_return fetcher_impl
|
35
|
+
end
|
36
|
+
|
37
|
+
context ".for_service" do
|
38
|
+
it "resolves the example fetcher without error" do
|
39
|
+
Chef::SecretFetcher.for_service(:example, {}, nil)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "resolves the Azure Key Vault fetcher without error" do
|
43
|
+
Chef::SecretFetcher.for_service(:azure_key_vault, { vault: "invalid" }, nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "resolves the AWS fetcher without error" do
|
47
|
+
Chef::SecretFetcher.for_service(:aws_secrets_manager, { region: "invalid" }, nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises Chef::Exceptions::Secret::MissingFetcher when service is blank" do
|
51
|
+
expect { Chef::SecretFetcher.for_service(nil, {}, nil) }.to raise_error(Chef::Exceptions::Secret::MissingFetcher)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "raises Chef::Exceptions::Secret::MissingFetcher when service is nil" do
|
55
|
+
expect { Chef::SecretFetcher.for_service("", {}, nil) }.to raise_error(Chef::Exceptions::Secret::MissingFetcher)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises Chef::Exceptions::Secret::InvalidFetcher for an unknown fetcher" do
|
59
|
+
expect { Chef::SecretFetcher.for_service(:bad_example, {}, nil) }.to raise_error(Chef::Exceptions::Secret::InvalidFetcherService)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "ensures fetcher configuration is valid by invoking validate!" do
|
63
|
+
expect(fetcher_impl).to receive(:validate!)
|
64
|
+
Chef::SecretFetcher.for_service(:example, {}, nil)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "#fetch" do
|
69
|
+
let(:fetcher) {
|
70
|
+
Chef::SecretFetcher.for_service(:example, { "key1" => "value1" }, nil)
|
71
|
+
}
|
72
|
+
|
73
|
+
it "fetches from the underlying service when secret name is provided " do
|
74
|
+
expect(fetcher_impl).to receive(:fetch).with("key1", "v1")
|
75
|
+
fetcher.fetch("key1", "v1")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "raises an error when the secret name is not provided" do
|
79
|
+
expect { fetcher.fetch(nil) }.to raise_error(Chef::Exceptions::Secret::MissingSecretName)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|