aboutsummaryrefslogtreecommitdiff
path: root/spec/type_aliases
diff options
context:
space:
mode:
authorThore Bödecker <me@foxxx0.de>2020-06-25 17:07:07 +0200
committerThore Bödecker <me@foxxx0.de>2020-06-30 18:05:47 +0200
commit856eca997158141e084b9e8c2002d7491a4720a1 (patch)
tree52103dc1a6e99ba629df558dfb0302840e78f834 /spec/type_aliases
parent945faf68871dfdb9f9521cdadcdecfef65634d4b (diff)
downloadpuppet-ferm-856eca997158141e084b9e8c2002d7491a4720a1.tar.gz
puppet-ferm-856eca997158141e084b9e8c2002d7491a4720a1.tar.bz2
use proper types and validations for port handling
- implement validations for port ranges - add test cases for these scenarios
Diffstat (limited to 'spec/type_aliases')
-rw-r--r--spec/type_aliases/port_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/type_aliases/port_spec.rb b/spec/type_aliases/port_spec.rb
new file mode 100644
index 0000000..e2b0d43
--- /dev/null
+++ b/spec/type_aliases/port_spec.rb
@@ -0,0 +1,43 @@
+# rubocop:disable Style/WordArray, Style/TrailingCommaInLiteral
+require 'spec_helper'
+
+describe 'Ferm::Port' do
+ describe 'valid values' do
+ [
+ 17,
+ 65_535,
+ '25:30',
+ ':22',
+ [80, 443, 8080, 8443],
+ ].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
+ [
+ 'asdf',
+ true,
+ false,
+ :symbol,
+ ['meep', 'meep'],
+ 65_538,
+ [95_000, 67_000],
+ '12345',
+ '20:22:23',
+ '1024:',
+ 'ネット',
+ nil,
+ {},
+ { 'foo' => 'bar' },
+ ].each do |value|
+ describe value.inspect do
+ it { is_expected.not_to allow_value(value) }
+ end
+ end
+ end
+ end
+end