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