Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an acceptance test for candlepin #145

Merged
merged 2 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions manifests/ssltools/nssdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
$nss_db_password_file = "${nss_db_dir}/nss_db_password-file"
$nssdb_files = ["${nss_db_dir}/cert8.db", "${nss_db_dir}/key3.db", "${nss_db_dir}/secmod.db"]

ensure_packages(['openssl', 'nss-tools'])

file { $nss_db_dir:
ensure => directory,
owner => 'root',
Expand All @@ -20,6 +22,7 @@
umask => '0027',
group => $group,
creates => $nss_db_password_file,
require => Package['openssl'],
} ->
file { $nss_db_password_file:
ensure => file,
Expand All @@ -33,6 +36,7 @@
umask => '0027',
group => $group,
creates => $nssdb_files,
require => Package['nss-tools'],
} ->
file { $nssdb_files:
owner => 'root',
Expand Down
112 changes: 112 additions & 0 deletions spec/acceptance/candlepin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
require 'spec_helper_acceptance'

describe 'certs' do
before(:all) do
install_repo = <<-EOS
yumrepo { 'katello':
descr => 'Katello latest',
baseurl => 'https://fedorapeople.org/groups/katello/releases/yum/latest/katello/el7/$basearch/',
gpgcheck => false,
enabled => true,
}
EOS

apply_manifest(install_repo)
end

context 'with default params' do
let(:pp) do
<<-EOS
user { 'tomcat':
ensure => present,
}

group { 'qpidd':
ensure => present,
}

['/usr/share/tomcat/conf', '/etc/candlepin/certs/amqp'].each |$dir| {
exec { "mkdir -p ${dir}":
creates => $dir,
path => ['/bin', '/usr/bin'],
}
}

package { 'java-1.8.0-openjdk-headless':
ensure => installed,
}

include ::certs::candlepin
EOS
end

keystore_password_file = '/etc/pki/katello/keystore_password-file'

it_behaves_like 'a idempotent resource'

describe x509_certificate('/etc/pki/katello/certs/katello-tomcat.crt') do
it { should be_certificate }
it { should be_valid }
it { should have_purpose 'server' }
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/O=Katello/OU=SomeOrgUnit/CN=#{fact('fqdn')}" }
its(:keylength) { should be >= 2048 }
end

describe x509_private_key('/etc/pki/katello/private/katello-tomcat.key') do
it { should_not be_encrypted }
it { should be_valid }
it { should have_matching_certificate('/etc/pki/katello/certs/katello-tomcat.crt') }
end

describe x509_certificate('/etc/pki/katello/certs/java-client.crt') do
it { should be_certificate }
it { should be_valid }
it { should have_purpose 'server' }
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/O=candlepin/OU=SomeOrgUnit/CN=#{fact('fqdn')}" }
its(:keylength) { should be >= 2048 }
end

describe x509_private_key('/etc/pki/katello/private/java-client.key') do
it { should_not be_encrypted }
it { should be_valid }
it { should have_matching_certificate('/etc/pki/katello/certs/java-client.crt') }
end

describe file(keystore_password_file) do
it { should be_file }
it { should be_mode 440 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe file('/etc/pki/katello/keystore') do
it { should be_file }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

describe command("keytool -list -keystore /etc/pki/katello/keystore -storepass $(cat #{keystore_password_file})") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/^Keystore type: JKS$/) }
its(:stdout) { should match(/^Your keystore contains 1 entry$/) }
its(:stdout) { should match(/^tomcat, .+, PrivateKeyEntry, $/) }
end

describe command("keytool -list -keystore /etc/candlepin/certs/amqp/candlepin.truststore -storepass $(cat #{keystore_password_file})") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/^Keystore type: JKS$/) }
its(:stdout) { should match(/^Your keystore contains 1 entry$/) }
its(:stdout) { should match(/^katello-default-ca, .+, trustedCertEntry, $/) }
end

describe command("keytool -list -keystore /etc/candlepin/certs/amqp/candlepin.jks -storepass $(cat #{keystore_password_file})") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/^Keystore type: JKS$/) }
its(:stdout) { should match(/^Your keystore contains 1 entry$/) }
its(:stdout) { should match(/^amqp-client, .+, PrivateKeyEntry, $/) }
end
end
end