chef 17.1.35-universal-mingw32 → 17.4.38-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +6 -4
- data/chef.gemspec +1 -0
- 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/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 +16 -2
- 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/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 +14 -13
- data/lib/chef/formatters/error_mapper.rb +2 -2
- data/lib/chef/formatters/minimal.rb +6 -5
- data/lib/chef/handler/slow_report.rb +66 -0
- data/lib/chef/handler.rb +46 -8
- data/lib/chef/http.rb +5 -5
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/node.rb +20 -19
- data/lib/chef/policy_builder/policyfile.rb +88 -45
- 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/lwrp_base.rb +1 -1
- data/lib/chef/provider/package/habitat.rb +168 -0
- data/lib/chef/provider/package/powershell.rb +5 -0
- 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 +17 -16
- data/lib/chef/provider/user/mac.rb +3 -3
- 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 +8 -7
- 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 +1 -1
- 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 +1 -1
- 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_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 +1 -1
- data/lib/chef/resource/windows_pagefile.rb +103 -64
- data/lib/chef/resource/windows_path.rb +2 -2
- 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 +2 -2
- 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 +1 -1
- 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 +13 -17
- data/lib/chef/resource_inspector.rb +6 -2
- data/lib/chef/resource_reporter.rb +0 -1
- data/lib/chef/resources.rb +12 -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/version.rb +1 -1
- data/spec/functional/mixin/from_file_spec.rb +1 -1
- data/spec/functional/resource/windows_hostname_spec.rb +91 -0
- data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
- 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/support/shared/unit/provider/file.rb +2 -8
- 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/formatters/doc_spec.rb +1 -1
- 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/mount/aix_spec.rb +1 -1
- data/spec/unit/provider/package/powershell_spec.rb +74 -12
- 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/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
- metadata +55 -7
@@ -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
|
@@ -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
|
@@ -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
|