From 1f2c9a8e8ee72c99db57591fa76b9e14c057f82a Mon Sep 17 00:00:00 2001 From: Romain THERRAT Date: Mon, 23 Dec 2013 17:18:46 +0100 Subject: [PATCH 1/2] Fix filter with a specified source --- manifests/filter.pp | 5 ++++- spec/defines/fail2ban_filter_spec.rb | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/manifests/filter.pp b/manifests/filter.pp index 8c7bec8..376c220 100644 --- a/manifests/filter.pp +++ b/manifests/filter.pp @@ -92,7 +92,10 @@ define fail2ban::filter ( $manage_file_content = $filtertemplate ? { '' => undef, - default => template($filtertemplate), + default => $filtersource ? { + '' => template($filtertemplate), + default => undef, + } } file { "${real_filtername}.local": diff --git a/spec/defines/fail2ban_filter_spec.rb b/spec/defines/fail2ban_filter_spec.rb index 6eac9af..2b7b712 100644 --- a/spec/defines/fail2ban_filter_spec.rb +++ b/spec/defines/fail2ban_filter_spec.rb @@ -61,7 +61,7 @@ b = 2 not c " end - + it { should contain_file('sample2.local').with_path('/etc/fail2ban/filter.d/sample2.local').with_content(expected) } it { should contain_file('sample2.local').without_source } end @@ -75,6 +75,7 @@ not c end it { should contain_file('sample3.local').with_path('/etc/fail2ban/filter.d/sample3.local').with_source('puppet:///some/path/to/source') } + it { should contain_file('sample3.local').with_content(nil) } it { should contain_file('sample3.local').without_template } end end From 582b6a178862e730670b279100aaf889967a139e Mon Sep 17 00:00:00 2001 From: Romain THERRAT Date: Mon, 23 Dec 2013 18:41:15 +0100 Subject: [PATCH 2/2] Fix test with 1.0 rspec-puppet version --- spec/classes/fail2ban_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/classes/fail2ban_spec.rb b/spec/classes/fail2ban_spec.rb index fcbb604..a981938 100644 --- a/spec/classes/fail2ban_spec.rb +++ b/spec/classes/fail2ban_spec.rb @@ -97,12 +97,10 @@ enabled = true/) } describe 'Test customizations - template' do let(:params) { {:template => "fail2ban/spec.erb" , :options => { 'opt_a' => 'value_a' } } } it 'should generate a valid template' do - content = catalogue.resource('file', 'fail2ban.local').send(:parameters)[:content] - content.should match "fqdn: rspec.example42.com" + should contain_file('fail2ban.local').with_content(/fqdn: rspec.example42.com/) end it 'should generate a template that uses custom options' do - content = catalogue.resource('file', 'fail2ban.local').send(:parameters)[:content] - content.should match "value_a" + should contain_file('fail2ban.local').with_content(/value_a/) end end @@ -136,8 +134,7 @@ enabled = true/) } } end it 'should not automatically restart the service, when service_autorestart => false' do - content = catalogue.resource('file', 'fail2ban.local').send(:parameters)[:notify] - content.should be_nil + should contain_file('fail2ban.local').with_notify(nil) end end