rodjek / rspec-puppet

RSpec tests for your Puppet manifests
http://rspec-puppet.com
MIT License
364 stars 203 forks source link

Implement ability to verify redacted values in catalog from the Sensitve Data type #529

Open TraGicCode opened 7 years ago

TraGicCode commented 7 years ago

It would be nice to be able to write a unit test that will verify you expect a certain property on a resource to have it's value redacted in the compiled catalog. Below is currently what i'm doing. Is there anyway we can get a thread going on how this can be implemented as a built in solution for rspec-puppet?

pasted image at 2017_06_15 08_31 am

DavidS commented 7 years ago

There is currently no way to check this. Using your method as a basis, it should be straightforward to implement a with_redacted_#{attrname} matcher.

Have a look at https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/matchers/create_generic.rb and https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/matchers/dynamic_matchers.rb#L4 how the existing matchers are hooked up.

DavidS commented 5 years ago

Related: To input a Sensitive wrapper, one currently has to use RawString like in ref() (See https://github.com/rodjek/rspec-puppet/blob/7a49bef36884da50d399cdf74aff59e2e8f37389/lib/rspec-puppet/support.rb#L453-L455) . Adding a sensitive() helper similar to ref() would be a good addition if this gets picked up.

baurmatt commented 1 year ago

@DavidS Hasn't this been done with https://github.com/rodjek/rspec-puppet/commit/60549f701648cffe980ffa4e816cf19a67d2baa6 already? :)

DavidS commented 1 year ago

@DavidS Hasn't this been done with 60549f7 already? :)

maybe, maybe not.

2023-03-11_13MS+0100_399x551

@baurmatt

barrymw commented 8 months ago

The tyranny of time! This issue really needs to be closed as its been implemented for quite a while. As a reference, the code also includes some tests: https://github.com/rodjek/rspec-puppet/blob/c4ceecde20c9c53a388587dd37d6a2fc5dac50e5/spec/classes/test_sensitive_spec.rb#L4