comparison modules/apache/spec/acceptance/default_mods_spec.rb @ 257:675c1cc61eaf

Update Apache module to get CentOS 8 support Unfortunately it only fixes some bits. mod_wsgi still needs other approaches This also overrides the vhost modification to make them come last in the import order (after module loading)
author IBBoard <dev@ibboard.co.uk>
date Sun, 22 Dec 2019 14:43:29 -0500
parents 37675581a273
children d9352a684e62
comparison
equal deleted inserted replaced
252:47750947f4dc 257:675c1cc61eaf
1 require 'spec_helper_acceptance' 1 require 'spec_helper_acceptance'
2 require_relative './version.rb'
2 3
3 case fact('osfamily') 4 describe 'apache::default_mods class' do
4 when 'RedHat'
5 mod_dir = '/etc/httpd/conf.d'
6 servicename = 'httpd'
7 when 'Debian'
8 mod_dir = '/etc/apache2/mods-available'
9 servicename = 'apache2'
10 when 'FreeBSD'
11 mod_dir = '/usr/local/etc/apache24/Modules'
12 servicename = 'apache24'
13 end
14
15 describe 'apache::default_mods class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
16 describe 'no default mods' do 5 describe 'no default mods' do
17 # Using puppet_apply as a helper 6 # Using puppet_apply as a helper
18 it 'should apply with no errors' do 7 let(:pp) do
19 pp = <<-EOS 8 <<-EOS
20 class { 'apache': 9 class { 'apache':
21 default_mods => false, 10 default_mods => false,
22 } 11 }
23 EOS 12 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 13 end
29 14
30 describe service(servicename) do 15 # Run it twice and test for idempotency
16 it_behaves_like "a idempotent resource"
17 describe service($service_name) do
31 it { is_expected.to be_running } 18 it { is_expected.to be_running }
32 end 19 end
33 end 20 end
34 21
35 describe 'no default mods and failing' do 22 unless (fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12')
36 # Using puppet_apply as a helper 23 describe 'no default mods and failing' do
37 it 'should apply with errors' do 24 before :all do
38 pp = <<-EOS 25 pp = <<-PP
39 class { 'apache': 26 include apache::params
40 default_mods => false, 27 class { 'apache': default_mods => false, service_ensure => stopped, }
41 } 28 PP
42 apache::vhost { 'defaults.example.com': 29 apply_manifest(pp)
43 docroot => '/var/www/defaults', 30 end
44 aliases => { 31 # Using puppet_apply as a helper
45 alias => '/css', 32 it 'should apply with errors' do
46 path => '/var/www/css', 33 pp = <<-EOS
47 }, 34 class { 'apache':
48 setenv => 'TEST1 one', 35 default_mods => false,
49 } 36 }
50 EOS 37 apache::vhost { 'defaults.example.com':
38 docroot => '#{$doc_root}/defaults',
39 aliases => {
40 alias => '/css',
41 path => '#{$doc_root}/css',
42 },
43 directories => [
44 {
45 'path' => "#{$doc_root}/admin",
46 'auth_basic_fake' => 'demo demopass',
47 }
48 ],
49 setenv => 'TEST1 one',
50 }
51 EOS
51 52
52 apply_manifest(pp, { :expect_failures => true }) 53 apply_manifest(pp, { :expect_failures => true })
53 end 54 end
55 end
54 56
55 # Are these the same? 57 describe service($service_name) do
56 describe service(servicename) do
57 it { is_expected.not_to be_running } 58 it { is_expected.not_to be_running }
58 end
59 describe "service #{servicename}" do
60 it 'should not be running' do
61 shell("pidof #{servicename}", {:acceptable_exit_codes => 1})
62 end
63 end 59 end
64 end 60 end
65 61
66 describe 'alternative default mods' do 62 describe 'alternative default mods' do
67 # Using puppet_apply as a helper 63 # Using puppet_apply as a helper
68 it 'should apply with no errors' do 64 let(:pp) do
69 pp = <<-EOS 65 <<-EOS
70 class { 'apache': 66 class { 'apache':
71 default_mods => [ 67 default_mods => [
72 'info', 68 'info',
73 'alias', 69 'alias',
74 'mime', 70 'mime',
75 'env', 71 'env',
76 'expires', 72 'expires',
77 ], 73 ],
78 } 74 }
79 apache::vhost { 'defaults.example.com': 75 apache::vhost { 'defaults.example.com':
80 docroot => '/var/www/defaults', 76 docroot => '#{$doc_root}/defaults',
81 aliases => { 77 aliases => {
82 alias => '/css', 78 alias => '/css',
83 path => '/var/www/css', 79 path => '#{$doc_root}/css',
84 }, 80 },
85 setenv => 'TEST1 one', 81 setenv => 'TEST1 one',
86 } 82 }
87 EOS 83 EOS
84 end
85 it_behaves_like "a idempotent resource"
88 86
89 apply_manifest(pp, :catch_failures => true) 87 describe service($service_name) do
90 shell('sleep 10')
91 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
92 end
93
94 describe service(servicename) do
95 it { is_expected.to be_running } 88 it { is_expected.to be_running }
96 end 89 end
97 end 90 end
98 91
99 describe 'change loadfile name' do 92 describe 'change loadfile name' do
100 it 'should apply with no errors' do 93 let(:pp) do
101 pp = <<-EOS 94 <<-EOS
102 class { 'apache': default_mods => false } 95 class { 'apache': default_mods => false }
103 ::apache::mod { 'auth_basic': 96 ::apache::mod { 'auth_basic':
104 loadfile_name => 'zz_auth_basic.load', 97 loadfile_name => 'zz_auth_basic.load',
105 } 98 }
106 EOS 99 EOS
107 # Run it twice and test for idempotency
108 apply_manifest(pp, :catch_failures => true)
109 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
110 end 100 end
111 101 # Run it twice and test for idempotency
112 describe service(servicename) do 102 it_behaves_like "a idempotent resource"
103 describe service($service_name) do
113 it { is_expected.to be_running } 104 it { is_expected.to be_running }
114 end 105 end
115 106
116 describe file("#{mod_dir}/zz_auth_basic.load") do 107 describe file("#{$mod_dir}/zz_auth_basic.load") do
117 it { is_expected.to be_file } 108 it { is_expected.to be_file }
118 end 109 end
119 end 110 end
120 end 111 end