diff --git a/Gemfile b/Gemfile index 0a7542d09..e4ed0cd65 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ group :development, :unit_tests do gem 'mocha', '< 1.2.0' gem 'rspec-puppet-facts' gem 'simplecov' - gem 'parallel_tests' + gem 'parallel_tests', '2.9.0' if RUBY_VERSION < '2.0.0' gem 'rubocop', '0.41.2' if RUBY_VERSION < '2.0.0' gem 'rubocop' if RUBY_VERSION >= '2.0.0' gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0' diff --git a/spec/aliases/ipv4_spec.rb b/spec/aliases/ipv4_spec.rb index e767b45b8..b6f6af1e1 100644 --- a/spec/aliases/ipv4_spec.rb +++ b/spec/aliases/ipv4_spec.rb @@ -7,6 +7,7 @@ '224.0.0.0', '255.255.255.255', '0.0.0.0', + '10.10.10.10', '192.88.99.0' ].each do |value| describe value.inspect do @@ -20,6 +21,9 @@ 'nope', '77', '4.4.4', + '9999.9999.9999.9999', + '10.010.10.10', + '192.168.256.1', '2001:0db8:85a3:0000:0000:8a2e:0370:73342001:0db8:85a3:0000:0000:8a2e:0370:7334' ].each do |value| describe value.inspect do diff --git a/spec/functions/is_ipv4_address_spec.rb b/spec/functions/is_ipv4_address_spec.rb index e39d93bf8..9d5dd070e 100644 --- a/spec/functions/is_ipv4_address_spec.rb +++ b/spec/functions/is_ipv4_address_spec.rb @@ -7,6 +7,10 @@ it { is_expected.to run.with_params('1.2.3.4').and_return(true) } it { is_expected.to run.with_params('1.2.3.255').and_return(true) } it { is_expected.to run.with_params('1.2.3').and_return(false) } + it { is_expected.to run.with_params('10.10.10.10').and_return(true) } + it { is_expected.to run.with_params('10.010.10.10').and_return(false) } + it { is_expected.to run.with_params('9999.9999.9999.9999').and_return(false) } + it { is_expected.to run.with_params('192.168.256.1').and_return(false) } it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } it { is_expected.to run.with_params('').and_return(false) } it { is_expected.to run.with_params('one').and_return(false) } diff --git a/types/compat/ipv4.pp b/types/compat/ipv4.pp index 1d72ebd09..c0ddbfed9 100644 --- a/types/compat/ipv4.pp +++ b/types/compat/ipv4.pp @@ -1,2 +1,2 @@ # Emulate the validate_ipv4_address and is_ipv4_address functions -type Stdlib::Compat::Ipv4 = Pattern[/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/] +type Stdlib::Compat::Ipv4 = Pattern[/^(([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]?){4}$/]