summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorblabade <107531905+blabade@users.noreply.github.com>2022-07-07 19:44:07 +0530
committerGitHub <noreply@github.com>2022-07-07 19:44:07 +0530
commit416704635ddddb61618184cfb5860b5859357711 (patch)
tree2618dd1eb19400146eb317bdbf3b1ab00115d9f8 /spec
parent8ec9f0cbd5a092c2ca8a9630e9d577042c74285b (diff)
parent8c139ab355803a3487f91cd89121a57731a5f3e6 (diff)
downloadchef-416704635ddddb61618184cfb5860b5859357711.tar.gz
Merge pull request #13014 from chef/fix_desired_state_issue
Fixed sensitive properties unsuppressed content issue
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index f0a624d5db..db355d44fa 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -371,6 +371,9 @@ describe Chef::Resource do
end
describe "to_text" do
+
+ let(:sensitive_property_masked_value) { "sensitive value suppressed" }
+
it "prints nice message" do
resource_class = Class.new(Chef::Resource) { property :foo, String }
resource = resource_class.new("sensitive_property_tests")
@@ -383,7 +386,24 @@ describe Chef::Resource do
resource_class = Class.new(Chef::Resource) { property :foo, String, sensitive: true }
resource = resource_class.new("sensitive_property_tests")
resource.foo = "some value"
- expect(resource.to_text).to match(/foo "\*sensitive value suppressed\*"/)
+ expect(resource.to_text).to match(/foo "\*#{sensitive_property_masked_value}\*"/)
+ end
+ it "suppresses that properties value irrespective of desired state (false) " do
+ resource_class = Class.new(Chef::Resource) {
+ property :suppressed_content, String, sensitive: true, desired_state: false
+ }
+ resource = resource_class.new("desired_state_property_tests")
+ resource.suppressed_content = "some value"
+ expect(resource.to_text).to match(/suppressed_content "\*#{sensitive_property_masked_value}\*"/)
+ end
+
+ it "suppresses that properties value irrespective of desired state (true) " do
+ resource_class = Class.new(Chef::Resource) {
+ property :desired_state_content, String, sensitive: true, desired_state: true
+ }
+ resource = resource_class.new("desired_state_property_tests")
+ resource.desired_state_content = "some value"
+ expect(resource.to_text).to match(/desired_state_content "\*#{sensitive_property_masked_value}\*"/)
end
end