-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented show_diff parameter, with similar behaviour as show_diff on
type file show_diff => true (default) prints diff to logs show_diff => md5 prints only md5 hashes instead of actual values show_diff => false redacts any information about values Global show_diff config takes priotiry over this one.
- Loading branch information
1 parent
27857c2
commit 31e309d
Showing
6 changed files
with
263 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#! /usr/bin/env ruby | ||
require 'spec_helper' | ||
|
||
ini_setting = Puppet::Type.type(:ini_setting) | ||
|
||
describe ini_setting do | ||
|
||
[true, false].product([true, false, "true", "false", "md5", :md5]).each do |cfg, param| | ||
describe "when Puppet[:show_diff] is #{cfg} and show_diff => #{param}" do | ||
|
||
before do | ||
Puppet[:show_diff] = cfg | ||
@value = described_class.new(:name => 'foo', :value => 'whatever', :show_diff => param).property(:value) | ||
end | ||
|
||
if (cfg and [true, "true"].include? param) | ||
it "should display diff" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('not_secret','at_all') | ||
end | ||
|
||
it "should tell current value" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('not_secret_at_all') | ||
end | ||
|
||
it "should tell new value" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('not_secret_at_all') | ||
end | ||
elsif (cfg and ["md5", :md5].include? param) | ||
it "should tell correct md5 hash for value" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('e9e8db547f8960ef32dbc34029735564','46cd73a9509ba78c39f05faf078a8cbe') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('not_secret') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('at_all') | ||
end | ||
|
||
it "should tell md5 of current value, but not value itself" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('{md5}218fde79f501b8ab8d212f1059bb857f') | ||
expect(@value.is_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
|
||
it "should tell md5 of new value, but not value itself" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('{md5}218fde79f501b8ab8d212f1059bb857f') | ||
expect(@value.should_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
else | ||
it "should not tell any actual values" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('[redacted sensitive information]') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('not_secret') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('at_all') | ||
end | ||
|
||
it "should not tell current value" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('[redacted sensitive information]') | ||
expect(@value.is_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
|
||
it "should not tell new value" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('[redacted sensitive information]') | ||
expect(@value.should_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#! /usr/bin/env ruby | ||
require 'spec_helper' | ||
|
||
ini_subsetting = Puppet::Type.type(:ini_subsetting) | ||
|
||
describe ini_subsetting do | ||
[true, false].product([true, false, :md5]).each do |cfg, param| | ||
describe "when Puppet[:show_diff] is #{cfg} and show_diff => #{param}" do | ||
|
||
before do | ||
Puppet[:show_diff] = cfg | ||
@value = described_class.new(:name => 'foo', :value => 'whatever', :show_diff => param).property(:value) | ||
end | ||
|
||
if (cfg and param == true) | ||
it "should display diff" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('not_secret','at_all') | ||
end | ||
|
||
it "should tell current value" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('not_secret_at_all') | ||
end | ||
|
||
it "should tell new value" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('not_secret_at_all') | ||
end | ||
elsif (cfg and param == :md5) | ||
it "should tell correct md5 hash for value" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('e9e8db547f8960ef32dbc34029735564','46cd73a9509ba78c39f05faf078a8cbe') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('not_secret') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('at_all') | ||
end | ||
|
||
it "should tell md5 of current value, but not value itself" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('{md5}218fde79f501b8ab8d212f1059bb857f') | ||
expect(@value.is_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
|
||
it "should tell md5 of new value, but not value itself" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('{md5}218fde79f501b8ab8d212f1059bb857f') | ||
expect(@value.should_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
else | ||
it "should not tell any actual values" do | ||
expect(@value.change_to_s('not_secret','at_all')).to include('[redacted sensitive information]') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('not_secret') | ||
expect(@value.change_to_s('not_secret','at_all')).not_to include('at_all') | ||
end | ||
|
||
it "should not tell current value" do | ||
expect(@value.is_to_s('not_secret_at_all')).to eq('[redacted sensitive information]') | ||
expect(@value.is_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
|
||
it "should not tell new value" do | ||
expect(@value.should_to_s('not_secret_at_all')).to eq('[redacted sensitive information]') | ||
expect(@value.should_to_s('not_secret_at_all')).not_to include('not_secret_at_all') | ||
end | ||
end | ||
end | ||
end | ||
end |