]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/classes/mod/info_spec.rb
try again, with puppetforge modules, correctly included now
[dsa-puppet.git] / 3rdparty / modules / apache / spec / classes / mod / info_spec.rb
1 # This function is called inside the OS specific contexts
2 def general_info_specs_22
3   it { is_expected.to contain_apache__mod('info') }
4
5   context 'passing no parameters' do
6     it {
7       is_expected.to contain_file('info.conf').with_content(
8         "<Location /server-info>\n"\
9         "    SetHandler server-info\n"\
10         "    Order deny,allow\n"\
11         "    Deny from all\n"\
12         "    Allow from 127.0.0.1\n"\
13         "    Allow from ::1\n"\
14         "</Location>\n"
15       )
16     }
17   end
18   context 'passing restrict_access => false' do
19     let :params do {
20       :restrict_access => false
21     }
22     end
23     it {
24       is_expected.to contain_file('info.conf').with_content(
25         "<Location /server-info>\n"\
26         "    SetHandler server-info\n"\
27         "</Location>\n"
28       )
29     }
30   end
31   context "passing allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']" do
32     let :params do
33       {:allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']}
34     end
35     it {
36       is_expected.to contain_file('info.conf').with_content(
37         "<Location /server-info>\n"\
38         "    SetHandler server-info\n"\
39         "    Order deny,allow\n"\
40         "    Deny from all\n"\
41         "    Allow from 10.10.1.2\n"\
42         "    Allow from 192.168.1.2\n"\
43         "    Allow from 127.0.0.1\n"\
44         "</Location>\n"
45       )
46     }
47   end
48   context 'passing both restrict_access and allow_from' do
49     let :params do
50       {
51         :restrict_access => false,
52         :allow_from      => ['10.10.1.2', '192.168.1.2', '127.0.0.1']
53       }
54     end
55     it {
56       is_expected.to contain_file('info.conf').with_content(
57         "<Location /server-info>\n"\
58         "    SetHandler server-info\n"\
59         "</Location>\n"
60       )
61     }
62   end
63 end
64
65 def general_info_specs_24
66   it { is_expected.to contain_apache__mod('info') }
67
68   context 'passing no parameters' do
69     it {
70       is_expected.to contain_file('info.conf').with_content(
71         "<Location /server-info>\n"\
72         "    SetHandler server-info\n"\
73         "    Require ip 127.0.0.1 ::1\n"\
74         "</Location>\n"
75       )
76     }
77   end
78   context 'passing restrict_access => false' do
79     let :params do {
80       :restrict_access => false
81     }
82     end
83     it {
84       is_expected.to contain_file('info.conf').with_content(
85         "<Location /server-info>\n"\
86         "    SetHandler server-info\n"\
87         "</Location>\n"
88       )
89     }
90   end
91   context "passing allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']" do
92     let :params do
93       {:allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']}
94     end
95     it {
96       is_expected.to contain_file('info.conf').with_content(
97         "<Location /server-info>\n"\
98         "    SetHandler server-info\n"\
99         "    Require ip 10.10.1.2 192.168.1.2 127.0.0.1\n"\
100         "</Location>\n"
101       )
102     }
103   end
104   context 'passing both restrict_access and allow_from' do
105     let :params do
106       {
107         :restrict_access => false,
108         :allow_from      => ['10.10.1.2', '192.168.1.2', '127.0.0.1']
109       }
110     end
111     it {
112       is_expected.to contain_file('info.conf').with_content(
113         "<Location /server-info>\n"\
114         "    SetHandler server-info\n"\
115         "</Location>\n"
116       )
117     }
118   end
119 end
120
121 describe 'apache::mod::info', :type => :class do
122   let :pre_condition do
123     "class { 'apache': default_mods => false, }"
124   end
125
126   context 'On a Debian OS' do
127     let :facts do
128       {
129         :osfamily               => 'Debian',
130         :operatingsystemrelease => '6',
131         :concat_basedir         => '/dne',
132         :lsbdistcodename        => 'squeeze',
133         :operatingsystem        => 'Debian',
134         :id                     => 'root',
135         :kernel                 => 'Linux',
136         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
137         :is_pe                  => false,
138       }
139     end
140
141     # Load the more generic tests for this context
142     general_info_specs_22()
143
144     it { is_expected.to contain_file('info.conf').with({
145       :ensure => 'file',
146       :path   => '/etc/apache2/mods-available/info.conf',
147     } ) }
148     it { is_expected.to contain_file('info.conf symlink').with({
149       :ensure => 'link',
150       :path   => '/etc/apache2/mods-enabled/info.conf',
151     } ) }
152   end
153
154   context 'on a RedHat OS' do
155     let :facts do
156       {
157         :osfamily               => 'RedHat',
158         :operatingsystemrelease => '6',
159         :concat_basedir         => '/dne',
160         :operatingsystem        => 'RedHat',
161         :id                     => 'root',
162         :kernel                 => 'Linux',
163         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
164         :is_pe                  => false,
165       }
166     end
167
168     # Load the more generic tests for this context
169     general_info_specs_22()
170
171     it { is_expected.to contain_file('info.conf').with({
172       :ensure => 'file',
173       :path   => '/etc/httpd/conf.d/info.conf',
174       } ) }
175   end
176
177   context 'on a FreeBSD OS' do
178     let :facts do
179       {
180         :osfamily               => 'FreeBSD',
181         :operatingsystemrelease => '10',
182         :concat_basedir         => '/dne',
183         :operatingsystem        => 'FreeBSD',
184         :id                     => 'root',
185         :kernel                 => 'FreeBSD',
186         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
187         :is_pe                  => false,
188       }
189     end
190
191     # Load the more generic tests for this context
192     general_info_specs_24()
193
194     it { is_expected.to contain_file('info.conf').with({
195       :ensure => 'file',
196       :path   => '/usr/local/etc/apache24/Modules/info.conf',
197     } ) }
198   end
199
200   context 'on a Gentoo OS' do
201     let :facts do
202       {
203         :osfamily               => 'Gentoo',
204         :operatingsystem        => 'Gentoo',
205         :operatingsystemrelease => '3.16.1-gentoo',
206         :concat_basedir         => '/dne',
207         :id                     => 'root',
208         :kernel                 => 'Linux',
209         :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
210         :is_pe                  => false,
211       }
212     end
213
214     # Load the more generic tests for this context
215     general_info_specs_24()
216
217     it { is_expected.to contain_file('info.conf').with({
218       :ensure => 'file',
219       :path   => '/etc/apache2/modules.d/info.conf',
220     } ) }
221   end
222 end