Commit b9fe74da authored by Ben Hocker's avatar Ben Hocker
Browse files

Resolves issue #55

- Adding tests for ldap.pp
- Only install postfix-ldap package on Debian based
parent 89055a99
......@@ -14,8 +14,10 @@
# include postfix::ldap
#
class postfix::ldap {
package {'postfix-ldap': }
case $::osfamily {
'debian': { package {'postfix-ldap': } }
default: {}
}
if ! $postfix::ldap_base {
fail 'Missing $postfix::ldap_base !'
......@@ -36,6 +38,6 @@ class postfix::ldap {
owner => 'root',
group => 'postfix',
content => template('postfix/postfix-ldap-aliases.cf.erb'),
require => Package['postfix-ldap'],
#TODO: Figure out if should have require package here
}
}
......@@ -37,6 +37,7 @@ describe 'postfix' do
context 'when on RedHat' do
let (:facts) { {
:lsbdistcodename => 'Maipo',
:fqdn => 'fqdn.example.com',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '7',
......@@ -162,8 +163,53 @@ describe 'postfix' do
end
end
context 'when enabling ldap' do
it 'should do stuff' do
skip 'need to write this still'
context 'when on Debian' do
let (:params) { {
:ldap => true,
:ldap_base => 'dc=example,dc=com',
:ldap_host => 'host.example.com',
} }
let (:facts) { {
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:fqdn => 'fqdn.example.com',
:lsbdistcodename => 'wheezy',
} }
it { should contain_package('postfix-ldap') }
it { should contain_file('/etc/postfix/ldap-aliases.cf').with(
:owner => 'root',
:group => 'postfix' ).with_content(/search_base = /)
}
end
context 'when on RedHat' do
let (:params) { {
:ldap => true,
:ldap_base => 'dc=example,dc=com',
:ldap_host => 'host.example.com',
} }
let (:facts) { {
:operatingsystem => 'RedHat',
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:lsbdistcodename => 'Maipo',
:fqdn => 'fqdn.example.com',
} }
it do
expect {
should_not contain_package('postfix-ldap')
}
end
it { should contain_file('/etc/postfix/ldap-aliases.cf').with(
:owner => 'root',
:group => 'postfix').with_content(/search_base = /)
}
end
end
context 'when a custom mail_user is specified' do
......@@ -195,7 +241,7 @@ describe 'postfix' do
:master_smtp => "smtp inet n - - - - smtpd
-o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject",
} }
it 'should update master.cf with the specified flags to smtp' do
it 'should update master.cf with the specified flags to smtp' do
is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content(
/smtp inet n - - - - smtpd/).with_content(
/^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment