diff options
author | Micah <micah@leap.se> | 2016-05-24 10:19:39 -0400 |
---|---|---|
committer | Micah <micah@leap.se> | 2016-05-24 10:19:39 -0400 |
commit | 1419079315b69a271b5019bcf5e7c4df39633677 (patch) | |
tree | 69305f1afb350e2d3956b0c8767c3a70cde7c7e6 /spec/classes/rsyslog_server_spec.rb |
Squashed 'puppet/modules/rsyslog/' content from commit b8ef11c
git-subtree-dir: puppet/modules/rsyslog
git-subtree-split: b8ef11c23949d12732ad5cdaebb3023ff39a297a
Diffstat (limited to 'spec/classes/rsyslog_server_spec.rb')
-rw-r--r-- | spec/classes/rsyslog_server_spec.rb | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/spec/classes/rsyslog_server_spec.rb b/spec/classes/rsyslog_server_spec.rb new file mode 100644 index 00000000..8f57656b --- /dev/null +++ b/spec/classes/rsyslog_server_spec.rb @@ -0,0 +1,182 @@ +require 'spec_helper' + +describe 'rsyslog::server', :type => :class do + + context "Rsyslog version >= 8" do + let(:default_facts) do + { + :rsyslog_version => '8.1.2' + } + end + + ['RedHat', 'Debian'].each do |osfamily| + context "osfamily = #{osfamily}" do + let :facts do + default_facts.merge!({ + :osfamily => osfamily, + :operatingsystem => osfamily, + :operatingsystemmajrelease => 6, + }) + end + + context "default usage (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-basic' } + + it 'should compile' do + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "enable_onefile (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'enable_onefile' => 'true'} } + + it 'should compile' do + should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "hostname_template (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } + + it 'should compile' do + should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) + end + end + + end + end + + + context "osfamily = FreeBSD" do + let :facts do + default_facts.merge!({ + :osfamily => 'freebsd', + }) + end + + context "default usage (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-basic' } + + it 'should compile' do + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "enable_onefile (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'enable_onefile' => 'true'} } + + it 'should compile' do + should_not contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "hostname_template (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } + + it 'should compile' do + should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/messages/) + end + end + + end + end + + context "Rsyslog version =< 8" do + let(:default_facts) do + { + :rsyslog_version => '7.1.2' + } + end + + ['RedHat', 'Debian'].each do |osfamily| + context "osfamily = #{osfamily}" do + let :facts do + default_facts.merge!({ + :osfamily => osfamily, + :operatingsystem => osfamily, + :operatingsystemmajrelease => 6, + }) + end + + context "default usage (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-basic' } + + it 'should compile' do + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "enable_onefile (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'enable_onefile' => 'true'} } + + it 'should compile' do + should_not contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "hostname_template (osfamily = #{osfamily})" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } + + it 'should compile' do + should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/auth.log/) + should contain_file('/etc/rsyslog.d/server.conf').with_content(/%hostname%\/messages/) + end + end + + end + end + + + context "osfamily = FreeBSD" do + let :facts do + default_facts.merge!({ + :osfamily => 'freebsd', + }) + end + + context "default usage (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-basic' } + + it 'should compile' do + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "enable_onefile (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'enable_onefile' => 'true'} } + + it 'should compile' do + should_not contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/\(\[A-Za-z-\]\*\)--end%\/messages/) + end + end + + context "hostname_template (osfamily = FreeBSD)" do + let(:title) { 'rsyslog-server-onefile' } + let(:params) { {'custom_config' => 'rsyslog/server-hostname.conf.erb'} } + + it 'should compile' do + should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/auth.log/) + should contain_file('/etc/syslog.d/server.conf').with_content(/%hostname%\/messages/) + end + end + + end + end +end # describe 'rsyslog::server' |