From 71e189ec6d7d9fe7611ac82f62563d7551b585e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Tue, 30 Apr 2013 06:28:48 -0300 Subject: [PATCH] Add specs --- spec/classes/fail2ban_spec.rb | 4 ++-- spec/defines/fail2ban_jail_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spec/defines/fail2ban_jail_spec.rb diff --git a/spec/classes/fail2ban_spec.rb b/spec/classes/fail2ban_spec.rb index a830664..b67ab3a 100644 --- a/spec/classes/fail2ban_spec.rb +++ b/spec/classes/fail2ban_spec.rb @@ -28,8 +28,8 @@ describe 'fail2ban' do let(:facts) { {:operatingsystem => 'Debian' } } let(:params) { {:jails_config => 'file', :jails_template => 'fail2ban/jail.local.erb', :jails => 'ssh' } } it { should contain_file('jail.local').without_source } - it { should contain_file('jail.local').with_content(/"*ssh-iptables] -enabled = true*/) } + it { should contain_file('jail.local').with_content(/ssh-iptables\] +enabled = true/) } end describe 'Test jails managed throuh file - custom template' do diff --git a/spec/defines/fail2ban_jail_spec.rb b/spec/defines/fail2ban_jail_spec.rb new file mode 100644 index 0000000..406d5a2 --- /dev/null +++ b/spec/defines/fail2ban_jail_spec.rb @@ -0,0 +1,20 @@ +require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}" + +describe 'fail2ban::jail' do + + let(:title) { 'fail2ban::jail' } + let(:node) { 'rspec.example42.com' } + let(:facts) { { :ipaddress => '10.42.42.42', :jails_file => '/etc/fail2ban/jail.local', :concat_basedir => '/var/lib/puppet/concat'} } + + describe 'Test basic jail.local is created' do + let(:params) { { :name => 'sample1', + :port => '42', + :logpath => '/path/to/somelog', + :enable => true, } } + + it { should include_class('concat::setup') } +# it { should contain_concat__fragment('fail2ban_jail_sample1').with_target('/etc/fail2ban/jail.local').with_content(/*port = 42 +#logpath = \/path\/to\/somelog*/) } + it { should contain_concat__fragment('fail2ban_jail_sample1').with_target('/etc/fail2ban/jail.local').with_content("##################\n[fail2ban::jail]\nenabled = true\nfilter = fail2ban::jail\nport = 42\nlogpath = /path/to/somelog\n\n") } + end +end