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 class to configure generating certificates #449

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
41 changes: 41 additions & 0 deletions manifests/generate.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Handles generating certificates
#
# === Parameters:
#
# $apache:: Generates certificates needed by Apache
#
# $foreman:: Generates certificates needed by Foreman
#
# $candlepin:: Generates certificates needed by Candlepin
#
# $foreman_proxy:: Generates certificates needed by Foreman Proxy
#
# $puppet:: Generates certificates needed by Puppet
#
class certs::generate (
Boolean $apache = false,
Boolean $foreman = false,
Boolean $candlepin = false,
Boolean $foreman_proxy = false,
Boolean $puppet = false,
) {
if $certs::generate::apache {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify all of these since the parameters are local

Suggested change
if $certs::generate::apache {
if $apache {

include certs::apache
}

if $certs::generate::foreman {
include certs::foreman
}

if $certs::generate::candlepin {
include certs::candlepin
}

if $certs::generate::foreman_proxy {
include certs::foreman_proxy
}

if $certs::generate::puppet {
include certs::puppet
}
}
75 changes: 75 additions & 0 deletions spec/classes/certs_generate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
require 'spec_helper'

describe 'certs::generate' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let :facts do
os_facts
end

describe 'with default parameters' do
it { should compile.with_all_deps }
end

describe 'with apache true' do
let :pre_condition do
"class {'certs::generate': apache => true,}"
end
Comment on lines +15 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the subject is the class itself, you can use params instead of a precondition

Suggested change
let :pre_condition do
"class {'certs::generate': apache => true,}"
end
let :params do
{ apache: true }
end


it { should compile.with_all_deps }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The should syntax is deprecated and we should (pun not intended) migrate to is_expected.to

Suggested change
it { should compile.with_all_deps }
it { is_expected.to compile.with_all_deps }


it do
is_expected.to contain_class('certs::apache')
end
end

describe 'with foreman true' do
let :pre_condition do
"class {'certs::generate': foreman => true,}"
end

it { should compile.with_all_deps }

it do
is_expected.to contain_class('certs::foreman')
end
end

describe 'with candlepin true' do
let :pre_condition do
"class {'certs::generate': candlepin => true,}"
end

it { should compile.with_all_deps }

it do
is_expected.to contain_class('certs::candlepin')
end
end

describe 'with foreman_proxy true' do
let :pre_condition do
"class {'certs::generate': foreman_proxy => true,}"
end

it { should compile.with_all_deps }

it do
is_expected.to contain_class('certs::foreman_proxy')
end
end

describe 'with puppet true' do
let :pre_condition do
"class {'certs::generate': puppet => true,}"
end

it { should compile.with_all_deps }

it do
is_expected.to contain_class('certs::puppet')
end
end
end
end
end