From 13d328cd109740c60a2e633d13c6b1016c405d6e Mon Sep 17 00:00:00 2001 From: "joe.nuspl" Date: Wed, 10 Sep 2014 10:54:23 -0700 Subject: Added spec tests for sensitive execute resources Change-Id: I4794d9c8ec38dff58c793bf4c4464862e70dc05b --- spec/unit/provider/execute_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec/unit/provider/execute_spec.rb') 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) -- cgit v1.2.1