diff options
author | Dominic Cleal <dominic@cleal.org> | 2017-03-14 11:16:07 +0000 |
---|---|---|
committer | Dominic Cleal <dominic@cleal.org> | 2017-03-14 11:27:42 +0000 |
commit | 318dcfaec6ba6d0e4af1e32e55ea20b721679537 (patch) | |
tree | c694e92cbf56620acd5fdaf85d2b4a83ca6db9f9 | |
parent | e4ea1c46e7408f6878819dc08905be445a9c7bc8 (diff) |
(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.
-rw-r--r-- | spec/aliases/absolute_path_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/absolutepath_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/array_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/bool_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/float_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/hash_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/httpsurl_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/httpurl_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/integer_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/ip_address.rb | 2 | ||||
-rw-r--r-- | spec/aliases/ipv4_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/ipv6_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/numeric_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/string_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/unixpath_spec.rb | 2 | ||||
-rw-r--r-- | spec/aliases/windowspath_spec.rb | 2 | ||||
-rw-r--r-- | spec/functions/deprecation_spec.rb | 2 | ||||
-rwxr-xr-x | spec/functions/ensure_resource_spec.rb | 2 | ||||
-rw-r--r-- | spec/functions/validate_legacy_spec.rb | 2 |
19 files changed, 19 insertions, 19 deletions
diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index eeda76a..0e9798e 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_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::absolute_path', type: :class do describe 'valid paths handling' do %w{ diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb index aa435d7..337074c 100644 --- a/spec/aliases/absolutepath_spec.rb +++ b/spec/aliases/absolutepath_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::absolutepath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/array_spec.rb b/spec/aliases/array_spec.rb index d0f9877..89cc2af 100644 --- a/spec/aliases/array_spec.rb +++ b/spec/aliases/array_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::array', type: :class do describe 'accepts arrays' do [ diff --git a/spec/aliases/bool_spec.rb b/spec/aliases/bool_spec.rb index 78c57fc..b84ab51 100644 --- a/spec/aliases/bool_spec.rb +++ b/spec/aliases/bool_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::bool', type: :class do describe 'accepts booleans' do [ diff --git a/spec/aliases/float_spec.rb b/spec/aliases/float_spec.rb index cc20758..66079c6 100644 --- a/spec/aliases/float_spec.rb +++ b/spec/aliases/float_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::float', type: :class do describe 'accepts floats' do [ diff --git a/spec/aliases/hash_spec.rb b/spec/aliases/hash_spec.rb index e10a04b..6e5060d 100644 --- a/spec/aliases/hash_spec.rb +++ b/spec/aliases/hash_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::hash', type: :class do describe 'accepts hashes' do [ diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb index 9cc9a76..3e51118 100644 --- a/spec/aliases/httpsurl_spec.rb +++ b/spec/aliases/httpsurl_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::httpsurl', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb index f92ddb3..fd49a47 100644 --- a/spec/aliases/httpurl_spec.rb +++ b/spec/aliases/httpurl_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::httpurl', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/integer_spec.rb b/spec/aliases/integer_spec.rb index 260090a..bd00c2a 100644 --- a/spec/aliases/integer_spec.rb +++ b/spec/aliases/integer_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::integer', type: :class do describe 'accepts integers' do [ diff --git a/spec/aliases/ip_address.rb b/spec/aliases/ip_address.rb index 664bf24..67a555c 100644 --- a/spec/aliases/ip_address.rb +++ b/spec/aliases/ip_address.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::ip_address', type: :class do describe 'accepts ipv4 and ipv6 addresses' do [ diff --git a/spec/aliases/ipv4_spec.rb b/spec/aliases/ipv4_spec.rb index 210b4b1..6a503ad 100644 --- a/spec/aliases/ipv4_spec.rb +++ b/spec/aliases/ipv4_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::ipv4', type: :class do describe 'accepts ipv4 addresses' do SharedData::IPV4_PATTERNS.each do |value| 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 [ diff --git a/spec/aliases/numeric_spec.rb b/spec/aliases/numeric_spec.rb index 0e98bee..bc17f4f 100644 --- a/spec/aliases/numeric_spec.rb +++ b/spec/aliases/numeric_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::numeric', type: :class do describe 'accepts numerics' do [ diff --git a/spec/aliases/string_spec.rb b/spec/aliases/string_spec.rb index 8a93585..d8fb885 100644 --- a/spec/aliases/string_spec.rb +++ b/spec/aliases/string_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::string', type: :class do describe 'accepts strings' do [ diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index 7824cb6..ac7d64d 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_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::unixpath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb index b8ddcb7..c20e373 100644 --- a/spec/aliases/windowspath_spec.rb +++ b/spec/aliases/windowspath_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::windowspath', type: :class do describe 'valid handling' do %w{ diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb index 8a65b69..bde4e89 100644 --- a/spec/functions/deprecation_spec.rb +++ b/spec/functions/deprecation_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 'deprecation' do before(:each) { # this is to reset the strict variable to default diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index fddc4c4..5366205 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -4,7 +4,7 @@ describe 'ensure_resource' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) } it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) } - if Puppet.version.to_f >= 4.6 + if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(ArgumentError) } else it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) } diff --git a/spec/functions/validate_legacy_spec.rb b/spec/functions/validate_legacy_spec.rb index 10b2aee..7b48f12 100644 --- a/spec/functions/validate_legacy_spec.rb +++ b/spec/functions/validate_legacy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.4 +if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0 describe 'validate_legacy' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(ArgumentError) } |