summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe.nuspl <joe.nuspl@workday.com>2014-09-10 10:54:23 -0700
committerjoe.nuspl <joe.nuspl@workday.com>2014-09-10 10:54:23 -0700
commit13d328cd109740c60a2e633d13c6b1016c405d6e (patch)
tree6df1e5fc66534271d126370aaae891f1969098eb
parenteb3be6a44bb61707498083c48b8701edf7262287 (diff)
downloadchef-13d328cd109740c60a2e633d13c6b1016c405d6e.tar.gz
Added spec tests for sensitive execute resources
Change-Id: I4794d9c8ec38dff58c793bf4c4464862e70dc05b
-rw-r--r--spec/unit/provider/execute_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 78216a89fa..ba51d4d6c6 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -46,12 +46,31 @@ describe Chef::Provider::Execute do
opts[:log_tag] = @new_resource.to_s
opts[:live_stream] = STDOUT
@provider.should_receive(:shell_out!).with(@new_resource.command, opts)
+ @provider.should_receive(:converge_by).with("execute foo_resource").and_call_original
Chef::Log.should_not_receive(:warn)
@provider.run_action(:run)
@new_resource.should be_updated
end
+ it "should honor sensitive attribute" do
+ @new_resource.sensitive true
+ @provider = Chef::Provider::Execute.new(@new_resource, @run_context)
+ @provider.stub(:load_current_resource)
+ opts = {}
+ opts[:timeout] = @new_resource.timeout
+ opts[:returns] = @new_resource.returns
+ opts[:log_level] = :info
+ opts[:log_tag] = @new_resource.to_s
+ # Since the resource is sensitive, it should not have :live_stream set
+ # opts[:live_stream] = STDOUT
+ @provider.should_receive(:shell_out!).with(@new_resource.command, opts)
+ Chef::Log.should_not_receive(:warn)
+ @provider.should_receive(:converge_by).with("execute sensitive resource").and_call_original
+ @provider.run_action(:run)
+ @new_resource.should be_updated
+ end
+
it "should do nothing if the sentinel file exists" do
@provider.stub(:load_current_resource)
File.should_receive(:exists?).with(@new_resource.creates).and_return(true)