|
3 | 3 | describe 'certs with tar archive' do |
4 | 4 | before(:all) do |
5 | 5 | on default, 'rm -rf /root/ssl-build' |
| 6 | + on default, 'rm -rf /etc/pki/katello' |
6 | 7 | end |
7 | 8 |
|
8 | | - before(:context) do |
9 | | - apply_manifest('include certs', catch_failures: true) |
10 | | - |
11 | | - pp = <<-PUPPET |
12 | | - class { 'certs': |
13 | | - generate => true, |
14 | | - deploy => false, |
15 | | - } |
16 | | -
|
17 | | - class { 'certs::foreman_proxy_content': |
18 | | - foreman_proxy_fqdn => 'foreman-proxy.example.com', |
19 | | - certs_tar => '/root/foreman-proxy.example.com.tar.gz', |
20 | | - } |
21 | | - PUPPET |
22 | | - |
23 | | - apply_manifest(pp, catch_failures: true) |
24 | | - on default, "rm -rf /root/ssl-build" |
25 | | - |
26 | | - install_certs = <<-PUPPET |
27 | | - class { 'certs': |
28 | | - tar_file => '/root/foreman-proxy.example.com.tar.gz', |
29 | | - generate => false, |
30 | | - node_fqdn => 'foreman-proxy.example.com', |
31 | | - } |
32 | | -
|
33 | | - include certs::apache |
34 | | - PUPPET |
35 | | - |
36 | | - # generation of a certs tar archive and extraction of it are not idempotent by design |
37 | | - apply_manifest(install_certs, catch_failures: true) |
38 | | - end |
39 | | - |
40 | | - after(:context) do |
41 | | - on default, 'yum -y remove foreman-proxy.example.com*noarch*' |
42 | | - end |
43 | | - |
44 | | - describe x509_certificate('/etc/pki/katello/certs/katello-apache.crt') do |
45 | | - it { should be_certificate } |
46 | | - it { should be_valid } |
47 | | - it { should have_purpose 'server' } |
48 | | - its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
49 | | - its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = Katello, OU = SomeOrgUnit, CN = foreman-proxy.example.com/) } |
50 | | - its(:keylength) { should be >= 4096 } |
51 | | - end |
52 | | - |
53 | | - describe x509_private_key('/etc/pki/katello/private/katello-apache.key') do |
54 | | - it { should_not be_encrypted } |
55 | | - it { should be_valid } |
56 | | - it { should have_matching_certificate('/etc/pki/katello/certs/katello-apache.crt') } |
57 | | - end |
58 | | - |
59 | | - describe x509_certificate('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt') do |
60 | | - it { should be_certificate } |
61 | | - it { should be_valid } |
62 | | - it { should have_purpose 'server' } |
63 | | - its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
64 | | - its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = Katello, OU = SomeOrgUnit, CN = foreman-proxy.example.com/) } |
65 | | - its(:keylength) { should be >= 4096 } |
66 | | - end |
67 | | - |
68 | | - describe x509_private_key('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.key') do |
69 | | - it { should_not be_encrypted } |
70 | | - it { should be_valid } |
71 | | - it { should have_matching_certificate('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt') } |
72 | | - end |
73 | | - |
74 | | - describe package("foreman-proxy.example.com-apache") do |
75 | | - it { should_not be_installed } |
76 | | - end |
77 | | - |
78 | | - describe file('/root/ssl-build/foreman-proxy.example.com') do |
79 | | - it { should be_directory } |
80 | | - end |
81 | | - |
82 | | - describe file('/root/ssl-build/katello-default-ca.crt') do |
83 | | - it { should exist } |
| 9 | + context 'default certificates' do |
| 10 | + before(:context) do |
| 11 | + pp = <<-PUPPET |
| 12 | + class { 'certs': |
| 13 | + generate => true, |
| 14 | + deploy => false, |
| 15 | + } |
| 16 | +
|
| 17 | + class { 'certs::foreman_proxy_content': |
| 18 | + foreman_proxy_fqdn => 'foreman-proxy.example.com', |
| 19 | + certs_tar => '/root/foreman-proxy.example.com.tar.gz', |
| 20 | + } |
| 21 | + PUPPET |
| 22 | + |
| 23 | + apply_manifest(pp, catch_failures: true) |
| 24 | + on default, "rm -rf /root/ssl-build" |
| 25 | + |
| 26 | + install_certs = <<-PUPPET |
| 27 | + class { 'certs': |
| 28 | + tar_file => '/root/foreman-proxy.example.com.tar.gz', |
| 29 | + generate => false, |
| 30 | + node_fqdn => 'foreman-proxy.example.com', |
| 31 | + } |
| 32 | +
|
| 33 | + include certs::apache |
| 34 | + PUPPET |
| 35 | + |
| 36 | + # generation of a certs tar archive and extraction of it are not idempotent by design |
| 37 | + apply_manifest(install_certs, catch_failures: true) |
| 38 | + end |
| 39 | + |
| 40 | + describe x509_certificate('/etc/pki/katello/certs/katello-apache.crt') do |
| 41 | + it { should be_certificate } |
| 42 | + it { should be_valid } |
| 43 | + it { should have_purpose 'server' } |
| 44 | + its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
| 45 | + its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = Katello, OU = SomeOrgUnit, CN = foreman-proxy.example.com/) } |
| 46 | + its(:keylength) { should be >= 4096 } |
| 47 | + end |
| 48 | + |
| 49 | + describe x509_private_key('/etc/pki/katello/private/katello-apache.key') do |
| 50 | + it { should_not be_encrypted } |
| 51 | + it { should be_valid } |
| 52 | + it { should have_matching_certificate('/etc/pki/katello/certs/katello-apache.crt') } |
| 53 | + end |
| 54 | + |
| 55 | + describe x509_certificate('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt') do |
| 56 | + it { should be_certificate } |
| 57 | + it { should be_valid } |
| 58 | + it { should have_purpose 'server' } |
| 59 | + its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
| 60 | + its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = Katello, OU = SomeOrgUnit, CN = foreman-proxy.example.com/) } |
| 61 | + its(:keylength) { should be >= 4096 } |
| 62 | + end |
| 63 | + |
| 64 | + describe x509_private_key('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.key') do |
| 65 | + it { should_not be_encrypted } |
| 66 | + it { should be_valid } |
| 67 | + it { should have_matching_certificate('/root/ssl-build/foreman-proxy.example.com/foreman-proxy.example.com-apache.crt') } |
| 68 | + end |
| 69 | + |
| 70 | + describe package("foreman-proxy.example.com-apache") do |
| 71 | + it { should_not be_installed } |
| 72 | + end |
| 73 | + |
| 74 | + describe file('/root/ssl-build/foreman-proxy.example.com') do |
| 75 | + it { should be_directory } |
| 76 | + end |
| 77 | + |
| 78 | + describe file('/root/ssl-build/katello-default-ca.crt') do |
| 79 | + it { should exist } |
| 80 | + end |
| 81 | + |
| 82 | + describe file('/root/ssl-build/katello-server-ca.crt') do |
| 83 | + it { should exist } |
| 84 | + end |
84 | 85 | end |
85 | 86 |
|
86 | | - describe file('/root/ssl-build/katello-server-ca.crt') do |
87 | | - it { should exist } |
| 87 | + context 'with custom certificates' do |
| 88 | + before(:context) do |
| 89 | + ['crt', 'key'].each do |ext| |
| 90 | + source_path = "fixtures/example.partial.solutions.#{ext}" |
| 91 | + dest_path = "/server.#{ext}" |
| 92 | + scp_to(hosts, source_path, dest_path) |
| 93 | + end |
| 94 | + |
| 95 | + source_path = "fixtures/example.partial.solutions-chain.pem" |
| 96 | + dest_path = "/server-ca.crt" |
| 97 | + scp_to(hosts, source_path, dest_path) |
| 98 | + |
| 99 | + manifest = <<~PUPPET |
| 100 | + class { 'certs': |
| 101 | + server_cert => '/server.crt', |
| 102 | + server_key => '/server.key', |
| 103 | + server_ca_cert => '/server-ca.crt', |
| 104 | + generate => true, |
| 105 | + deploy => false, |
| 106 | + } |
| 107 | +
|
| 108 | + class { 'certs::foreman_proxy_content': |
| 109 | + foreman_proxy_fqdn => 'foreman-proxy.example.com', |
| 110 | + certs_tar => '/root/foreman-proxy.example.com.tar.gz', |
| 111 | + } |
| 112 | + PUPPET |
| 113 | + |
| 114 | + apply_manifest(manifest, catch_failures: true) |
| 115 | + |
| 116 | + on default, 'rm -rf /root/ssl-build' |
| 117 | + |
| 118 | + install_certs = <<-PUPPET |
| 119 | + class { 'certs': |
| 120 | + tar_file => '/root/foreman-proxy.example.com.tar.gz', |
| 121 | + generate => false, |
| 122 | + node_fqdn => 'foreman-proxy.example.com', |
| 123 | + } |
| 124 | +
|
| 125 | + include certs::apache |
| 126 | + PUPPET |
| 127 | + |
| 128 | + # generation of a certs tar archive and extraction of it are not idempotent by design |
| 129 | + apply_manifest(install_certs, catch_failures: true) |
| 130 | + end |
| 131 | + |
| 132 | + describe 'default and server ca certs do not match' do |
| 133 | + it { expect(file('/etc/pki/katello/certs/katello-default-ca.crt').content).not_to eq(file('/etc/pki/katello/certs/katello-server-ca.crt').content) } |
| 134 | + end |
| 135 | + |
| 136 | + describe x509_certificate('/etc/pki/katello/certs/katello-default-ca.crt') do |
| 137 | + it { should be_certificate } |
| 138 | + it { should be_valid } |
| 139 | + it { should have_purpose 'SSL server CA' } |
| 140 | + its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
| 141 | + its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) } |
| 142 | + its(:keylength) { should be >= 4096 } |
| 143 | + end |
| 144 | + |
| 145 | + describe x509_certificate('/etc/pki/katello/certs/katello-server-ca.crt') do |
| 146 | + it { should be_certificate } |
| 147 | + it { should be_valid } |
| 148 | + it { should have_purpose 'SSL server CA' } |
| 149 | + # The issuer and subject are not identical as we only configure it with the intermediate |
| 150 | + # and not the actual root |
| 151 | + its(:issuer) { should match_without_whitespace(/CN = Fake LE Root X1/) } |
| 152 | + its(:subject) { should match_without_whitespace(/CN = Fake LE Intermediate X1/) } |
| 153 | + its(:keylength) { should be >= 2048 } |
| 154 | + end |
88 | 155 | end |
89 | 156 | end |
0 commit comments