Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
Optional[Stdlib::Port] $db_port = undef,
String[1] $db_database = 'foreman',
String[1] $db_username = 'foreman',
String[1] $db_password = $foreman::params::db_password,
Variant[String[1], Sensitive[String[1]]] $db_password = $foreman::params::db_password,
Optional[String[1]] $db_sslmode = undef,
Optional[String[1]] $db_root_cert = undef,
Optional[Integer[0]] $db_pool = undef,
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,17 @@

it { should contain_user('foreman').with('groups' => []) }
end

describe 'with sensitive passwords' do
let(:params) do
super().merge(db_password: sensitive('secret'))
end

it 'should configure the database' do
should contain_file('/etc/foreman/database.yml')
.with_content(/password: "secret"/)
end
end
end
end
end
2 changes: 1 addition & 1 deletion templates/database.yml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
username: <%= $username %>
<% } -%>
<% if $password { -%>
password: "<%= $password %>"
password: <%= stdlib::to_ruby($password) %>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I drop this, I get:

expected that the catalogue would contain File[/etc/foreman/database.yml] with content set to /password: "secret"/ but it is set to #<Sensitive [value redacted]>

so maybe with_content is a bad idea to begin with?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_content(sensitive(…)) works for the plain case, but not once to_ruby is involved. yay

<% } -%>
pool: <%= $db_pool %>