Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit e22a87a

Browse files
author
Joshua Hoblitt
committed
change nssdb::add_cert type to treat it's title as the default nickname
Previously, the title was being used as the default cert param value.
1 parent a733330 commit e22a87a

File tree

2 files changed

+56
-28
lines changed

2 files changed

+56
-28
lines changed

manifests/add_cert.pp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Loads a certificate into an NSS database.
22
#
33
# Parameters:
4-
# $nickname - required - the nickname for the NSS certificate
5-
# $cert - optional - path to certificate in PEM format
6-
# $certdir - required - defaults to $title
7-
# $trustargs - optional - defaults to 'CT,,'
4+
# $certdir - required - defaults to $title
5+
# $cert - required - path to certificate in PEM format
6+
# $nickname - optional - the nickname for the NSS certificate
7+
# $trustargs - optional - defaults to 'CT,,'
88
#
99
# Actions:
1010
# loads certificate and key into the NSS database.
1111
#
1212
# Requires:
13-
# $nickname
13+
# $certdir
1414
# $cert
1515
#
1616
# Sample Usage:
@@ -21,9 +21,9 @@
2121
# }
2222
#
2323
define nssdb::add_cert(
24-
$nickname,
25-
$cert = $title,
2624
$certdir,
25+
$cert,
26+
$nickname = $title,
2727
$trustargs = 'CT,,'
2828
) {
2929
include nssdb

spec/defines/nssdb_add_cert_spec.rb

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,55 @@
11
require 'spec_helper'
22

33
describe 'nssdb::add_cert', :type => :define do
4-
let(:title) { '/dne' }
5-
let(:params) do
6-
{
7-
:nickname => 'GlobalSign Root CA',
8-
:cert => '/tmp/server.crt',
9-
:certdir => '/dne',
10-
}
11-
end
4+
context 'default params' do
5+
let(:title) { 'GlobalSign Root CA' }
6+
let(:params) do
7+
{
8+
:certdir => '/dne',
9+
:cert => '/tmp/server.crt',
10+
}
11+
end
12+
13+
context 'add_cert' do
14+
it do
15+
should contain_exec('add_cert_GlobalSign Root CA').with(
16+
:path => ['/usr/bin'],
17+
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'CT,,' -a -i /tmp/server.crt",
18+
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
19+
:logoutput => true,
20+
:require => [
21+
'Nssdb::Create[/dne]',
22+
'Class[Nssdb]'
23+
]
24+
)
25+
end
26+
end
27+
end # default params
28+
29+
context 'all params' do
30+
let(:title) { 'foo' }
31+
let(:params) do
32+
{
33+
:certdir => '/dne',
34+
:cert => '/tmp/server.crt',
35+
:nickname => 'GlobalSign Root CA',
36+
:trustargs => 'u,u,u',
37+
}
38+
end
1239

13-
context 'add_cert' do
14-
it do
15-
should contain_exec('add_cert_/dne').with(
16-
:path => ['/usr/bin'],
17-
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'CT,,' -a -i /tmp/server.crt",
18-
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
19-
:logoutput => true,
20-
:require => [
21-
'Nssdb::Create[/dne]',
22-
'Class[Nssdb]'
23-
]
24-
)
40+
context 'add_cert' do
41+
it do
42+
should contain_exec('add_cert_foo').with(
43+
:path => ['/usr/bin'],
44+
:command => "certutil -d /dne -A -n 'GlobalSign Root CA' -t 'u,u,u' -a -i /tmp/server.crt",
45+
:unless => "certutil -d /dne -L -n 'GlobalSign Root CA'",
46+
:logoutput => true,
47+
:require => [
48+
'Nssdb::Create[/dne]',
49+
'Class[Nssdb]'
50+
]
51+
)
52+
end
2553
end
26-
end
54+
end # all params
2755
end

0 commit comments

Comments
 (0)