diff options
author | Tim Smith <tsmith@chef.io> | 2021-06-13 16:23:44 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2021-06-13 17:04:58 -0700 |
commit | e493d5149619f7c5537c45c3f7e723e232ecf9ec (patch) | |
tree | c4bd87b3e46195d0412d2b908bc95a4892ad3dee | |
parent | d507902f201ee82b4e8a5a0cc21d27fe05ea4e56 (diff) | |
download | chef-e493d5149619f7c5537c45c3f7e723e232ecf9ec.tar.gz |
Add specs
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | cspell.json | 1 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_windows_defender.rb | 6 | ||||
-rw-r--r-- | spec/unit/resource/windows_defender_exclusion_spec.rb | 62 | ||||
-rw-r--r-- | spec/unit/resource/windows_defender_spec.rb | 71 |
4 files changed, 137 insertions, 3 deletions
diff --git a/cspell.json b/cspell.json index d6434022e8..614bb8f06d 100644 --- a/cspell.json +++ b/cspell.json @@ -14,6 +14,7 @@ "dictionaries": ["chef"], // words - list of words to be always considered correct "words": [ + "IOAV", "abcz", "Abdulin", "ABORTIFHUNG", diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_windows_defender.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_windows_defender.rb index 4565998f26..90a0403ae3 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/_windows_defender.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_windows_defender.rb @@ -5,7 +5,7 @@ # Copyright:: Copyright (c) Chef Software Inc. # -windows_defender 'Configure Windows Defender' do +windows_defender "Configure Windows Defender" do realtime_protection true intrusion_protection_system true lock_ui true @@ -18,8 +18,8 @@ windows_defender 'Configure Windows Defender' do action :enable end -windows_defender_exclusion 'Exclude PNG files' do - extensions 'png' +windows_defender_exclusion "Exclude PNG files" do + extensions "png" process_paths 'c:\\windows\\system32' action :add end diff --git a/spec/unit/resource/windows_defender_exclusion_spec.rb b/spec/unit/resource/windows_defender_exclusion_spec.rb new file mode 100644 index 0000000000..f776c07713 --- /dev/null +++ b/spec/unit/resource/windows_defender_exclusion_spec.rb @@ -0,0 +1,62 @@ +# +# Copyright:: Copyright (c) Chef Software Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "spec_helper" + +describe Chef::Resource::WindowsDefenderExclusion do + let(:resource) { Chef::Resource::WindowsDefenderExclusion.new("fakey_fakerton") } + + it "sets resource name as :windows_defender_exclusion" do + expect(resource.resource_name).to eql(:windows_defender_exclusion) + end + + it "sets the default action as :add" do + expect(resource.action).to eql([:add]) + end + + it "supports :add, :remove actions" do + expect { resource.action :add }.not_to raise_error + expect { resource.action :remove }.not_to raise_error + end + + it "paths property defaults to []" do + expect(resource.paths).to eql([]) + end + + it "paths coerces strings to arrays" do + resource.paths "foo,bar" + expect(resource.paths).to eq(%w{foo bar}) + end + + it "extensions property defaults to []" do + expect(resource.extensions).to eql([]) + end + + it "extensions coerces strings to arrays" do + resource.extensions "foo,bar" + expect(resource.extensions).to eq(%w{foo bar}) + end + + it "process_paths property defaults to []" do + expect(resource.process_paths).to eql([]) + end + + it "process_paths coerces strings to arrays" do + resource.process_paths "foo,bar" + expect(resource.process_paths).to eq(%w{foo bar}) + end +end diff --git a/spec/unit/resource/windows_defender_spec.rb b/spec/unit/resource/windows_defender_spec.rb new file mode 100644 index 0000000000..1cafd262a5 --- /dev/null +++ b/spec/unit/resource/windows_defender_spec.rb @@ -0,0 +1,71 @@ +# +# Copyright:: Copyright (c) Chef Software Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "spec_helper" + +describe Chef::Resource::WindowsDefender do + let(:resource) { Chef::Resource::WindowsDefender.new("fakey_fakerton") } + + it "sets resource name as :windows_defender" do + expect(resource.resource_name).to eql(:windows_defender) + end + + it "sets the default action as :enable" do + expect(resource.action).to eql([:enable]) + end + + it "supports :enable, :disable actions" do + expect { resource.action :enable }.not_to raise_error + expect { resource.action :disable }.not_to raise_error + end + + it "realtime_protection property defaults to true" do + expect(resource.realtime_protection).to eql(true) + end + + it "intrusion_protection_system property defaults to true" do + expect(resource.intrusion_protection_system).to eql(true) + end + + it "lock_ui property defaults to true" do + expect(resource.lock_ui).to eql(false) + end + + it "scan_archives property defaults to true" do + expect(resource.scan_archives).to eql(true) + end + + it "scan_scripts property defaults to true" do + expect(resource.scan_scripts).to eql(false) + end + + it "scan_email property defaults to true" do + expect(resource.scan_email).to eql(false) + end + + it "scan_removable_drives property defaults to true" do + expect(resource.scan_removable_drives).to eql(false) + end + + it "scan_network_files property defaults to true" do + expect(resource.scan_network_files).to eql(false) + end + + it "scan_mapped_drives property defaults to true" do + expect(resource.scan_mapped_drives).to eql(true) + end +end |