diff options
author | Davin Taddeo <davin@chef.io> | 2020-06-15 13:31:04 -0400 |
---|---|---|
committer | Davin Taddeo <davin@chef.io> | 2020-06-15 13:31:04 -0400 |
commit | d9ba5b4003c336db1fe12a7dec27a980ea10addb (patch) | |
tree | 8417e830467a0f37966817a69ac9127d288ddf52 | |
parent | f752905e2dc1d11244cdb6fefe1482b69207d679 (diff) | |
download | chef-d9ba5b4003c336db1fe12a7dec27a980ea10addb.tar.gz |
fix the spec file to fix unit tests by making rspec happy. fix some spellcheck issues and chefstyle issues as well.
Signed-off-by: Davin Taddeo <davin@chef.io>
-rw-r--r-- | cspell.json | 6 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/linux.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/snap.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/windows_firewall_profile.rb | 44 | ||||
-rw-r--r-- | spec/unit/resource/windows_firewall_policy_spec.rb | 6 |
5 files changed, 31 insertions, 29 deletions
diff --git a/cspell.json b/cspell.json index 7c54d63296..01d684b77a 100644 --- a/cspell.json +++ b/cspell.json @@ -31,6 +31,7 @@ "Alam", "Albenzi", "albertomurillo", + "Albertson", "Algorta", "Alloc", "allowselfservice", @@ -121,6 +122,7 @@ "basepath", "basestring", "baseurls", + "Bastien", "bcast", "Benesch", "Berksfile", @@ -197,6 +199,7 @@ "cfprefsd", "cgroup", "chadmccune", + "Chamberland", "Chaput", "chardev", "chatops", @@ -308,6 +311,7 @@ "cpio", "cpjones", "CPPFLAGS", + "Crae", "Cragun", "CREAT", "createhomedir", @@ -1986,6 +1990,8 @@ "Unformatter", "unformatter", "unhold", + "unicast", + "Unicast", "unignored", "uninst", "unintuitive", diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb index da5265359d..aad4895246 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb @@ -119,5 +119,5 @@ include_recipe "::_openssl" include_recipe "::_tests" # at the moment these do not run properly in docker -# we need to investage if this is a snap on docker issue or a chef issue +# we need to investigate if this is a snap on docker issue or a chef issue # include_recipe "::_snap" if platform?("ubuntu") diff --git a/lib/chef/provider/package/snap.rb b/lib/chef/provider/package/snap.rb index 7aaaf3f30f..338f2ec510 100644 --- a/lib/chef/provider/package/snap.rb +++ b/lib/chef/provider/package/snap.rb @@ -137,7 +137,7 @@ class Chef # while it is expected to allow clients to connect using https over # a tcp socket, at this point only a unix socket is supported. the - # socket is /run/snapd.socket note - unixsocket is not defined on + # socket is /run/snapd.socket note - unix socket is not defined on # windows systems if defined?(::UNIXSocket) UNIXSocket.open("/run/snapd.socket") do |socket| diff --git a/lib/chef/resource/windows_firewall_profile.rb b/lib/chef/resource/windows_firewall_profile.rb index e283004797..dbaee7ad0d 100644 --- a/lib/chef/resource/windows_firewall_profile.rb +++ b/lib/chef/resource/windows_firewall_profile.rb @@ -20,7 +20,7 @@ class Chef class Resource class WindowsFirewallProfile < Chef::Resource provides :windows_firewall_profile - description 'Use the **windows_firewall_profile** resource to enable, disable, and configure the Windows firewall.' + description "Use the **windows_firewall_profile** resource to enable, disable, and configure the Windows firewall." introduced "16.2" examples <<~DOC @@ -63,17 +63,17 @@ class Chef unified_mode true - property :profile, String, required: true, equal_to: %w(Domain Public Private), description: 'Set the Windows Profile being configured' - property :profile_enabled, [true, false], default: true, description: 'Set the status of the firewall profile to Enabled or Disabled' - property :default_inbound_block, [true, false, nil], default: true, description: 'Set the default policy for inbound network traffic to blocked' - property :default_outbound_allow, [true, false, nil], default: true, description: 'Set the default policy for outbound network traffic to blocked' - property :allow_inbound_rules, [true, false, nil], description: 'Allow users to set inbound firewall rules' - property :allow_local_firewall_rules, [true, false, nil], description: 'Merges inbound firewall rules into the policy' - property :allow_local_ipsec_rules, [true, false, nil], description: 'Allow users to manage local connection security rules' - property :allow_user_apps, [true, false, nil], description: 'Allow user applications to manage firewall' - property :allow_user_ports, [true, false, nil], description: 'Allow users to manage firewall port rules' - property :allow_unicast_response, [true, false, nil], description: 'Allow unicast responses to multicast and broadcast messages' - property :display_notification, [true, false, nil], description: 'Display a notification when firewall blocks certain activity' + property :profile, String, required: true, equal_to: %w{ Domain Public Private }, description: "Set the Windows Profile being configured" + property :profile_enabled, [true, false], default: true, description: "Set the status of the firewall profile to Enabled or Disabled" + property :default_inbound_block, [true, false, nil], default: true, description: "Set the default policy for inbound network traffic to blocked" + property :default_outbound_allow, [true, false, nil], default: true, description: "Set the default policy for outbound network traffic to blocked" + property :allow_inbound_rules, [true, false, nil], description: "Allow users to set inbound firewall rules" + property :allow_local_firewall_rules, [true, false, nil], description: "Merges inbound firewall rules into the policy" + property :allow_local_ipsec_rules, [true, false, nil], description: "Allow users to manage local connection security rules" + property :allow_user_apps, [true, false, nil], description: "Allow user applications to manage firewall" + property :allow_user_ports, [true, false, nil], description: "Allow users to manage firewall port rules" + property :allow_unicast_response, [true, false, nil], description: "Allow unicast responses to multicast and broadcast messages" + property :display_notification, [true, false, nil], description: "Display a notification when firewall blocks certain activity" load_current_value do |desired| ps_results = powershell_exec(<<-CODE).result @@ -104,52 +104,52 @@ class Chef action :configure do converge_if_changed :profile_enabled do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += "-Enabled #{new_resource.profile_enabled ? 'True' : 'False'} " + cmd += "-Enabled #{new_resource.profile_enabled ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :default_inbound_block do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.default_inbound_block.nil? ? '-DefaultInboundAction NotConfigured ' : "-DefaultInboundAction #{new_resource.default_inbound_block ? 'Block' : 'Allow'} " + cmd += new_resource.default_inbound_block.nil? ? "-DefaultInboundAction NotConfigured " : "-DefaultInboundAction #{new_resource.default_inbound_block ? "Block" : "Allow"} " powershell_exec(cmd) end converge_if_changed :default_outbound_allow do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.default_outbound_allow.nil? ? '-DefaultOutboundAction NotConfigured ' : "-DefaultOutboundAction #{new_resource.default_outbound_allow ? 'Allow' : 'Block'} " + cmd += new_resource.default_outbound_allow.nil? ? "-DefaultOutboundAction NotConfigured " : "-DefaultOutboundAction #{new_resource.default_outbound_allow ? "Allow" : "Block"} " powershell_exec(cmd) end converge_if_changed :allow_inbound_rules do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_inbound_rules.nil? ? '-AllowInboundRules NotConfigured ' : "-AllowInboundRules #{new_resource.allow_inbound_rules ? 'True' : 'False'} " + cmd += new_resource.allow_inbound_rules.nil? ? "-AllowInboundRules NotConfigured " : "-AllowInboundRules #{new_resource.allow_inbound_rules ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :allow_local_firewall_rules do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_local_firewall_rules.nil? ? '-AllowLocalFirewallRules NotConfigured ' : "-AllowLocalFirewallRules #{new_resource.allow_local_firewall_rules ? 'True' : 'False'} " + cmd += new_resource.allow_local_firewall_rules.nil? ? "-AllowLocalFirewallRules NotConfigured " : "-AllowLocalFirewallRules #{new_resource.allow_local_firewall_rules ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :allow_local_ipsec_rules do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_local_ipsec_rules.nil? ? '-AllowLocalIPsecRules NotConfigured ' : "-AllowLocalIPsecRules #{new_resource.allow_local_ipsec_rules ? 'True' : 'False'} " + cmd += new_resource.allow_local_ipsec_rules.nil? ? "-AllowLocalIPsecRules NotConfigured " : "-AllowLocalIPsecRules #{new_resource.allow_local_ipsec_rules ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :allow_user_apps do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_user_apps.nil? ? '-AllowUserApps NotConfigured ' : "-AllowUserApps #{new_resource.allow_user_apps ? 'True' : 'False'} " + cmd += new_resource.allow_user_apps.nil? ? "-AllowUserApps NotConfigured " : "-AllowUserApps #{new_resource.allow_user_apps ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :allow_user_ports do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_user_ports.nil? ? '-AllowUserPorts NotConfigured ' : "-AllowUserPorts #{new_resource.allow_user_ports ? 'True' : 'False'} " + cmd += new_resource.allow_user_ports.nil? ? "-AllowUserPorts NotConfigured " : "-AllowUserPorts #{new_resource.allow_user_ports ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :allow_unicast_response do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.allow_unicast_response.nil? ? '-AllowUnicastResponseToMulticast NotConfigured ' : "-AllowUnicastResponseToMulticast #{new_resource.allow_unicast_response ? 'True' : 'False'} " + cmd += new_resource.allow_unicast_response.nil? ? "-AllowUnicastResponseToMulticast NotConfigured " : "-AllowUnicastResponseToMulticast #{new_resource.allow_unicast_response ? "True" : "False"} " powershell_exec(cmd) end converge_if_changed :display_notification do cmd = "Set-NetFirewallProfile -Profile #{new_resource.profile} " - cmd += new_resource.display_notification.nil? ? '-NotifyOnListen NotConfigured ' : "-NotifyOnListen #{new_resource.display_notification ? 'True' : 'False'} " + cmd += new_resource.display_notification.nil? ? "-NotifyOnListen NotConfigured " : "-NotifyOnListen #{new_resource.display_notification ? "True" : "False"} " powershell_exec(cmd) end end diff --git a/spec/unit/resource/windows_firewall_policy_spec.rb b/spec/unit/resource/windows_firewall_policy_spec.rb index 2c1b200a61..0f81a52235 100644 --- a/spec/unit/resource/windows_firewall_policy_spec.rb +++ b/spec/unit/resource/windows_firewall_policy_spec.rb @@ -26,11 +26,7 @@ describe Chef::Resource::WindowsFirewallProfile do %i{Domain Private Public}.each do |profile| it "The profile accepts values for the \"#{profile}\" Profile" do - expect { resource.profile profile, - resource.profile_enabled true, - resource.default_inbound_block true, - resource.default_outbound_allow true, - }.not_to raise_error + expect { resource.profile profile }.not_to raise_error end end |