-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #20021 - Optionally generate CA public cert with other CAs certs
- Loading branch information
Showing
9 changed files
with
208 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'certs with default params' do | ||
context 'with default params' do | ||
let(:pp) do | ||
<<-EOS | ||
$repo = 'latest' | ||
$dist = 'el7' | ||
package { 'epel-release': | ||
ensure => installed, | ||
} | ||
yumrepo { 'katello': | ||
descr => 'Katello latest', | ||
baseurl => "https://fedorapeople.org/groups/katello/releases/yum/${repo}/katello/${dist}/\\$basearch/", | ||
gpgkey => 'https://raw.githubusercontent.com/Katello/katello-packaging/master/repos/RPM-GPG-KEY-katello-2015', | ||
gpgcheck => '0', | ||
enabled => '1', | ||
} | ||
class { '::certs':} | ||
EOS | ||
end | ||
|
||
it_behaves_like 'a idempotent resource' | ||
|
||
describe package('katello-certs-tools') do | ||
it { is_expected.to be_installed } | ||
end | ||
|
||
describe x509_certificate('/etc/pki/katello-certs-tools/certs/katello-default-ca.crt') do | ||
it { should be_certificate } | ||
it { should be_valid } | ||
it { should have_purpose 'SSL server CA' } | ||
its(:issuer) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
its(:subject) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
end | ||
|
||
describe x509_certificate('/etc/pki/katello-certs-tools/certs/katello-server-ca.crt') do | ||
it { should be_certificate } | ||
it { should be_valid } | ||
it { should have_purpose 'SSL server CA' } | ||
its(:issuer) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
its(:subject) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
end | ||
end | ||
|
||
context 'with custom server certs' do | ||
before(:all) do | ||
beforepp = <<-EOS | ||
# Mark server-ca for update | ||
file { '/root/ssl-build/katello-server-ca.update': | ||
ensure => file, | ||
} | ||
Exec { | ||
path => ['/usr/bin'], | ||
} | ||
file { '/root/custom_cert': | ||
ensure => directory, | ||
} ~> | ||
exec { 'Create CA key': | ||
cwd => "/root/custom_cert", | ||
command => "openssl genrsa -out ca.key 2048", | ||
creates => "/root/custom_cert/ca.key", | ||
} ~> | ||
exec { 'Create CA certficates': | ||
cwd => "/root/custom_cert", | ||
command => 'openssl req -new -x509 -key ca.key -out ca.crt -nodes -x509 -subj "/C=US/ST=North Carolina/L=Raleigh/O=CustomKatelloCA/CN=www.custom-katello-ca.example.com"', | ||
creates => "/root/custom_cert/ca.crt", | ||
} ~> | ||
exec { 'Create custom key': | ||
cwd => "/root/custom_cert", | ||
command => "openssl genrsa -out katello.example.com.key 2048", | ||
creates => "/root/custom_cert/katello.example.com.key", | ||
} ~> | ||
exec { 'Create CSR': | ||
cwd => "/root/custom_cert", | ||
command => 'openssl req -new -key katello.example.com.key -out katello.example.com.csr -nodes -subj "/C=US/ST=North Carolina/L=Raleigh/O=Katello/CN=www.katello.example.com"', | ||
creates => "/root/custom_cert/katello.example.com.csr", | ||
} ~> | ||
exec { 'Sign CSR': | ||
cwd => "/root/custom_cert", | ||
command => 'openssl x509 -req -in katello.example.com.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out katello.example.com.crt', | ||
creates => "/root/custom_cert/katello.example.com.crt", | ||
} | ||
EOS | ||
apply_manifest(beforepp) | ||
end | ||
|
||
let(:pp) do | ||
<<-EOS | ||
$repo = 'latest' | ||
$dist = 'el7' | ||
package { 'epel-release': | ||
ensure => installed, | ||
} | ||
yumrepo { 'katello': | ||
descr => 'Katello latest', | ||
baseurl => "https://fedorapeople.org/groups/katello/releases/yum/${repo}/katello/${dist}/\\$basearch/", | ||
gpgkey => 'https://raw.githubusercontent.com/Katello/katello-packaging/master/repos/RPM-GPG-KEY-katello-2015', | ||
gpgcheck => '0', | ||
enabled => '1', | ||
} | ||
class { '::certs': | ||
server_cert => "/root/custom_cert/katello.example.com.crt", | ||
server_ca_cert => "/root/custom_cert/ca.crt", | ||
server_key => "/root/custom_cert/katello.example.com.key", | ||
server_cert_req => "/root/custom_cert/katello.example.com.csr", | ||
} | ||
EOS | ||
end | ||
|
||
it_behaves_like 'a idempotent resource' | ||
|
||
describe package('katello-certs-tools') do | ||
it { is_expected.to be_installed } | ||
end | ||
|
||
describe x509_certificate('/etc/pki/katello-certs-tools/certs/katello-default-ca.crt') do | ||
it { should be_certificate } | ||
it { should be_valid } | ||
it { should have_purpose 'SSL server CA' } | ||
its(:issuer) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
its(:subject) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" } | ||
end | ||
|
||
|
||
describe x509_certificate('/etc/pki/katello-certs-tools/certs/katello-server-ca.crt') do | ||
it { should be_certificate } | ||
it { should be_valid } | ||
it { should have_purpose 'SSL server CA' } | ||
its(:issuer) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=CustomKatelloCA/CN=www.custom-katello-ca.example.com" } | ||
its(:subject) { should eq "/C=US/ST=North Carolina/L=Raleigh/O=CustomKatelloCA/CN=www.custom-katello-ca.example.com" } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe 'certs::ca' do | ||
let :facts do | ||
on_supported_os['redhat-7-x86_64'] | ||
end | ||
|
||
context 'without params ' do | ||
let :pre_condition do | ||
"class {'certs':}" | ||
end | ||
|
||
describe 'with ca set' do | ||
it { should contain_ca('katello-default-ca').with({ :other_certs => [] }) } | ||
end | ||
end | ||
|
||
context 'with params' do | ||
let :pre_condition do | ||
"class {'certs': other_default_ca_certs => ['/tmp/other-default-cert.crt', '/tmp/another-default-cert.crt']}" | ||
end | ||
|
||
describe 'with ca set' do | ||
it { should contain_ca('katello-default-ca').with({ :other_certs => ['/tmp/other-default-cert.crt', '/tmp/another-default-cert.crt'] }) } | ||
end | ||
end | ||
end |