From: adrianiurca <adrian.iurca@gmail.com>
Date: Thu, 16 Jul 2020 08:57:39 +0000 (+0300)
Subject: add acceptance test for hex_string
X-Git-Tag: v2.5.0~2^2~1
X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6b6c2ab36ebaeac76dfbb95cce514084b760b1c9;p=puppet-modules%2Fpuppetlabs-firewall.git

add acceptance test for hex_string
---

diff --git a/lib/puppet/type/firewall.rb b/lib/puppet/type/firewall.rb
index 889177c..c1accc3 100644
--- a/lib/puppet/type/firewall.rb
+++ b/lib/puppet/type/firewall.rb
@@ -2073,6 +2073,9 @@ Puppet::Type.newtype(:firewall) do
       String matching feature. Matches the package against the hex pattern
       given as an argument.
     PUPPETCODE
+    munge do |value|
+      _value = value.delete(' ')
+    end
   end
 
   newproperty(:string_algo, required_features: :string_matching) do
diff --git a/spec/acceptance/firewall_attributes_ipv6_happy_path_spec.rb b/spec/acceptance/firewall_attributes_ipv6_happy_path_spec.rb
index 43c4963..13d7b1e 100644
--- a/spec/acceptance/firewall_attributes_ipv6_happy_path_spec.rb
+++ b/spec/acceptance/firewall_attributes_ipv6_happy_path_spec.rb
@@ -261,6 +261,15 @@ describe 'firewall attribute testing, happy path', unless: (os[:family] == 'redh
           proto   => all,
           provider => 'ip6tables',
         }
+        firewall { '812 - hex_string':
+          chain       => 'INPUT',
+          proto       => 'tcp',
+          string_hex  => '|f4 6d 04 25 b2 02 00 0a|',
+          string_algo => 'kmp',
+          string_to   => '65535',
+          action      => accept,
+          provider    => 'ip6tables',
+        }
       PUPPETCODE
       idempotent_apply(pp)
     end
@@ -365,5 +374,8 @@ describe 'firewall attribute testing, happy path', unless: (os[:family] == 'redh
         expect(result.stdout).to match(regex)
       end
     end
+    it 'checks hex_string value' do
+      expect(result.stdout).to match(%r{-A INPUT -p tcp -m string --hex-string "|f46d0425b202000a|" --algo kmp --to 65535 -m comment --comment "812 - hex_string" -j ACCEPT})
+    end
   end
 end