comparison modules/apache/spec/classes/mod/status_spec.rb @ 36:37675581a273 puppet-3.6

Update Puppet module for Apache (pulls in concat module)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:07:04 +0000
parents 956e484adc12
children 675c1cc61eaf
comparison
equal deleted inserted replaced
35:1bb941522ebf 36:37675581a273
1 require 'spec_helper' 1 require 'spec_helper'
2 2
3 # Helper function for testing the contents of `status.conf` 3 # Helper function for testing the contents of `status.conf`
4 def status_conf_spec(allow_from, extended_status) 4 def status_conf_spec(allow_from, extended_status, status_path)
5 it do 5 it do
6 should contain_file("status.conf").with_content( 6 is_expected.to contain_file("status.conf").with_content(
7 "<Location /server-status>\n"\ 7 "<Location #{status_path}>\n"\
8 " SetHandler server-status\n"\ 8 " SetHandler server-status\n"\
9 " Order deny,allow\n"\ 9 " Order deny,allow\n"\
10 " Deny from all\n"\ 10 " Deny from all\n"\
11 " Allow from #{Array(allow_from).join(' ')}\n"\ 11 " Allow from #{Array(allow_from).join(' ')}\n"\
12 "</Location>\n"\ 12 "</Location>\n"\
29 let :facts do 29 let :facts do
30 { 30 {
31 :osfamily => 'Debian', 31 :osfamily => 'Debian',
32 :operatingsystemrelease => '6', 32 :operatingsystemrelease => '6',
33 :concat_basedir => '/dne', 33 :concat_basedir => '/dne',
34 } 34 :lsbdistcodename => 'squeeze',
35 end 35 :operatingsystem => 'Debian',
36 36 :id => 'root',
37 it { should contain_apache__mod("status") } 37 :kernel => 'Linux',
38 38 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
39 status_conf_spec(["127.0.0.1", "::1"], "On") 39 :is_pe => false,
40 40 }
41 it { should contain_file("status.conf").with({ 41 end
42
43 it { is_expected.to contain_apache__mod("status") }
44
45 status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
46
47 it { is_expected.to contain_file("status.conf").with({
42 :ensure => 'file', 48 :ensure => 'file',
43 :path => '/etc/apache2/mods-available/status.conf', 49 :path => '/etc/apache2/mods-available/status.conf',
44 } ) } 50 } ) }
45 51
46 it { should contain_file("status.conf symlink").with({ 52 it { is_expected.to contain_file("status.conf symlink").with({
47 :ensure => 'link', 53 :ensure => 'link',
48 :path => '/etc/apache2/mods-enabled/status.conf', 54 :path => '/etc/apache2/mods-enabled/status.conf',
49 } ) } 55 } ) }
50 56
51 end 57 end
54 let :facts do 60 let :facts do
55 { 61 {
56 :osfamily => 'RedHat', 62 :osfamily => 'RedHat',
57 :operatingsystemrelease => '6', 63 :operatingsystemrelease => '6',
58 :concat_basedir => '/dne', 64 :concat_basedir => '/dne',
59 } 65 :operatingsystem => 'RedHat',
60 end 66 :id => 'root',
61 67 :kernel => 'Linux',
62 it { should contain_apache__mod("status") } 68 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
63 69 :is_pe => false,
64 status_conf_spec(["127.0.0.1", "::1"], "On") 70 }
65 71 end
66 it { should contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") } 72
67 73 it { is_expected.to contain_apache__mod("status") }
68 end 74
69 75 status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
70 context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off'" do 76
71 let :facts do 77 it { is_expected.to contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") }
72 { 78
73 :osfamily => 'Debian', 79 end
74 :operatingsystemrelease => '6', 80
75 :concat_basedir => '/dne', 81 context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off', $status_path => '/custom-status'" do
82 let :facts do
83 {
84 :osfamily => 'Debian',
85 :operatingsystemrelease => '6',
86 :concat_basedir => '/dne',
87 :lsbdistcodename => 'squeeze',
88 :operatingsystem => 'Debian',
89 :id => 'root',
90 :kernel => 'Linux',
91 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
92 :is_pe => false,
76 } 93 }
77 end 94 end
78 let :params do 95 let :params do
79 { 96 {
80 :allow_from => ['10.10.10.10','11.11.11.11'], 97 :allow_from => ['10.10.10.10','11.11.11.11'],
81 :extended_status => 'Off', 98 :extended_status => 'Off',
82 } 99 :status_path => '/custom-status',
83 end 100 }
84 101 end
85 status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off") 102
103 status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off", "/custom-status")
86 104
87 end 105 end
88 106
89 context "with valid parameter type $allow_from => ['10.10.10.10']" do 107 context "with valid parameter type $allow_from => ['10.10.10.10']" do
90 let :facts do 108 let :facts do
91 { 109 {
92 :osfamily => 'Debian', 110 :osfamily => 'Debian',
93 :operatingsystemrelease => '6', 111 :operatingsystemrelease => '6',
94 :concat_basedir => '/dne', 112 :concat_basedir => '/dne',
113 :lsbdistcodename => 'squeeze',
114 :operatingsystem => 'Debian',
115 :id => 'root',
116 :kernel => 'Linux',
117 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
118 :is_pe => false,
95 } 119 }
96 end 120 end
97 let :params do 121 let :params do
98 { :allow_from => ['10.10.10.10'] } 122 { :allow_from => ['10.10.10.10'] }
99 end 123 end
100 it 'should expect to succeed array validation' do 124 it 'should expect to succeed array validation' do
101 expect { 125 expect {
102 should contain_file("status.conf") 126 is_expected.to contain_file("status.conf")
103 }.not_to raise_error() 127 }.not_to raise_error()
104 end 128 end
105 end 129 end
106 130
107 context "with invalid parameter type $allow_from => '10.10.10.10'" do 131 context "with invalid parameter type $allow_from => '10.10.10.10'" do
108 let :facts do 132 let :facts do
109 { 133 {
110 :osfamily => 'Debian', 134 :osfamily => 'Debian',
111 :operatingsystemrelease => '6', 135 :operatingsystemrelease => '6',
112 :concat_basedir => '/dne', 136 :concat_basedir => '/dne',
137 :operatingsystem => 'Debian',
138 :id => 'root',
139 :kernel => 'Linux',
140 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
141 :is_pe => false,
113 } 142 }
114 end 143 end
115 let :params do 144 let :params do
116 { :allow_from => '10.10.10.10' } 145 { :allow_from => '10.10.10.10' }
117 end 146 end
118 it 'should expect to fail array validation' do 147 it 'should expect to fail array validation' do
119 expect { 148 expect {
120 should contain_file("status.conf") 149 is_expected.to contain_file("status.conf")
121 }.to raise_error(Puppet::Error) 150 }.to raise_error(Puppet::Error)
122 end 151 end
123 end 152 end
124 153
125 # Only On or Off are valid options 154 # Only On or Off are valid options
128 let :facts do 157 let :facts do
129 { 158 {
130 :osfamily => 'Debian', 159 :osfamily => 'Debian',
131 :operatingsystemrelease => '6', 160 :operatingsystemrelease => '6',
132 :concat_basedir => '/dne', 161 :concat_basedir => '/dne',
162 :lsbdistcodename => 'squeeze',
163 :operatingsystem => 'Debian',
164 :id => 'root',
165 :kernel => 'Linux',
166 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
167 :is_pe => false,
133 } 168 }
134 end 169 end
135 let :params do 170 let :params do
136 { :extended_status => valid_param } 171 { :extended_status => valid_param }
137 end 172 end
138 it 'should expect to succeed regular expression validation' do 173 it 'should expect to succeed regular expression validation' do
139 expect { 174 expect {
140 should contain_file("status.conf") 175 is_expected.to contain_file("status.conf")
141 }.not_to raise_error() 176 }.not_to raise_error()
142 end 177 end
143 end 178 end
144 end 179 end
145 180
148 let :facts do 183 let :facts do
149 { 184 {
150 :osfamily => 'Debian', 185 :osfamily => 'Debian',
151 :operatingsystemrelease => '6', 186 :operatingsystemrelease => '6',
152 :concat_basedir => '/dne', 187 :concat_basedir => '/dne',
188 :operatingsystem => 'Debian',
189 :id => 'root',
190 :kernel => 'Linux',
191 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
192 :is_pe => false,
153 } 193 }
154 end 194 end
155 let :params do 195 let :params do
156 { :extended_status => invalid_param } 196 { :extended_status => invalid_param }
157 end 197 end
158 it 'should expect to fail regular expression validation' do 198 it 'should expect to fail regular expression validation' do
159 expect { 199 expect {
160 should contain_file("status.conf") 200 is_expected.to contain_file("status.conf")
161 }.to raise_error(Puppet::Error) 201 }.to raise_error(Puppet::Error)
162 end 202 end
163 end 203 end
164 end 204 end
165 205