[icinga-checkins] icinga.org: chef-icinga2/master: Add chefspec for server_apache.rb recipe
git at icinga.org
git at icinga.org
Sat Jul 16 19:49:36 CEST 2016
Module: chef-icinga2
Branch: master
Commit: 865c4f067c079e0324a0e29074eebb578f0c0e82
URL: https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=865c4f067c079e0324a0e29074eebb578f0c0e82
Author: Thomas Peitz <thomas.peitz at invision.de>
Date: Thu Jun 30 16:37:58 2016 +0200
Add chefspec for server_apache.rb recipe
---
spec/unit/recipes/server_apache.rb | 86 ++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/spec/unit/recipes/server_apache.rb b/spec/unit/recipes/server_apache.rb
new file mode 100644
index 0000000..5523ae2
--- /dev/null
+++ b/spec/unit/recipes/server_apache.rb
@@ -0,0 +1,86 @@
+require 'spec_helper'
+
+describe 'icinga2::server_apache' do
+ before do
+ stub_command('/usr/sbin/httpd -t').and_return(true)
+ stub_command('/usr/sbin/apache2 -t').and_return(true)
+ stub_command('which php').and_return(true)
+ end
+
+ context 'rhel' do
+ let(:chef_run) do
+ ChefSpec::SoloRunner.new(platform: 'centos', version: '6.4') do |node|
+ node.automatic['platform_family'] = 'rhel'
+ node.set['icinga2']['classic_ui']['enable'] = true
+ node.set['icinga2']['web2']['enable'] = true
+ node.set['icinga2']['ignore_version'] = true
+ end.converge(described_recipe)
+ end
+
+ it 'creates an icinga2-classicui config file for httpd' do
+ expect(chef_run).to create_template('/etc/httpd/conf-available/icinga2-classic-ui.conf').with(
+ source: 'apache.vhost.icinga2_classic_ui.conf.rhel.erb',
+ owner: 'apache',
+ group: 'apache'
+ )
+ end
+
+ it 'creates an icinga2-web2 config file for httpd' do
+ expect(chef_run).to create_template('/etc/httpd/conf-available/icinga2-web2.conf').with(
+ source: 'apache.vhost.icinga2_web2.erb',
+ owner: 'apache',
+ group: 'apache'
+ )
+ end
+
+ it 'defines an icinga group' do
+ group = chef_run.group('icinga')
+ expect(group).to do_nothing
+ end
+
+ it 'modifies a manage_members_icinga group' do
+ group = chef_run.group('manage_members_icinga')
+ expect(group).to do_nothing
+ end
+ end
+
+ context 'ubuntu' do
+ let(:chef_run) do
+ ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
+ node.automatic['platform_family'] = 'debian'
+ node.set['icinga2']['classic_ui']['enable'] = true
+ node.set['icinga2']['ignore_version'] = true
+ node.set['icinga2']['web2']['enable'] = true
+ node.set['platform'] = 'ubuntu'
+ end.converge(described_recipe)
+ end
+
+ it 'creates an icinga2-classicui config file for apache2' do
+ expect(chef_run).to create_template('/etc/apache2/conf-available/icinga2-classicui.conf').with(
+ source: 'apache.vhost.icinga2_classic_ui.conf.debian.erb',
+ owner: 'www-data',
+ group: 'www-data'
+ )
+ end
+
+ it 'creates an icinga2-web2 config file for apache2' do
+ expect(chef_run).to create_template('/etc/apache2/conf-available/icinga2-web2.conf').with(
+ source: 'apache.vhost.icinga2_web2.erb',
+ owner: 'www-data',
+ group: 'www-data'
+ )
+ end
+
+ it 'creates a nagios user' do
+ expect(chef_run).to create_user('nagios')
+ end
+
+ it 'creates a nagios group' do
+ expect(chef_run).to create_group('nagios')
+ end
+
+ it 'modifies a manage_members_nagios group' do
+ expect(chef_run).to modify_group('manage_members_nagios')
+ end
+ end
+end
More information about the icinga-checkins
mailing list