rspec-puppet 2.7.8 → 2.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rspec-puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rspec-puppet/cache.rb +11 -6
- data/lib/rspec-puppet/matchers/create_generic.rb +5 -0
- data/lib/rspec-puppet/matchers/parameter_matcher.rb +3 -4
- data/lib/rspec-puppet/monkey_patches.rb +28 -0
- data/lib/rspec-puppet/sensitive.rb +47 -0
- data/lib/rspec-puppet/support.rb +10 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca4beef2e1c4c55e6e0e79b0fd9d03fb05a1462166632aa64c6df9b37ca93e51
|
4
|
+
data.tar.gz: 7b4c5948d175bbfad4f46fcf89ac1ec8427dbc1457cf3f767dc656427a30b6ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a24ffc5d27c563a0bfe01be6f6881119955ad7a46afe330ffa9a787102186b41ba1af6d26df8984202746aefa5fca432860074e874073aba9a2fe69e87099d7
|
7
|
+
data.tar.gz: 19e34976f263b427406002ffa5ba26711814d49558c1bc2f396fd03415ce0ec7fe018052d4e90db5e295127561d1e8a1c30371fc32d856a14a0d34c81a29b1a4
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
All notable changes to this project will be documented in this file. This
|
3
3
|
project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [2.7.9]
|
6
|
+
### Fixed
|
7
|
+
* Fix issues with removal of `default_env` method in Puppet 6.17.0.
|
8
|
+
|
5
9
|
## [2.7.8]
|
6
10
|
|
7
11
|
### Fixed
|
data/lib/rspec-puppet/cache.rb
CHANGED
@@ -11,12 +11,17 @@ module RSpec::Puppet
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def get(*args, &blk)
|
14
|
-
# decouple the hash key from whatever the blk might do to it
|
15
14
|
key = Marshal.load(Marshal.dump(args))
|
16
|
-
if
|
17
|
-
|
18
|
-
|
15
|
+
if @cache.has_key?(key)
|
16
|
+
# Cache hit
|
17
|
+
# move that entry last to make it "most recenty used"
|
18
|
+
@lra.insert(-1, @lra.delete_at(@lra.index(args)))
|
19
|
+
else
|
20
|
+
# Cache miss
|
21
|
+
# Ensure room by evicting least recently used if no space left
|
19
22
|
expire!
|
23
|
+
@cache[args] = (blk || @default_proc).call(*args)
|
24
|
+
@lra << args
|
20
25
|
end
|
21
26
|
|
22
27
|
@cache[key]
|
@@ -25,8 +30,8 @@ module RSpec::Puppet
|
|
25
30
|
private
|
26
31
|
|
27
32
|
def expire!
|
28
|
-
|
29
|
-
|
33
|
+
# delete one entry (the oldest) when there is no room in cache
|
34
|
+
@cache.delete(@lra.shift) if @cache.size == MAX_ENTRIES
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -89,6 +89,11 @@ module RSpec::Puppet
|
|
89
89
|
else
|
90
90
|
RSpec::Puppet::Coverage.cover!(resource)
|
91
91
|
rsrc_hsh = resource.to_hash
|
92
|
+
if resource.respond_to?(:sensitive_parameters)
|
93
|
+
resource.sensitive_parameters.each do |s_param|
|
94
|
+
rsrc_hsh[s_param] = ::Puppet::Pops::Types::PSensitiveType::Sensitive.new(rsrc_hsh[s_param])
|
95
|
+
end
|
96
|
+
end
|
92
97
|
|
93
98
|
if resource.builtin_type?
|
94
99
|
namevar = resource.resource_type.key_attributes.first.to_s
|
@@ -21,10 +21,7 @@ module RSpec::Puppet
|
|
21
21
|
#
|
22
22
|
# @return [true, false]
|
23
23
|
def matches?(resource)
|
24
|
-
|
25
|
-
@resource = resource
|
26
|
-
|
27
|
-
actual = @resource[@parameter]
|
24
|
+
actual = resource[@parameter]
|
28
25
|
expected = @value
|
29
26
|
|
30
27
|
# Puppet flattens an array with a single value into just the value and
|
@@ -65,6 +62,8 @@ module RSpec::Puppet
|
|
65
62
|
check_hash(expected, actual)
|
66
63
|
when Array
|
67
64
|
check_array(expected, actual)
|
65
|
+
when RSpec::Puppet::Sensitive
|
66
|
+
expected == actual
|
68
67
|
else
|
69
68
|
check_string(expected, actual)
|
70
69
|
end
|
@@ -132,6 +132,16 @@ module Puppet
|
|
132
132
|
end
|
133
133
|
|
134
134
|
module Util
|
135
|
+
# Fix for removal of default_env function
|
136
|
+
# Bug: https://github.com/rodjek/rspec-puppet/issues/796
|
137
|
+
# Upstream: https://github.com/puppetlabs/puppet/commit/94df3c1a3992d89b2d7d5db8a70373c135bdd86b
|
138
|
+
if !respond_to?(:default_env)
|
139
|
+
def default_env()
|
140
|
+
DEFAULT_ENV
|
141
|
+
end
|
142
|
+
module_function :default_env
|
143
|
+
end
|
144
|
+
|
135
145
|
if respond_to?(:get_env)
|
136
146
|
alias :old_get_env :get_env
|
137
147
|
module_function :old_get_env
|
@@ -292,6 +302,24 @@ class Pathname
|
|
292
302
|
end
|
293
303
|
end
|
294
304
|
|
305
|
+
# Puppet loads init.pp, then foo.pp, to find class "mod::foo". If
|
306
|
+
# class "mod" has been mocked using pre_condition when testing
|
307
|
+
# "mod::foo", this causes duplicate declaration for "mod".
|
308
|
+
# This monkey patch only loads "init.pp" if "foo.pp" does not exist.
|
309
|
+
class Puppet::Module
|
310
|
+
if [:match_manifests, 'match_manifests'].any? { |r| instance_methods.include?(r) }
|
311
|
+
old_match_manifests = instance_method(:match_manifests)
|
312
|
+
|
313
|
+
define_method(:match_manifests) do |rest|
|
314
|
+
result = old_match_manifests.bind(self).call(rest)
|
315
|
+
if result.length > 1 && File.basename(result[0]) == 'init.pp'
|
316
|
+
result.shift
|
317
|
+
end
|
318
|
+
result
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
295
323
|
# Prevent the File type from munging paths (which uses File.expand_path to
|
296
324
|
# normalise paths, which does very bad things to *nix paths on Windows.
|
297
325
|
file_path_munge = Puppet::Type.type(:file).paramclass(:path).instance_method(:unsafe_munge)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RSpec::Puppet
|
2
|
+
if defined?(::Puppet::Pops::Types::PSensitiveType::Sensitive)
|
3
|
+
# A wrapper representing Sensitive data type, eg. in class params.
|
4
|
+
class Sensitive < ::Puppet::Pops::Types::PSensitiveType::Sensitive
|
5
|
+
# Create a new Sensitive object
|
6
|
+
# @param [Object] value to wrap
|
7
|
+
def initialize(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return the wrapped value
|
12
|
+
def unwrap
|
13
|
+
@value
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return true
|
17
|
+
def sensitive?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return inspect of the wrapped value, inside Sensitive()
|
22
|
+
def inspect
|
23
|
+
"Sensitive(#{@value.inspect})"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Check for equality with another value.
|
27
|
+
# If compared to Puppet Sensitive type, it compares the wrapped values.
|
28
|
+
|
29
|
+
# @param other [#unwrap, Object] value to compare to
|
30
|
+
def == other
|
31
|
+
if other.respond_to? :unwrap
|
32
|
+
return unwrap == other.unwrap
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
#:nocov:
|
40
|
+
class Sensitive
|
41
|
+
def initialize(value)
|
42
|
+
raise 'The use of the Sensitive data type is not supported by this Puppet version'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
#:nocov:
|
46
|
+
end
|
47
|
+
end
|
data/lib/rspec-puppet/support.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rspec-puppet/cache'
|
2
2
|
require 'rspec-puppet/adapters'
|
3
3
|
require 'rspec-puppet/raw_string'
|
4
|
+
require 'rspec-puppet/sensitive'
|
4
5
|
|
5
6
|
module RSpec::Puppet
|
6
7
|
module Support
|
@@ -440,8 +441,7 @@ module RSpec::Puppet
|
|
440
441
|
end
|
441
442
|
|
442
443
|
def escape_special_chars(string)
|
443
|
-
string.gsub
|
444
|
-
string
|
444
|
+
string.gsub(/\$/, "\\$")
|
445
445
|
end
|
446
446
|
|
447
447
|
def rspec_compatibility
|
@@ -462,6 +462,14 @@ module RSpec::Puppet
|
|
462
462
|
return RSpec::Puppet::RawString.new("#{type}['#{title}']")
|
463
463
|
end
|
464
464
|
|
465
|
+
# Helper to return value wrapped in Sensitive type.
|
466
|
+
#
|
467
|
+
# @param [Object] value to wrap
|
468
|
+
# @return [RSpec::Puppet::Sensitive] a new Sensitive wrapper with the new value
|
469
|
+
def sensitive(value)
|
470
|
+
return RSpec::Puppet::Sensitive.new(value)
|
471
|
+
end
|
472
|
+
|
465
473
|
# @!attribute [r] adapter
|
466
474
|
# @api private
|
467
475
|
# @return [Class < RSpec::Puppet::Adapters::Base]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb
|
67
67
|
- lib/rspec-puppet/rake_task.rb
|
68
68
|
- lib/rspec-puppet/raw_string.rb
|
69
|
+
- lib/rspec-puppet/sensitive.rb
|
69
70
|
- lib/rspec-puppet/setup.rb
|
70
71
|
- lib/rspec-puppet/spec_helper.rb
|
71
72
|
- lib/rspec-puppet/support.rb
|