]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/acceptance/class_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / acceptance / class_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'apache class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4   case fact('osfamily')
5   when 'RedHat'
6     package_name = 'httpd'
7     service_name = 'httpd'
8   when 'Debian'
9     package_name = 'apache2'
10     service_name = 'apache2'
11   when 'FreeBSD'
12     package_name = 'apache24'
13     service_name = 'apache24'
14   when 'Gentoo'
15     package_name = 'www-servers/apache'
16     service_name = 'apache2'
17   end
18
19   context 'default parameters' do
20     it 'should work with no errors' do
21       pp = <<-EOS
22       class { 'apache': }
23       EOS
24
25       # Run it twice and test for idempotency
26       apply_manifest(pp, :catch_failures => true)
27       expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
28     end
29
30     describe package(package_name) do
31       it { is_expected.to be_installed }
32     end
33
34     describe service(service_name) do
35       it { is_expected.to be_enabled }
36       it { is_expected.to be_running }
37     end
38
39     describe port(80) do
40       it { should be_listening }
41     end
42   end
43
44   context 'custom site/mod dir parameters' do
45     # Using puppet_apply as a helper
46     it 'should work with no errors' do
47       pp = <<-EOS
48       if $::osfamily == 'RedHat' and $::selinux {
49         $semanage_package = $::operatingsystemmajrelease ? {
50           '5'     => 'policycoreutils',
51           default => 'policycoreutils-python',
52         }
53
54         package { $semanage_package: ensure => installed }
55         exec { 'set_apache_defaults':
56           command     => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
57           path        => '/bin:/usr/bin/:/sbin:/usr/sbin',
58           subscribe   => Package[$semanage_package],
59           refreshonly => true,
60         }
61         exec { 'restorecon_apache':
62           command     => 'restorecon -Rv /apache_spec',
63           path        => '/bin:/usr/bin/:/sbin:/usr/sbin',
64           before      => Service['httpd'],
65           require     => Class['apache'],
66           subscribe   => Exec['set_apache_defaults'],
67           refreshonly => true,
68         }
69       }
70       file { '/apache_spec': ensure => directory, }
71       file { '/apache_spec/apache_custom': ensure => directory, }
72       class { 'apache':
73         mod_dir   => '/apache_spec/apache_custom/mods',
74         vhost_dir => '/apache_spec/apache_custom/vhosts',
75       }
76       EOS
77
78       # Run it twice and test for idempotency
79       apply_manifest(pp, :catch_failures => true)
80       apply_manifest(pp, :catch_changes => true)
81     end
82
83     describe service(service_name) do
84       it { is_expected.to be_enabled }
85       it { is_expected.to be_running }
86     end
87   end
88 end