Skip to content

Commit

Permalink
do not directly manage openssl package
Browse files Browse the repository at this point in the history
Add require_openssl param to nssdb class to enable/disable requiring the
`openssl` class.
  • Loading branch information
Joshua Hoblitt committed Feb 10, 2014
1 parent 5f4ea61 commit 258a04e
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
fixtures:
repositories:
'stdlib':
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '4.0.0'
'openssl': 'https://github.com/camptocamp/puppet-openssl.git'
symlinks:
nssdb: "#{source_dir}"
1 change: 1 addition & 0 deletions Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ description 'This module manages NSS databases.'
project_page 'https://github.com/rcritten/puppet-nssdb'

dependency 'puppetlabs/stdlib', '>= 4.0.0'
dependency 'camptocamp/openssl', '>= 0.1.0'
14 changes: 12 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# utility class
class nssdb {
include nssdb::params
class nssdb (
$require_openssl = true,
) {
validate_bool($require_openssl)

include nssdb::params
ensure_packages($::nssdb::params::package_name)

if $require_openssl {
include openssl

Class['openssl'] ->
Anchor['nssdb::begin']
}

anchor{ 'nssdb::begin': } ->
Package[$::nssdb::params::package_name] ->
anchor{ 'nssdb::end': }
Expand Down
9 changes: 8 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# this class should be considered private
class nssdb::params {
$package_name = ['nss-tools', 'openssl']
case $::osfamily {
'redhat': {
$package_name = ['nss-tools']
}
default: {
fail("Module ${module_name} is not supported on ${::operatingsystem}")
}
}
}
51 changes: 49 additions & 2 deletions spec/classes/nssdb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
require 'spec_helper'

describe 'nssdb', :type => :class do
it { should contain_package('nss-tools') }
it { should contain_package('openssl') }
describe 'on osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
# rspec-puppet relationship matchers seem to be buggy in 1.0.1
# it { should contain_class('openssl').that_comes_before('Class[nssdb]') }
it { should contain_class('openssl') }
it { should contain_package('nss-tools') }
end # default params

context 'require_openssl =>' do
context 'true' do
let(:params) {{ :require_openssl => true }}

it { should contain_class('openssl') }
it { should contain_package('nss-tools') }
end

context 'false' do
let(:params) {{ :require_openssl => false }}

it { should_not contain_class('openssl') }
it { should contain_package('nss-tools') }
end

context 'foo' do
let(:params) {{ :require_openssl => 'foo' }}

it 'should fail' do
expect { should contain_class('nssdb') }.
to raise_error(/not a boolean./)
end
end
end # default params
end # on osfamily RedHat

describe 'unsupported osfamily' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
}
end

it 'should fail' do
expect { should compile }.to raise_error(/not supported on Debian/)
end
end # unsupported osfamily

end
2 changes: 2 additions & 0 deletions spec/defines/nssdb_add_cert_and_key_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe 'nssdb::add_cert_and_key', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
let(:title) { 'Server-Cert' }
let(:params) do
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/nssdb_add_cert_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe 'nssdb::add_cert', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
let(:title) { 'GlobalSign Root CA' }
let(:params) do
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/nssdb_create_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe 'nssdb::create', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}

context 'default params' do
let(:title) { '/obsolete' }
let(:params) do
Expand Down

0 comments on commit 258a04e

Please sign in to comment.