summaryrefslogtreecommitdiff
path: root/spec/unit/resource_spec.rb
diff options
context:
space:
mode:
authorTom Duffield <tom@chef.io>2017-02-10 13:02:15 -0600
committerTom Duffield <tom@chef.io>2017-02-10 13:05:50 -0600
commit346ee33c99bb630ea60d59833f74c5c2c05bed97 (patch)
treedf29565c15e0237ab1b4bfe4e46780e15a79d3f9 /spec/unit/resource_spec.rb
parent963acf8094a67a26373311039c139daac0f0a8b4 (diff)
downloadchef-346ee33c99bb630ea60d59833f74c5c2c05bed97.tar.gz
Suppress sensitive properties from resource output
Signed-off-by: Tom Duffield <tom@chef.io>
Diffstat (limited to 'spec/unit/resource_spec.rb')
-rw-r--r--spec/unit/resource_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index fbe4544c19..2f75ba0241 100644
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -354,6 +354,24 @@ describe Chef::Resource do
end
end
+ describe "to_text" do
+ it "prints nice message" do
+ resource_class = Class.new(Chef::Resource) { property :foo, String }
+ resource = resource_class.new("sensitive_property_tests")
+ resource.foo = "some value"
+ expect(resource.to_text).to match(/foo "some value"/)
+ end
+
+ context "when property is sensitive" do
+ it "supresses that properties value" 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\*"/)
+ end
+ end
+ end
+
describe "self.resource_name" do
context "When resource_name is not set" do
it "and there are no provides lines, resource_name is nil" do