-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying owner/group/mode/show_diff (#94)
Some systemd files could contain sensitive information like .netdev files associated with wireguard devices that contain private keys and potentially pre-shared keys.
- Loading branch information
1 parent
f6929de
commit 629a8fb
Showing
4 changed files
with
132 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,59 @@ | ||
require 'spec_helper' | ||
|
||
describe 'systemd::network' do | ||
let :params do | ||
{ | ||
restart_service: true | ||
} | ||
end | ||
context 'supported operating systems' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
# manage systemd-networkd service | ||
let :pre_condition do | ||
"class { 'systemd': | ||
manage_networkd => true, | ||
}" | ||
end | ||
|
||
let(:title) { 'eth0.network' } | ||
let(:facts) { facts } | ||
|
||
on_supported_os.each do |os, facts| | ||
let :facts do | ||
facts | ||
end | ||
let(:title) { 'eth0.network' } | ||
|
||
let(:params) {{ | ||
:content => 'random stuff', | ||
:restart_service => true, | ||
}} | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { is_expected.to create_file("/etc/systemd/network/#{title}").with( | ||
:ensure => 'file', | ||
:content => /#{params[:content]}/, | ||
:mode => '0444' | ||
) } | ||
|
||
it { is_expected.to create_file("/etc/systemd/network/#{title}").that_notifies('Service[systemd-networkd]') } | ||
|
||
context 'with group => systemd-network, mode => 0640 and show_diff => false' do | ||
let(:title) { 'wg0.netdev' } | ||
|
||
let(:params) {{ | ||
:content => 'secret string', | ||
:group => 'systemd-network', | ||
:mode => '0640', | ||
:show_diff => false, | ||
:restart_service => true, | ||
}} | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
|
||
it { is_expected.to create_file("/etc/systemd/network/#{title}").with( | ||
:ensure => 'file', | ||
:content => /#{params[:content]}/, | ||
:group => 'systemd-network', | ||
:mode => '0640', | ||
:show_diff => false | ||
) } | ||
|
||
context 'with all defaults' do | ||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to create_file("/etc/systemd/network/#{title}").that_notifies('Service[systemd-networkd]') } | ||
end | ||
end | ||
end | ||
end | ||
end |