|
7 | 7 | include_examples 'Debian 11'
|
8 | 8 |
|
9 | 9 | it { is_expected.to contain_class('apache::params') }
|
| 10 | + |
10 | 11 | it {
|
11 | 12 | is_expected.to contain_package('httpd').with(
|
12 | 13 | 'notify' => 'Class[Apache::Service]',
|
13 | 14 | 'ensure' => 'installed',
|
14 | 15 | )
|
15 | 16 | }
|
| 17 | + |
16 | 18 | it { is_expected.to contain_user('www-data') }
|
17 | 19 | it { is_expected.to contain_group('www-data') }
|
18 | 20 | it { is_expected.to contain_class('apache::service') }
|
| 21 | + |
19 | 22 | it {
|
20 | 23 | is_expected.to contain_file('/var/www/html').with(
|
21 | 24 | 'ensure' => 'directory',
|
22 | 25 | )
|
23 | 26 | }
|
| 27 | + |
24 | 28 | it {
|
25 | 29 | is_expected.to contain_file('/etc/apache2/sites-enabled').with(
|
26 | 30 | 'ensure' => 'directory', 'recurse' => 'true',
|
27 | 31 | 'purge' => 'true'
|
28 | 32 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
29 | 33 | }
|
| 34 | + |
30 | 35 | it {
|
31 | 36 | is_expected.to contain_file('/etc/apache2/mods-enabled').with(
|
32 | 37 | 'ensure' => 'directory', 'recurse' => 'true',
|
33 | 38 | 'purge' => 'true'
|
34 | 39 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
35 | 40 | }
|
| 41 | + |
36 | 42 | it {
|
37 | 43 | is_expected.to contain_file('/etc/apache2/mods-available').with(
|
38 | 44 | 'ensure' => 'directory', 'recurse' => 'true',
|
39 | 45 | 'purge' => 'false'
|
40 | 46 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
41 | 47 | }
|
| 48 | + |
42 | 49 | it { is_expected.to contain_file('/etc/apache2/apache2.conf').without_content(%r{ServerAdmin}) }
|
| 50 | + |
43 | 51 | it {
|
44 | 52 | is_expected.to contain_concat('/etc/apache2/ports.conf').with(
|
45 | 53 | 'owner' => 'root', 'group' => 'root',
|
46 | 54 | 'mode' => '0644'
|
47 | 55 | ).that_notifies('Class[Apache::Service]')
|
48 | 56 | }
|
| 57 | + |
49 | 58 | # Assert that load files are placed and symlinked for these mods, but no conf file.
|
50 | 59 | ['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
|
51 | 60 | it {
|
|
54 | 63 | 'ensure' => 'file',
|
55 | 64 | )
|
56 | 65 | }
|
| 66 | + |
57 | 67 | it {
|
58 | 68 | is_expected.to contain_file("#{modname}.load symlink").with(
|
59 | 69 | 'path' => "/etc/apache2/mods-enabled/#{modname}.load",
|
60 | 70 | 'ensure' => 'link',
|
61 | 71 | 'target' => "/etc/apache2/mods-available/#{modname}.load",
|
62 | 72 | )
|
63 | 73 | }
|
| 74 | + |
64 | 75 | it { is_expected.not_to contain_file("#{modname}.conf") }
|
65 | 76 | it { is_expected.not_to contain_file("#{modname}.conf symlink") }
|
66 | 77 | end
|
|
125 | 136 | 'ensure' => 'file',
|
126 | 137 | )
|
127 | 138 | }
|
| 139 | + |
128 | 140 | it {
|
129 | 141 | is_expected.to contain_file("#{modname}.load symlink").with(
|
130 | 142 | 'path' => "/etc/apache2/mods-enabled/#{modname}.load",
|
131 | 143 | 'ensure' => 'link',
|
132 | 144 | 'target' => "/etc/apache2/mods-available/#{modname}.load",
|
133 | 145 | )
|
134 | 146 | }
|
| 147 | + |
135 | 148 | it {
|
136 | 149 | is_expected.to contain_file("#{modname}.conf").with(
|
137 | 150 | 'path' => "/etc/apache2/mods-available/#{modname}.conf",
|
138 | 151 | 'ensure' => 'file',
|
139 | 152 | )
|
140 | 153 | }
|
| 154 | + |
141 | 155 | it {
|
142 | 156 | is_expected.to contain_file("#{modname}.conf symlink").with(
|
143 | 157 | 'path' => "/etc/apache2/mods-enabled/#{modname}.conf",
|
|
198 | 212 | is_expected.to contain_file('/etc/apache2/apache2.conf').with_content reg
|
199 | 213 | end
|
200 | 214 | end
|
| 215 | + |
201 | 216 | it 'Not expected to contain' do
|
202 | 217 | unexpected.each do |reg|
|
203 | 218 | is_expected.to contain_file('/etc/apache2/apache2.conf').without_content reg
|
|
229 | 244 | include_examples 'RedHat 8'
|
230 | 245 |
|
231 | 246 | it { is_expected.to contain_class('apache::params') }
|
| 247 | + |
232 | 248 | it {
|
233 | 249 | is_expected.to contain_package('httpd').with(
|
234 | 250 | 'notify' => 'Class[Apache::Service]',
|
235 | 251 | 'ensure' => 'installed',
|
236 | 252 | )
|
237 | 253 | }
|
| 254 | + |
238 | 255 | it { is_expected.to contain_user('apache') }
|
239 | 256 | it { is_expected.to contain_group('apache') }
|
240 | 257 | it { is_expected.to contain_class('apache::service') }
|
| 258 | + |
241 | 259 | it {
|
242 | 260 | is_expected.to contain_file('/var/www/html').with(
|
243 | 261 | 'ensure' => 'directory',
|
244 | 262 | )
|
245 | 263 | }
|
| 264 | + |
246 | 265 | it {
|
247 | 266 | is_expected.to contain_file('/etc/httpd/conf.d').with(
|
248 | 267 | 'ensure' => 'directory', 'recurse' => 'true',
|
249 | 268 | 'purge' => 'true'
|
250 | 269 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
251 | 270 | }
|
| 271 | + |
252 | 272 | it {
|
253 | 273 | is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with(
|
254 | 274 | 'owner' => 'root', 'group' => 'root',
|
255 | 275 | 'mode' => '0644'
|
256 | 276 | ).that_notifies('Class[Apache::Service]')
|
257 | 277 | }
|
| 278 | + |
258 | 279 | describe 'Alternate confd/mod/vhosts directory' do
|
259 | 280 | let :params do
|
260 | 281 | {
|
|
280 | 301 | "/etc/httpd/mod.d/#{modname}.load",
|
281 | 302 | )
|
282 | 303 | }
|
| 304 | + |
283 | 305 | it {
|
284 | 306 | is_expected.not_to contain_file("#{modname}.conf").with_path(
|
285 | 307 | "/etc/httpd/mod.d/#{modname}.conf",
|
|
294 | 316 | "/etc/httpd/mod.d/#{modname}.load",
|
295 | 317 | )
|
296 | 318 | }
|
| 319 | + |
297 | 320 | it {
|
298 | 321 | is_expected.to contain_file("#{modname}.conf").with_path(
|
299 | 322 | "/etc/httpd/mod.d/#{modname}.conf",
|
|
521 | 544 | it { is_expected.to contain_user('www') }
|
522 | 545 | it { is_expected.to contain_group('www') }
|
523 | 546 | it { is_expected.to contain_class('apache::service') }
|
| 547 | + |
524 | 548 | it {
|
525 | 549 | is_expected.to contain_file('/usr/local/www/apache24/data').with(
|
526 | 550 | 'ensure' => 'directory',
|
527 | 551 | )
|
528 | 552 | }
|
| 553 | + |
529 | 554 | it {
|
530 | 555 | is_expected.to contain_file('/usr/local/etc/apache24/Vhosts').with(
|
531 | 556 | 'ensure' => 'directory', 'recurse' => 'true',
|
532 | 557 | 'purge' => 'true'
|
533 | 558 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
534 | 559 | }
|
| 560 | + |
535 | 561 | it {
|
536 | 562 | is_expected.to contain_file('/usr/local/etc/apache24/Modules').with(
|
537 | 563 | 'ensure' => 'directory', 'recurse' => 'true',
|
538 | 564 | 'purge' => 'true'
|
539 | 565 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
540 | 566 | }
|
| 567 | + |
541 | 568 | it {
|
542 | 569 | is_expected.to contain_concat('/usr/local/etc/apache24/ports.conf').with(
|
543 | 570 | 'owner' => 'root', 'group' => 'wheel',
|
544 | 571 | 'mode' => '0644'
|
545 | 572 | ).that_notifies('Class[Apache::Service]')
|
546 | 573 | }
|
| 574 | + |
547 | 575 | # Assert that load files are placed for these mods, but no conf file.
|
548 | 576 | ['auth_basic', 'authn_core', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
|
549 | 577 | it {
|
|
552 | 580 | 'ensure' => 'file',
|
553 | 581 | )
|
554 | 582 | }
|
| 583 | + |
555 | 584 | it { is_expected.not_to contain_file("#{modname}.conf") }
|
556 | 585 | end
|
557 | 586 |
|
|
563 | 592 | 'ensure' => 'file',
|
564 | 593 | )
|
565 | 594 | }
|
| 595 | + |
566 | 596 | it {
|
567 | 597 | is_expected.to contain_file("#{modname}.conf").with(
|
568 | 598 | 'path' => "/usr/local/etc/apache24/Modules/#{modname}.conf",
|
|
578 | 608 | it { is_expected.to contain_user('apache') }
|
579 | 609 | it { is_expected.to contain_group('apache') }
|
580 | 610 | it { is_expected.to contain_class('apache::service') }
|
| 611 | + |
581 | 612 | it {
|
582 | 613 | is_expected.to contain_file('/var/www/localhost/htdocs').with(
|
583 | 614 | 'ensure' => 'directory',
|
584 | 615 | )
|
585 | 616 | }
|
| 617 | + |
586 | 618 | it {
|
587 | 619 | is_expected.to contain_file('/etc/apache2/vhosts.d').with(
|
588 | 620 | 'ensure' => 'directory', 'recurse' => 'true',
|
589 | 621 | 'purge' => 'true'
|
590 | 622 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
591 | 623 | }
|
| 624 | + |
592 | 625 | it {
|
593 | 626 | is_expected.to contain_file('/etc/apache2/modules.d').with(
|
594 | 627 | 'ensure' => 'directory', 'recurse' => 'true',
|
595 | 628 | 'purge' => 'true'
|
596 | 629 | ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
|
597 | 630 | }
|
| 631 | + |
598 | 632 | it {
|
599 | 633 | is_expected.to contain_concat('/etc/apache2/ports.conf').with(
|
600 | 634 | 'owner' => 'root', 'group' => 'wheel',
|
|
0 commit comments