Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,10 @@ ...@@ -14,8 +14,10 @@
# include postfix::ldap # include postfix::ldap
# #
class postfix::ldap { class postfix::ldap {
case $::osfamily {
package {'postfix-ldap': } 'debian': { package {'postfix-ldap': } }
default: {}
}
if ! $postfix::ldap_base { if ! $postfix::ldap_base {
fail 'Missing $postfix::ldap_base !' fail 'Missing $postfix::ldap_base !'
...@@ -36,6 +38,6 @@ class postfix::ldap { ...@@ -36,6 +38,6 @@ class postfix::ldap {
owner => 'root', owner => 'root',
group => 'postfix', group => 'postfix',
content => template('postfix/postfix-ldap-aliases.cf.erb'), 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 ...@@ -37,6 +37,7 @@ describe 'postfix' do
context 'when on RedHat' do context 'when on RedHat' do
let (:facts) { { let (:facts) { {
:lsbdistcodename => 'Maipo',
:fqdn => 'fqdn.example.com', :fqdn => 'fqdn.example.com',
:operatingsystem => 'RedHat', :operatingsystem => 'RedHat',
:operatingsystemmajrelease => '7', :operatingsystemmajrelease => '7',
...@@ -162,8 +163,53 @@ describe 'postfix' do ...@@ -162,8 +163,53 @@ describe 'postfix' do
end end
end end
context 'when enabling ldap' do context 'when enabling ldap' do
it 'should do stuff' do context 'when on Debian' do
skip 'need to write this still' 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
end end
context 'when a custom mail_user is specified' do context 'when a custom mail_user is specified' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment