summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Bolt <cbolt@denirostaff.com>2015-10-27 09:44:32 -0700
committerJohn Keiser <john@johnkeiser.com>2015-10-27 20:33:02 -0700
commitd81a1306abc77d8b69e043f06a14d21547c7fbc6 (patch)
treee0b89952e5b468d86e1b36c5c24aa60d8ca824e8
parentde5cbc446e1c20d5b6b6bc88f6a617b4cdefc6bd (diff)
downloadchef-d81a1306abc77d8b69e043f06a14d21547c7fbc6.tar.gz
tests and style
-rw-r--r--lib/chef/provider.rb4
-rw-r--r--spec/integration/recipes/resource_converge_if_changed_spec.rb48
2 files changed, 50 insertions, 2 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 1e8146428e..d9d6b49894 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -205,7 +205,7 @@ class Chef
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
if modified.empty?
properties_str = if sensitive
- '(suppressed sensitive properties)'
+ specified_properties.join(", ")
else
specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")
end
@@ -236,7 +236,7 @@ class Chef
else
new_resource.send(property).inspect
end
- " set #{property.to_s.ljust(property_size)} to #{properties_str}" + default ||= ''
+ " set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
end
converge_by([ "create #{new_resource.identity}" ] + created, &converge_block)
diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb
index 82d38a8faf..fb01da5137 100644
--- a/spec/integration/recipes/resource_converge_if_changed_spec.rb
+++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb
@@ -110,6 +110,29 @@ EOM
end
end
+ context "and state1 and state2 are set to new sensitive values" do
+ let(:converge_recipe) {
+ <<-EOM
+ #{resource_name} 'blah' do
+ sensitive true
+ state1 'new_state1'
+ state2 'new_state2'
+ end
+ EOM
+ }
+
+ it "the resource updates state1 and state2" do
+ expect(resource.converged).to eq 1
+ expect(resource.updated?).to be_truthy
+ expect(converged_recipe.stdout).to eq <<-EOM
+* #{resource_name}[blah] action create
+ - update default_identity1
+ - set state1 to (suppressed sensitive properties)
+ - set state2 to (suppressed sensitive properties)
+EOM
+ end
+ end
+
context "and state1 is set to its current value but state2 is set to a new value" do
let(:converge_recipe) {
<<-EOM
@@ -416,6 +439,31 @@ EOM
EOM
end
end
+
+ context "and state1 and state2 are set to new sensitive values" do
+ let(:converge_recipe) {
+ <<-EOM
+ #{resource_name} 'blah' do
+ sensitive true
+ state1 'new_state1'
+ state2 'new_state2'
+ end
+ EOM
+ }
+
+ it "the resource is created" do
+ expect(resource.converged).to eq 2
+ expect(resource.updated?).to be_truthy
+ expect(converged_recipe.stdout).to eq <<-EOM
+* #{resource_name}[blah] action create
+ - create default_identity1
+ - set state1 to (suppressed sensitive properties)
+ - create default_identity1
+ - set state2 to (suppressed sensitive properties)
+EOM
+ end
+ end
+
end
end