Skip to content

Commit

Permalink
Merge pull request #1357 from emahags/verifyServerCert
Browse files Browse the repository at this point in the history
Use valid parameter name
  • Loading branch information
igalic committed Mar 11, 2016
2 parents f786980 + 06498f2 commit 723eb0b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
14 changes: 11 additions & 3 deletions manifests/mod/authnz_ldap.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
class apache::mod::authnz_ldap (
$verifyServerCert = true,
$verify_server_cert = true,
$verifyServerCert = undef,
) {
include ::apache
include '::apache::mod::ldap'
::apache::mod { 'authnz_ldap': }

validate_bool($verifyServerCert)
if $verifyServerCert {
warning('Class[\'apache::mod::authnz_ldap\'] parameter verifyServerCert is deprecated in favor of verify_server_cert')
$_verify_server_cert = $verifyServerCert
} else {
$_verify_server_cert = $verify_server_cert
}

validate_bool($_verify_server_cert)

# Template uses:
# - $verifyServerCert
# - $_verify_server_cert
file { 'authnz_ldap.conf':
ensure => file,
path => "${::apache::mod_dir}/authnz_ldap.conf",
Expand Down
20 changes: 10 additions & 10 deletions spec/classes/mod/authnz_ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
it { is_expected.to contain_class("apache::mod::ldap") }
it { is_expected.to contain_apache__mod('authnz_ldap') }

context 'default verifyServerCert' do
context 'default verify_server_cert' do
it { is_expected.to contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert On$/) }
end

context 'verifyServerCert = false' do
let(:params) { { :verifyServerCert => false } }
context 'verify_server_cert = false' do
let(:params) { { :verify_server_cert => false } }
it { is_expected.to contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert Off$/) }
end

context 'verifyServerCert = wrong' do
let(:params) { { :verifyServerCert => 'wrong' } }
context 'verify_server_cert = wrong' do
let(:params) { { :verify_server_cert => 'wrong' } }
it 'should raise an error' do
expect { is_expected.to raise_error Puppet::Error }
end
Expand All @@ -56,17 +56,17 @@
it { is_expected.to contain_class("apache::mod::ldap") }
it { is_expected.to contain_apache__mod('authnz_ldap') }

context 'default verifyServerCert' do
context 'default verify_server_cert' do
it { is_expected.to contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert On$/) }
end

context 'verifyServerCert = false' do
let(:params) { { :verifyServerCert => false } }
context 'verify_server_cert = false' do
let(:params) { { :verify_server_cert => false } }
it { is_expected.to contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert Off$/) }
end

context 'verifyServerCert = wrong' do
let(:params) { { :verifyServerCert => 'wrong' } }
context 'verify_server_cert = wrong' do
let(:params) { { :verify_server_cert => 'wrong' } }
it 'should raise an error' do
expect { is_expected.to raise_error Puppet::Error }
end
Expand Down
2 changes: 1 addition & 1 deletion templates/mod/authnz_ldap.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if @verifyServerCert == true -%>
<% if @_verify_server_cert == true -%>
LDAPVerifyServerCert On
<% else -%>
LDAPVerifyServerCert Off
Expand Down

0 comments on commit 723eb0b

Please sign in to comment.