summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPatrick Schaumburg <pschaumburg@tecracer.de>2020-03-30 12:32:48 +0200
committerPatrick Schaumburg <pschaumburg@tecracer.de>2020-03-30 12:32:48 +0200
commitdbe1f2831b51fc9ea0535093121af05772ac6df3 (patch)
treecfdf699bec450748466314e08e150fbfa41c1c50 /spec
parentc2688e6b3673d95b9a356bd9eb340c3cd713ed13 (diff)
downloadchef-dbe1f2831b51fc9ea0535093121af05772ac6df3.tar.gz
fix linting errors + add unit test for is_set_properly? method
Signed-off-by: Patrick Schaumburg <pschaumburg@tecracer.de>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource/windows_firewall_rule_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/unit/resource/windows_firewall_rule_spec.rb b/spec/unit/resource/windows_firewall_rule_spec.rb
index f4dfea1e0a..9620daa76c 100644
--- a/spec/unit/resource/windows_firewall_rule_spec.rb
+++ b/spec/unit/resource/windows_firewall_rule_spec.rb
@@ -502,4 +502,65 @@ describe Chef::Resource::WindowsFirewallRule do
end
end
end
+ describe "#is_set_properly?" do
+ context "#TCP" do
+ it "protocol is TCP and icmp_type is empty" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("", "TCP")).to be false
+ end
+
+ it "protocol is TCP and icmp_type is 'Any'" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("Any", "TCP")).to be true
+ end
+
+ it "protocol is TCP and icmp_type is 123 as String" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("123", "TCP")).to be false
+ end
+
+ it "protocol is TCP and icmp_type is 123 as Integer" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?(123, "TCP")).to be false
+ end
+
+ it "protocol is TCP and icmp_type is '1:3' as code pair" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("1:3", "TCP")).to be false
+ end
+
+ it "protocol is TCP and icmp_type is '123:456' as code pair out of range" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("123:456", "TCP")).to be false
+ end
+
+ it "protocol is TCP and icmp_type is nil" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?(nil, "TCP")).to be false
+ end
+ end
+
+ context "#ICMPv6" do
+ it "protocol is ICMPv6 and icmp_type is empty" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("", "ICMPv6")).to be false
+ end
+
+ it "protocol is ICMPv6 and icmp_type is 'Any'" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("Any", "ICMPv6")).to be true
+ end
+
+ it "protocol is ICMPv6 and icmp_type is 123 as String" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("123", "ICMPv6")).to be true
+ end
+
+ it "protocol is ICMPv6 and icmp_type is 123 as Integer" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?(123, "ICMPv6")).to be true
+ end
+
+ it "protocol is ICMPv6 and icmp_type is '1:3' as code pair" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("1:3", "ICMPv6")).to be true
+ end
+
+ it "protocol is ICMPv6 and icmp_type is '123:456' as code pair out of range" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?("123:456", "ICMPv6")).to be false
+ end
+
+ it "protocol is ICMPv6 and icmp_type is nil" do
+ expect(Chef::Resource::WindowsFirewallRule.is_set_properly?(nil, "ICMPv6")).to be false
+ end
+ end
+ end
end