-
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
196 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,8 @@ | |
|
||
instance_eval(&Certs::CERT_COMMON_PARAMS) | ||
|
||
newparam(:other_certs) do | ||
defaultto [] | ||
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
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,144 @@ | ||
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 { 'candlepin': | ||
descr => 'Candlepin: an open source entitlement management system.', | ||
baseurl => "https://fedorapeople.org/groups/katello/releases/yum/${repo}/candlepin/${dist}/\\$basearch/", | ||
gpgkey => 'https://raw.githubusercontent.com/Katello/katello-packaging/master/repos/RPM-GPG-KEY-katello-2015', | ||
gpgcheck => '0', | ||
enabled => '1', | ||
} | ||
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 file("/etc/pki/katello-certs-tools/certs/katello-default-ca.crt") do | ||
it { should be_file } | ||
it { expect(shell("/usr/bin/openssl x509 -in /etc/pki/katello-certs-tools/certs/katello-default-ca.crt -noout -subject").stdout).to match(fact('fqdn')) } | ||
end | ||
|
||
describe file("/etc/pki/katello-certs-tools/certs/katello-server-ca.crt") do | ||
it { should be_file } | ||
it { expect(shell("/usr/bin/openssl x509 -in /etc/pki/katello-certs-tools/certs/katello-server-ca.crt -noout -subject").stdout).to match(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, | ||
} | ||
file { '/root/custom_cert': | ||
ensure => directory, | ||
} ~> | ||
exec { 'Create CA key': | ||
cwd => "/root/custom_cert", | ||
path => ["/usr/bin"], | ||
command => "openssl genrsa -out ca.key 2048", | ||
creates => "/root/custom_cert/ca.key", | ||
} ~> | ||
exec { 'Create CA certficates': | ||
cwd => "/root/custom_cert", | ||
path => ["/usr/bin"], | ||
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", | ||
path => ["/usr/bin"], | ||
command => "openssl genrsa -out katello.example.com.key 2048", | ||
creates => "/root/custom_cert/katello.example.com.key", | ||
} ~> | ||
exec { 'Create CSR': | ||
cwd => "/root/custom_cert", | ||
path => ["/usr/bin"], | ||
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", | ||
path => ["/usr/bin"], | ||
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 { 'candlepin': | ||
descr => 'Candlepin: an open source entitlement management system.', | ||
baseurl => "https://fedorapeople.org/groups/katello/releases/yum/${repo}/candlepin/${dist}/\\$basearch/", | ||
gpgkey => 'https://raw.githubusercontent.com/Katello/katello-packaging/master/repos/RPM-GPG-KEY-katello-2015', | ||
gpgcheck => '0', | ||
enabled => '1', | ||
} | ||
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 file("/etc/pki/katello-certs-tools/certs/katello-default-ca.crt") do | ||
it { should be_file } | ||
it { expect(shell("/usr/bin/openssl x509 -in /etc/pki/katello-certs-tools/certs/katello-default-ca.crt -noout -subject").stdout).to match(fact('fqdn')) } | ||
end | ||
|
||
describe file("/etc/pki/katello-certs-tools/certs/katello-server-ca.crt") do | ||
it { should be_file } | ||
it { expect(shell("/usr/bin/openssl x509 -in /etc/pki/katello-certs-tools/certs/katello-server-ca.crt -noout -subject").stdout).to match('CustomKatelloCA') } | ||
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 |