Skip to content

Commit b30e456

Browse files
committed
Add test coverage for certs
1 parent 21ddfb0 commit b30e456

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

spec/classes/certs_spec.rb

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,65 @@
77
os_facts
88
end
99

10-
it { should contain_class('certs::install') }
11-
it { should contain_class('certs::config') }
10+
context 'with default parameters' do
11+
it { is_expected.to compile.with_all_deps }
12+
it { is_expected.to contain_class('certs') }
13+
it { is_expected.to contain_class('certs::params') }
14+
15+
# Install
16+
it { is_expected.to contain_class('certs::install') }
17+
it { is_expected.to contain_package('katello-certs-tools') }
18+
19+
# Config
20+
it { is_expected.to contain_class('certs::config').that_requires('Class[certs::install]') }
21+
it { is_expected.to contain_file('/etc/pki/katello').with_mode('0755').with_owner('root').with_group('root') }
22+
it { is_expected.to contain_file('/etc/pki/katello/certs').with_mode('0755').with_owner('root').with_group('root') }
23+
it { is_expected.to contain_file('/etc/pki/katello/private').with_mode('0750').with_owner('root').with_group('root') }
24+
25+
# CA verification
26+
it { is_expected.to contain_class('certs::ca').that_requires('Class[certs::config]') }
27+
28+
it { is_expected.to contain_file('/etc/pki/katello/private/katello-default-ca.pwd') }
29+
it do
30+
is_expected.to contain_ca('katello-default-ca')
31+
.with_common_name('foo.example.com')
32+
.with_country('US')
33+
.with_state('North Carolina')
34+
.with_city('Raleigh')
35+
.with_org('Katello')
36+
.with_org_unit('SomeOrgUnit')
37+
.with_expiration('36500')
38+
.with_generate(true)
39+
.with_deploy(true)
40+
.that_requires('File[/etc/pki/katello/private/katello-default-ca.pwd]')
41+
end
42+
43+
it { is_expected.to contain_privkey('/etc/pki/katello/private/katello-default-ca.key').that_requires('Ca[katello-default-ca]') }
44+
it do
45+
is_expected.to contain_file('/etc/pki/katello/private/katello-default-ca.key')
46+
.that_subscribes_to(['Ca[katello-default-ca]', 'Privkey[/etc/pki/katello/private/katello-default-ca.key]'])
47+
end
48+
49+
it { is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-default-ca-stripped.crt').that_subscribes_to('Ca[katello-default-ca]') }
50+
51+
it { is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-default-ca.crt').that_subscribes_to('Ca[katello-default-ca]') }
52+
it do
53+
is_expected.to contain_file('/etc/pki/katello/certs/katello-default-ca.crt')
54+
.that_subscribes_to(['Ca[katello-default-ca]', 'Pubkey[/etc/pki/katello/certs/katello-default-ca.crt]'])
55+
end
56+
57+
it do
58+
is_expected.to contain_ca('katello-server-ca')
59+
.with_ca('Ca[katello-default-ca]')
60+
.that_requires('Ca[katello-default-ca]')
61+
end
62+
it { is_expected.to contain_file('/root/ssl-build/KATELLO-TRUSTED-SSL-CERT').that_requires('Ca[katello-server-ca]') }
63+
it { is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-server-ca.crt') }
64+
it do
65+
is_expected.to contain_file('/etc/pki/katello/certs/katello-server-ca.crt')
66+
.that_subscribes_to(['Ca[katello-server-ca]', 'Pubkey[/etc/pki/katello/certs/katello-server-ca.crt]'])
67+
end
68+
end
1269
end
1370
end
1471
end

0 commit comments

Comments
 (0)