Skip to content

Commit 87efeda

Browse files
authored
Merge pull request #235 from cirrax/dev_file_ownership_defaults
fix default configs file ownership
2 parents 6dc8cfd + af24e28 commit 87efeda

File tree

2 files changed

+66
-30
lines changed

2 files changed

+66
-30
lines changed

manifests/configs.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
$conffiles.each | String $filename, Hash $vals | {
7676
openssl::config { $filename:
7777
* => {
78+
owner => $owner,
79+
group => $group,
80+
mode => $mode,
7881
country => $country,
7982
state => $state,
8083
locality => $locality,

spec/classes/configs_spec.rb

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,72 @@
66
on_supported_os.each do |os, os_facts|
77
context "on #{os}" do
88
let(:facts) { os_facts }
9-
let :params do
10-
{
11-
country: 'CH',
12-
organization: 'Existing Ltd',
13-
conffiles: {
14-
'/path/to/openssl.conf' => { 'country' => 'US', 'commonname' => 'servername.xyz.org' },
15-
'/other/path/to/openssl.conf' => { 'group' => 'vpn', 'commonname' => ['test.ch', 'test2.ch'] },
16-
'/absent.conf' => { 'ensure' => 'absent', 'commonname' => 'blah' },
17-
},
9+
10+
context 'without ownership defaults' do
11+
let :params do
12+
{
13+
country: 'CH',
14+
organization: 'Existing Ltd',
15+
conffiles: {
16+
'/path/to/openssl.conf' => { 'country' => 'US', 'commonname' => 'servername.xyz.org' },
17+
'/other/path/to/openssl.conf' => { 'group' => 'vpn', 'commonname' => ['test.ch', 'test2.ch'] },
18+
'/absent.conf' => { 'ensure' => 'absent', 'commonname' => 'blah' },
19+
},
20+
}
21+
end
22+
23+
it { is_expected.to compile }
24+
25+
it {
26+
is_expected.to contain_file('/path/to/openssl.conf').
27+
with_ensure('present').
28+
with_owner('root').
29+
with_mode('0640')
30+
}
31+
32+
it {
33+
is_expected.to contain_file('/other/path/to/openssl.conf').
34+
with_ensure('present').
35+
with_owner('root').
36+
with_group('vpn').
37+
with_mode('0640')
38+
}
39+
40+
it {
41+
is_expected.to contain_file('/absent.conf').
42+
with_ensure('absent')
1843
}
1944
end
2045

21-
it { is_expected.to compile }
22-
23-
it {
24-
is_expected.to contain_file('/path/to/openssl.conf').
25-
with_ensure('present').
26-
with_owner('root').
27-
with_mode('0640')
28-
}
29-
30-
it {
31-
is_expected.to contain_file('/other/path/to/openssl.conf').
32-
with_ensure('present').
33-
with_owner('root').
34-
with_group('vpn').
35-
with_mode('0640')
36-
}
37-
38-
it {
39-
is_expected.to contain_file('/absent.conf').
40-
with_ensure('absent')
41-
}
46+
context 'with ownership defaults' do
47+
let :params do
48+
{
49+
owner: 'someone',
50+
group: 'somegroup',
51+
mode: '0000',
52+
conffiles: {
53+
'/path/to/openssl.conf' => { 'commonname' => 'servername.xyz.org' },
54+
'/tmp/openssl.conf' => { 'commonname' => 'some', 'owner' => 'whoever', 'group' => 'agroup', 'mode' => '1111' },
55+
},
56+
}
57+
end
58+
59+
it {
60+
is_expected.to contain_file('/path/to/openssl.conf').
61+
with_ensure('present').
62+
with_owner('someone').
63+
with_group('somegroup').
64+
with_mode('0000')
65+
}
66+
67+
it {
68+
is_expected.to contain_file('/tmp/openssl.conf').
69+
with_ensure('present').
70+
with_owner('whoever').
71+
with_group('agroup').
72+
with_mode('1111')
73+
}
74+
end
4275
end
4376
end
4477
end

0 commit comments

Comments
 (0)