diff options
author | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2017-12-07 09:02:01 +0000 |
---|---|---|
committer | Vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2017-12-26 08:38:42 +0000 |
commit | 4da3e139ccce5ca9813ec2900109cf3cee3b130d (patch) | |
tree | e72b29dd18150d58c1773ff4fccd10fc0377cbd0 | |
parent | bfe8487a26f99d3cd3e08fffea8cf6457631cf69 (diff) | |
download | chef-4da3e139ccce5ca9813ec2900109cf3cee3b130d.tar.gz |
[MSYS-725] [chef#6073] allow forcing senistive to false on execute and batch resource
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
-rw-r--r-- | lib/chef/resource/execute.rb | 3 | ||||
-rw-r--r-- | spec/support/shared/unit/execute_resource.rb | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index de927ec06e..616195deee 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -133,7 +133,8 @@ class Chef property :password, String, sensitive: true - property :sensitive, [ TrueClass, FalseClass ], default: false, coerce: proc { |x| password ? true : x } + # lazy used to set default value of sensitive to true if password is set + property :sensitive, [ TrueClass, FalseClass ], default: lazy { |r| r.password ? true : false } property :elevated, [ TrueClass, FalseClass ], default: false diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb index ae56a9697d..c15b02612e 100644 --- a/spec/support/shared/unit/execute_resource.rb +++ b/spec/support/shared/unit/execute_resource.rb @@ -139,7 +139,14 @@ shared_examples_for "an execute resource" do it "should be true if the password is non-nil but the value is explicitly set to false" do @resource.password("we.funk!") @resource.sensitive false - expect(@resource.sensitive).to eq(true) + expect(@resource.sensitive).to eq(false) + end + + # added this test to ensure setting of password property after or before sensitive does not matter + it "should be false if the sensitive is set before password property" do + @resource.sensitive false + @resource.password("we.funk!") + expect(@resource.sensitive).to eq(false) end end |