diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-20 09:51:12 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-02-20 09:51:12 -0600 |
| commit | 602409e18c5b3229f6d239ac28472dd4709a117b (patch) | |
| tree | 1a6ed7f73c65bf97f4e419e626dba4c8f29a7873 | |
| parent | c0d5037d11643fd551fdc9f20a9e0ba196c5345a (diff) | |
| parent | d758f45a14057f0b9517a1905d575d6b28b90bc2 (diff) | |
| download | puppet-602409e18c5b3229f6d239ac28472dd4709a117b.tar.gz puppet-602409e18c5b3229f6d239ac28472dd4709a117b.tar.xz puppet-602409e18c5b3229f6d239ac28472dd4709a117b.zip | |
Merge branch '0.24.x'
Conflicts:
lib/puppet/type/file/content.rb
spec/unit/type/file/content.rb
| -rw-r--r-- | CHANGELOG | 2 | ||||
| -rwxr-xr-x | lib/puppet/type/file/content.rb | 23 | ||||
| -rwxr-xr-x | spec/unit/type/file/content.rb | 25 |
3 files changed, 38 insertions, 12 deletions
@@ -14,6 +14,8 @@ Fixed #1840 - Bug fixes and improvements for Emacs puppet-mode.el 0.24.8 + Fixed #1871 - Sensitive information leaked in log reports + Fixed #1956 - Cleaned up variable names to be more sane, clarified error messages and fixed incorrect use of 'value' variable rather than 'member'. diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index 6d6dad4f1..385a86357 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -25,18 +25,17 @@ module Puppet This attribute is especially useful when used with `PuppetTemplating templating`:trac:." - def change_to_s(currentvalue, newvalue) - if source = resource.parameter(:source) - newvalue = source.metadata.checksum - else - newvalue = "{md5}" + Digest::MD5.hexdigest(newvalue) - end - if currentvalue == :absent - return "created file with contents %s" % newvalue - else - currentvalue = "{md5}" + Digest::MD5.hexdigest(currentvalue) - return "changed file contents from %s to %s" % [currentvalue, newvalue] - end + def string_as_checksum(string) + return "absent" if string == :absent + "{md5}" + Digest::MD5.hexdigest(string) + end + + def should_to_s(should) + string_as_checksum(should) + end + + def is_to_s(is) + string_as_checksum(is) end def content diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb index 9b61b8d9b..212bb2fdb 100755 --- a/spec/unit/type/file/content.rb +++ b/spec/unit/type/file/content.rb @@ -166,4 +166,29 @@ describe content do @content.sync.should == :file_created end end + + describe "when logging changes" do + before do + @resource = stub 'resource', :line => "foo", :file => "bar", :replace? => true + @resource.stubs(:[]).returns "foo" + @resource.stubs(:[]).with(:path).returns "/my/file" + @content = content.new :resource => @resource + end + + it "should not include current contents" do + @content.change_to_s("current_content", "desired").should_not be_include("current_content") + end + + it "should not include desired contents" do + @content.change_to_s("current", "desired_content").should_not be_include("desired_content") + end + + it "should not include the content when converting current content to a string" do + @content.is_to_s("my_content").should_not be_include("my_content") + end + + it "should not include the content when converting desired content to a string" do + @content.should_to_s("my_content").should_not be_include("my_content") + end + end end |
