Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept Datatype Sensitive for $content #201

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
define systemd::unit_file (
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[String] $content = undef,
Optional[Variant[String, Sensitive[String]]] $content = undef,
Optional[String] $source = undef,
Optional[Stdlib::Absolutepath] $target = undef,
String $owner = 'root',
Expand Down
26 changes: 21 additions & 5 deletions spec/defines/unit_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,27 @@

it { is_expected.to compile.with_all_deps }

it do
is_expected.to create_file("/etc/systemd/system/#{title}").
with_ensure('file').
with_content(%r{#{params[:content]}}).
with_mode('0444')
context 'with non-sensitive Content' do
let(:params) { { content: 'non-sensitive Content' } }

it do
is_expected.to create_file("/etc/systemd/system/#{title}").
with_ensure('file').
with_content(params[:content]).
with_mode('0444')
end
end

context 'with sensitive Content' do
let(:params) { { content: sensitive('sensitive Content') } }

it do
resource = catalogue.resource("File[/etc/systemd/system/#{title}]")
expect(resource[:content]).to eq(params[:content].unwrap)

is_expected.to contain_file("/etc/systemd/system/#{title}").
with({ content: sensitive('sensitive Content') })
end
end

context 'with a bad unit type' do
Expand Down