From 496d19640cc239f59e456c381bd9912cde60a07e Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Fri, 3 Mar 2017 11:43:12 +0000 Subject: (MODULES-4485) Improve ipv6 support for type * Improves regex to catch some valid (but less known) ipv6 strings, mostly those which are a mix of ipv6 strings and embedded ipv4 numbers * Regex inspired by the following: * https://github.com/sindresorhus/ip-regex * https://gist.github.com/cpetschnig/294476 * The original Dartware forum thread where someone originally created this beast of a regex, now lost except to archive.org * Whilst we're here, we can add the more tricky ipv6 strings to the existing functions to validate * Luckily, the `ipaddr` native ruby library used in the original functions already supports these --- spec/aliases/ipv6_spec.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'spec/aliases/ipv6_spec.rb') diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 13d7c3e..6237eba 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -5,7 +5,14 @@ if Puppet.version.to_f >= 4.5 describe 'accepts ipv6 addresses' do [ '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111' + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + 'fe80:0000:0000:0000:0204:61ff:fe9d:f156', + 'fe80:0:0:0:204:61ff:fe9d:f156', + 'fe80::204:61ff:fe9d:f156', + 'fe80:0:0:0:0204:61ff:254.157.241.86', + '::1', + 'fe80::', + '2001::', ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -18,7 +25,10 @@ if Puppet.version.to_f >= 4.5 'nope', '77', '4.4.4', - '2000:7334' + '2000:7334', + '::ffff:2.3.4', + '::ffff:257.1.2.3', + '::ffff:12345678901234567890.1.26', ].each do |value| describe value.inspect do let(:params) {{ value: value }} -- cgit v1.2.3 From 318dcfaec6ba6d0e4af1e32e55ea20b721679537 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 14 Mar 2017 11:16:07 +0000 Subject: (MODULES-4528) Use versioncmp to check Puppet version for 4.10.x compat `Puppet.version.to_f` on Puppet 4.10.0 will evaluate to `4.1`, causing test and behavioural changes when conditionals check that the version is equal or greater than versions such as `4.3`. Version comparisons that are vulnerable to this have been changed to use Puppet's versioncmp implementation, while most others only check for for major version boundaries which is safe. --- spec/aliases/ipv6_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/aliases/ipv6_spec.rb') diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 6237eba..ae90f42 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.5 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'test::ipv6', type: :class do describe 'accepts ipv6 addresses' do [ -- cgit v1.2.3