Skip to content

Commit 729502a

Browse files
committed
Add a test for customer server certificates in tar file
This asserts that the default CA and server CA are the same in one scenario and differ in the other.
1 parent 2b9f043 commit 729502a

File tree

1 file changed

+61
-20
lines changed

1 file changed

+61
-20
lines changed

spec/acceptance/foreman_proxy_content_spec.rb

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55
on default, 'rm -rf /root/ssl-build'
66
end
77

8-
context 'with default parameters' do
9-
before(:context) do
10-
apply_manifest('include certs', catch_failures: true)
8+
let(:expected_files_in_tar) do
9+
[
10+
'ssl-build/katello-default-ca.crt',
11+
'ssl-build/katello-server-ca.crt',
12+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt',
13+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-client.crt',
14+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy-client.crt',
15+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy.crt',
16+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-puppet-client.crt',
17+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.key',
18+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-client.key',
19+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy-client.key',
20+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy.key',
21+
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-puppet-client.key',
22+
]
23+
end
1124

12-
pp = <<-PUPPET
25+
context 'with default CA' do
26+
before(:context) do
27+
manifest = <<~PUPPET
1328
class { 'certs':
1429
generate => true,
1530
deploy => false,
@@ -21,29 +36,55 @@ class { 'certs::foreman_proxy_content':
2136
}
2237
PUPPET
2338

24-
apply_manifest(pp, catch_failures: true)
39+
apply_manifest(manifest, catch_failures: true)
40+
end
41+
42+
describe tar('/root/foreman-proxy.example.com.tar.gz') do
43+
it { should exist }
44+
its(:contents) { should match_array(expected_files_in_tar) }
45+
end
46+
47+
describe 'default and server ca certs match' do
48+
it { expect(file('/root/ssl-build/katello-default-ca.crt').content).to eq(file('/root/ssl-build/katello-server-ca.crt').content) }
2549
end
50+
end
51+
52+
context 'with server certificates' do
53+
before(:context) do
54+
certs = {
55+
'fixtures/example.partial.solutions.crt' => '/server.crt',
56+
'fixtures/example.partial.solutions.key' => '/server.key',
57+
'fixtures/example.partial.solutions-chain.pem' => '/server-ca.crt',
58+
}
59+
certs.each do |source_path, dest_path|
60+
scp_to(hosts, source_path, dest_path)
61+
end
62+
63+
manifest = <<~PUPPET
64+
class { 'certs':
65+
server_cert => '/server.crt',
66+
server_key => '/server.key',
67+
server_ca_cert => '/server-ca.crt',
68+
generate => true,
69+
deploy => false,
70+
}
71+
72+
class { 'certs::foreman_proxy_content':
73+
foreman_proxy_fqdn => 'foreman-proxy.example.com',
74+
certs_tar => '/root/foreman-proxy.example.com.tar.gz',
75+
}
76+
PUPPET
2677

27-
let(:expected_files_in_tar) do
28-
[
29-
'ssl-build/katello-default-ca.crt',
30-
'ssl-build/katello-server-ca.crt',
31-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt',
32-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-client.crt',
33-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy-client.crt',
34-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy.crt',
35-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-puppet-client.crt',
36-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.key',
37-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-client.key',
38-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy-client.key',
39-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-foreman-proxy.key',
40-
'ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-puppet-client.key',
41-
]
78+
apply_manifest(manifest, catch_failures: true)
4279
end
4380

4481
describe tar('/root/foreman-proxy.example.com.tar.gz') do
4582
it { should exist }
4683
its(:contents) { should match_array(expected_files_in_tar) }
4784
end
85+
86+
describe 'default and server ca certs differ' do
87+
it { expect(file('/root/ssl-build/katello-default-ca.crt').content).not_to eq(file('/root/ssl-build/katello-server-ca.crt').content) }
88+
end
4889
end
4990
end

0 commit comments

Comments
 (0)