@@ -145,4 +145,106 @@ class { 'certs':
145145 its ( :keylength ) { should be >= 2048 }
146146 end
147147 end
148+
149+ context 'with tar file' do
150+ context 'with default ca' do
151+ before ( :context ) do
152+ manifest = <<~PUPPET
153+ class { 'certs':
154+ generate => true,
155+ deploy => false,
156+ }
157+
158+ class { 'certs::foreman_proxy_content':
159+ foreman_proxy_fqdn => 'foreman-proxy.example.com',
160+ certs_tar => '/root/foreman-proxy.example.com.tar.gz',
161+ }
162+ PUPPET
163+
164+ apply_manifest ( manifest , catch_failures : true )
165+
166+ on default , 'rm -rf /root/ssl-build'
167+ end
168+
169+ describe 'deploy certificates' do
170+ manifest = <<-PUPPET
171+ class { 'certs':
172+ tar_file => '/root/foreman-proxy.example.com.tar.gz',
173+ }
174+ PUPPET
175+ # tar extraction is not idempotent
176+ it { apply_manifest ( manifest , catch_failures : true ) }
177+ end
178+
179+ describe 'default and server ca certs match' do
180+ it { expect ( file ( '/etc/pki/katello/certs/katello-default-ca.crt' ) . content ) . to eq ( file ( '/etc/pki/katello/certs/katello-server-ca.crt' ) . content ) }
181+ end
182+
183+ describe x509_certificate ( '/etc/pki/katello/certs/katello-default-ca.crt' ) do
184+ it { should be_certificate }
185+ it { should be_valid }
186+ it { should have_purpose 'SSL server CA' }
187+ its ( :issuer ) { should match_without_whitespace ( /C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{ fact ( 'fqdn' ) } / ) }
188+ its ( :subject ) { should match_without_whitespace ( /C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{ fact ( 'fqdn' ) } / ) }
189+ its ( :keylength ) { should be >= 4096 }
190+ end
191+ end
192+
193+ context 'with custom certificates' do
194+ before ( :context ) do
195+ manifest = <<~PUPPET
196+ class { 'certs':
197+ server_cert => '/server.crt',
198+ server_key => '/server.key',
199+ server_ca_cert => '/server-ca.crt',
200+ generate => true,
201+ deploy => false,
202+ }
203+
204+ class { 'certs::foreman_proxy_content':
205+ foreman_proxy_fqdn => 'foreman-proxy.example.com',
206+ certs_tar => '/root/foreman-proxy.example.com.tar.gz',
207+ }
208+ PUPPET
209+
210+ apply_manifest ( manifest , catch_failures : true )
211+
212+ on default , 'rm -rf /root/ssl-build'
213+ end
214+
215+ describe 'deploy certificates' do
216+ manifest = <<-PUPPET
217+ class { 'certs':
218+ tar_file => '/root/foreman-proxy.example.com.tar.gz',
219+ }
220+ PUPPET
221+ # tar extraction is not idempotent
222+ it { apply_manifest ( manifest , catch_failures : true ) }
223+ end
224+
225+ describe 'default and server ca certs match' do
226+ 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 ) }
227+ end
228+
229+ describe x509_certificate ( '/etc/pki/katello/certs/katello-default-ca.crt' ) do
230+ it { should be_certificate }
231+ it { should be_valid }
232+ it { should have_purpose 'SSL server CA' }
233+ its ( :issuer ) { should match_without_whitespace ( /C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{ fact ( 'fqdn' ) } / ) }
234+ its ( :subject ) { should match_without_whitespace ( /C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{ fact ( 'fqdn' ) } / ) }
235+ its ( :keylength ) { should be >= 4096 }
236+ end
237+
238+ describe x509_certificate ( '/etc/pki/katello/certs/katello-server-ca.crt' ) do
239+ it { should be_certificate }
240+ it { should be_valid }
241+ it { should have_purpose 'SSL server CA' }
242+ # These don't match since we only configure it with the intermediate
243+ # and not the actual root
244+ its ( :issuer ) { should match_without_whitespace ( /CN = Fake LE Root X1/ ) }
245+ its ( :subject ) { should match_without_whitespace ( /CN = Fake LE Intermediate X1/ ) }
246+ its ( :keylength ) { should be >= 2048 }
247+ end
248+ end
249+ end
148250end
0 commit comments