diff options
author | dmitrys <dmitrys@northernlight.com> | 2017-09-26 12:07:35 -0400 |
---|---|---|
committer | dmitrys <dmitrys@northernlight.com> | 2017-09-26 12:07:35 -0400 |
commit | 8242ac9f65f841030ba4a3cc3cc91a8208b3c4f8 (patch) | |
tree | bec9dc72c86c10ea66f3229b406f11168398af26 | |
parent | c4af66766f970b915a5bd2cd65308936082202a7 (diff) | |
download | chef-8242ac9f65f841030ba4a3cc3cc91a8208b3c4f8.tar.gz |
sensitive? returns true by default for password property
Signed-off-by: dmitrys <dmitrys@northernlight.com>
-rw-r--r-- | lib/chef/property.rb | 6 | ||||
-rw-r--r-- | spec/unit/property_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb index a72e41a61e..e258498189 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -242,7 +242,11 @@ class Chef # @return [Boolean] # def sensitive? - options.fetch(:sensitive, false) + if name == :password + options.fetch(:sensitive, true) + else + options.fetch(:sensitive, false) + end end # diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index b8cf7f5d1b..510b0f94d7 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -118,6 +118,20 @@ describe "Chef::Resource.property" do end end + with_property ":password, String" do + it "password is sensitive by default" do + expect(resource.password "Jetstream123!").to eql("Jetstream123!") + expect(resource.state_for_resource_reporter[:password]).to eql("*sensitive value suppressed*") + end + end + + with_property ":password, String, sensitive: false" do + it "password is no longer sensitive" do + expect(resource.password "Jetstream123!").to eql("Jetstream123!") + expect(resource.state_for_resource_reporter[:password]).to eql("Jetstream123!") + end + end + with_property ":x, name_property: true" do context "and subclass" do let(:subresource_class) do diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 466b6ac8c0..caa2e2f65a 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -205,7 +205,7 @@ describe Chef::Resource::Mount do state = @resource.state_for_resource_reporter expect(state[:mount_point]).to eq("T:") expect(state[:username]).to eq("Administrator") - expect(state[:password]).to eq("Jetstream123!") + expect(state[:password]).to eq("*sensitive value suppressed*") expect(state[:domain]).to eq("TEST_DOMAIN") expect(state[:device_type]).to eql(:device) expect(state[:fstype]).to eq("auto") |