diff options
Diffstat (limited to 'spec/type_aliases')
-rw-r--r-- | spec/type_aliases/actions_spec.rb | 46 | ||||
-rw-r--r-- | spec/type_aliases/policies_spec.rb | 39 | ||||
-rw-r--r-- | spec/type_aliases/protocols_spec.rb | 46 | ||||
-rw-r--r-- | spec/type_aliases/tables_spec.rb | 39 |
4 files changed, 170 insertions, 0 deletions
diff --git a/spec/type_aliases/actions_spec.rb b/spec/type_aliases/actions_spec.rb new file mode 100644 index 0000000..9c42e12 --- /dev/null +++ b/spec/type_aliases/actions_spec.rb @@ -0,0 +1,46 @@ +# rubocop:disable Style/WordArray, Style/TrailingCommaInLiteral +require 'spec_helper' + +describe 'Ferm::Actions' do + describe 'valid values' do + [ + 'RETURN', + 'ACCEPT', + 'DROP', + 'REJECT', + 'NOTRACK', + 'LOG', + 'MARK', + 'DNAT', + 'SNAT', + 'MASQUERADE', + 'REDIRECT', + 'MYFANCYCUSTOMCHAINNAMEISALSOVALID', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid values' do + context 'with garbage inputs' do + [ + # :symbol, # this should not match but seems liks String[1] allows it? + # nil, # this should not match but seems liks String[1] allows it? + '', + true, + false, + ['meep', 'meep'], + 65_538, + [95_000, 67_000], + {}, + { 'foo' => 'bar' }, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/policies_spec.rb b/spec/type_aliases/policies_spec.rb new file mode 100644 index 0000000..bc45423 --- /dev/null +++ b/spec/type_aliases/policies_spec.rb @@ -0,0 +1,39 @@ +# rubocop:disable Style/WordArray, Style/TrailingCommaInLiteral +require 'spec_helper' + +describe 'Ferm::Policies' do + describe 'valid values' do + [ + 'ACCEPT', + 'DROP', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid values' do + context 'with garbage inputs' do + [ + 'RETURN', + 'REJECT', + 'foobar', + :symbol, + nil, + '', + true, + false, + ['meep', 'meep'], + 65_538, + [95_000, 67_000], + {}, + { 'foo' => 'bar' }, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/protocols_spec.rb b/spec/type_aliases/protocols_spec.rb new file mode 100644 index 0000000..a067b69 --- /dev/null +++ b/spec/type_aliases/protocols_spec.rb @@ -0,0 +1,46 @@ +# rubocop:disable Style/WordArray, Style/TrailingCommaInLiteral +require 'spec_helper' + +describe 'Ferm::Protocols' do + describe 'valid values' do + [ + 'icmp', + 'tcp', + 'udp', + 'udplite', + 'icmpv6', + 'esp', + 'ah', + 'sctp', + 'mh', + 'all', + ['icmp', 'tcp', 'udp'], + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid values' do + context 'with garbage inputs' do + [ + :symbol, + nil, + 'foobar', + '', + true, + false, + ['meep', 'meep'], + 65_538, + [95_000, 67_000], + {}, + { 'foo' => 'bar' }, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/tables_spec.rb b/spec/type_aliases/tables_spec.rb new file mode 100644 index 0000000..eb02877 --- /dev/null +++ b/spec/type_aliases/tables_spec.rb @@ -0,0 +1,39 @@ +# rubocop:disable Style/WordArray, Style/TrailingCommaInLiteral +require 'spec_helper' + +describe 'Ferm::Tables' do + describe 'valid values' do + [ + 'raw', + 'mangle', + 'nat', + 'filter', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid values' do + context 'with garbage inputs' do + [ + :symbol, + nil, + 'foobar', + '', + true, + false, + ['meep', 'meep'], + 65_538, + [95_000, 67_000], + {}, + { 'foo' => 'bar' }, + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end |