Skip to content

Commit

Permalink
change nssdb::add_cert type to treat it's title as the default nickname
Browse files Browse the repository at this point in the history
Previously, the title was being used as the default cert param value.
  • Loading branch information
Joshua Hoblitt committed Feb 10, 2014
1 parent a733330 commit e22a87a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 28 deletions.
14 changes: 7 additions & 7 deletions manifests/add_cert.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Loads a certificate into an NSS database.
#
# Parameters:
# $nickname - required - the nickname for the NSS certificate
# $cert - optional - path to certificate in PEM format
# $certdir - required - defaults to $title
# $trustargs - optional - defaults to 'CT,,'
# $certdir - required - defaults to $title
# $cert - required - path to certificate in PEM format
# $nickname - optional - the nickname for the NSS certificate
# $trustargs - optional - defaults to 'CT,,'
#
# Actions:
# loads certificate and key into the NSS database.
#
# Requires:
# $nickname
# $certdir
# $cert
#
# Sample Usage:
Expand All @@ -21,9 +21,9 @@
# }
#
define nssdb::add_cert(
$nickname,
$cert = $title,
$certdir,
$cert,
$nickname = $title,
$trustargs = 'CT,,'
) {
include nssdb
Expand Down
70 changes: 49 additions & 21 deletions spec/defines/nssdb_add_cert_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
require 'spec_helper'

describe 'nssdb::add_cert', :type => :define do
let(:title) { '/dne' }
let(:params) do
{
:nickname => 'GlobalSign Root CA',
:cert => '/tmp/server.crt',
:certdir => '/dne',
}
end
context 'default params' do
let(:title) { 'GlobalSign Root CA' }
let(:params) do
{
:certdir => '/dne',
:cert => '/tmp/server.crt',
}
end

context 'add_cert' do
it do
should contain_exec('add_cert_GlobalSign Root CA').with(
:path => ['/usr/bin'],
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'CT,,' -a -i /tmp/server.crt",
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
:logoutput => true,
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
]
)
end
end
end # default params

context 'all params' do
let(:title) { 'foo' }
let(:params) do
{
:certdir => '/dne',
:cert => '/tmp/server.crt',
:nickname => 'GlobalSign Root CA',
:trustargs => 'u,u,u',
}
end

context 'add_cert' do
it do
should contain_exec('add_cert_/dne').with(
:path => ['/usr/bin'],
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'CT,,' -a -i /tmp/server.crt",
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
:logoutput => true,
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
]
)
context 'add_cert' do
it do
should contain_exec('add_cert_foo').with(
:path => ['/usr/bin'],
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'u,u,u' -a -i /tmp/server.crt",
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
:logoutput => true,
:require => [
'Nssdb::Create[/dne]',
'Class[Nssdb]'
]
)
end
end
end
end # all params
end

0 comments on commit e22a87a

Please sign in to comment.