|
4 | 4 |
|
5 | 5 | describe 'apache', type: :class do |
6 | 6 | context 'on a Debian OS' do |
7 | | - let :facts do |
8 | | - { |
9 | | - id: 'root', |
10 | | - kernel: 'Linux', |
11 | | - lsbdistcodename: 'squeeze', |
12 | | - osfamily: 'Debian', |
13 | | - operatingsystem: 'Debian', |
14 | | - operatingsystemrelease: '6', |
15 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
16 | | - is_pe: false, |
17 | | - } |
18 | | - end |
| 7 | + include_examples 'Debian 8' |
19 | 8 |
|
20 | 9 | it { is_expected.to contain_class('apache::params') } |
21 | 10 | it { |
|
28 | 17 | it { is_expected.to contain_group('www-data') } |
29 | 18 | it { is_expected.to contain_class('apache::service') } |
30 | 19 | it { |
31 | | - is_expected.to contain_file('/var/www').with( |
| 20 | + is_expected.to contain_file('/var/www/html').with( |
32 | 21 | 'ensure' => 'directory', |
33 | 22 | ) |
34 | 23 | } |
|
57 | 46 | ).that_notifies('Class[Apache::Service]') |
58 | 47 | } |
59 | 48 | # Assert that load files are placed and symlinked for these mods, but no conf file. |
60 | | - ['auth_basic', 'authn_file', 'authz_default', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| |
| 49 | + ['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| |
61 | 50 | it { |
62 | 51 | is_expected.to contain_file("#{modname}.load").with( |
63 | 52 | 'path' => "/etc/apache2/mods-available/#{modname}.load", |
|
243 | 232 | end |
244 | 233 | end |
245 | 234 |
|
246 | | - context '8' do |
247 | | - let :facts do |
248 | | - super().merge(lsbdistcodename: 'jessie', |
249 | | - operatingsystemrelease: '8.0.0') |
| 235 | + describe 'Alternate mpm_modules when declaring mpm_module => prefork' do |
| 236 | + let :params do |
| 237 | + { mpm_module: 'worker' } |
250 | 238 | end |
251 | 239 |
|
252 | | - it { |
253 | | - is_expected.to contain_file('/var/www/html').with( |
254 | | - 'ensure' => 'directory', |
255 | | - ) |
256 | | - } |
257 | | - describe 'Alternate mpm_modules when declaring mpm_module => prefork' do |
258 | | - let :params do |
259 | | - { mpm_module: 'worker' } |
260 | | - end |
261 | | - |
262 | | - it { is_expected.to contain_exec('/usr/sbin/a2dismod event') } |
263 | | - it { is_expected.to contain_exec('/usr/sbin/a2dismod prefork') } |
264 | | - end |
| 240 | + it { is_expected.to contain_exec('/usr/sbin/a2dismod event') } |
| 241 | + it { is_expected.to contain_exec('/usr/sbin/a2dismod prefork') } |
265 | 242 | end |
266 | 243 |
|
267 | | - context 'on Ubuntu 14.04' do |
268 | | - let :facts do |
269 | | - super().merge(operatingsystem: 'Ubuntu', |
270 | | - lsbdistrelease: '14.04', |
271 | | - operatingsystemrelease: '14.04') |
272 | | - end |
| 244 | + context 'on Ubuntu 18.04' do |
| 245 | + include_examples 'Ubuntu 18.04' |
273 | 246 |
|
274 | 247 | it { |
275 | 248 | is_expected.to contain_file('/var/www/html').with( |
|
279 | 252 | end |
280 | 253 | end |
281 | 254 |
|
282 | | - context 'on a RedHat 5 OS' do |
283 | | - let :facts do |
284 | | - { |
285 | | - id: 'root', |
286 | | - kernel: 'Linux', |
287 | | - osfamily: 'RedHat', |
288 | | - operatingsystem: 'RedHat', |
289 | | - operatingsystemrelease: '5', |
290 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
291 | | - is_pe: false, |
292 | | - } |
293 | | - end |
| 255 | + context 'on a RedHat 8 OS' do |
| 256 | + include_examples 'RedHat 8' |
294 | 257 |
|
295 | 258 | it { is_expected.to contain_class('apache::params') } |
296 | 259 | it { |
|
338 | 301 | end |
339 | 302 |
|
340 | 303 | # Assert that load files are placed for these mods, but no conf file. |
341 | | - ['auth_basic', 'authn_file', 'authz_default', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| |
| 304 | + ['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| |
342 | 305 | it { |
343 | 306 | is_expected.to contain_file("#{modname}.load").with_path( |
344 | 307 | "/etc/httpd/mod.d/#{modname}.load", |
|
365 | 328 | } |
366 | 329 | end |
367 | 330 |
|
368 | | - it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/site\.d/\*"$} } |
| 331 | + it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^IncludeOptional "/etc/httpd/site\.d/\*"$} } |
369 | 332 | it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/mod\.d/\*\.conf"$} } |
370 | 333 | it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/mod\.d/\*\.load"$} } |
371 | 334 | end |
|
667 | 630 | end |
668 | 631 |
|
669 | 632 | context 'on Fedora 21' do |
670 | | - let :facts do |
671 | | - super().merge(operatingsystem: 'Fedora', |
672 | | - lsbdistrelease: '21', |
673 | | - operatingsystemrelease: '21') |
674 | | - end |
| 633 | + include_examples 'Fedora 21' |
675 | 634 |
|
676 | 635 | it { is_expected.to contain_class('apache').with_apache_version('2.4') } |
677 | 636 | end |
678 | 637 | context 'on Fedora Rawhide' do |
679 | | - let :facts do |
680 | | - super().merge(operatingsystem: 'Fedora', |
681 | | - lsbdistrelease: 'Rawhide', |
682 | | - operatingsystemrelease: 'Rawhide') |
683 | | - end |
| 638 | + include_examples 'Fedora Rawhide' |
684 | 639 |
|
685 | 640 | it { is_expected.to contain_class('apache').with_apache_version('2.4') } |
686 | 641 | end |
687 | 642 | # kinda obsolete |
688 | 643 | context 'on Fedora 17' do |
689 | | - let :facts do |
690 | | - super().merge(operatingsystem: 'Fedora', |
691 | | - lsbdistrelease: '17', |
692 | | - operatingsystemrelease: '17') |
693 | | - end |
| 644 | + include_examples 'Fedora 17' |
694 | 645 |
|
695 | 646 | it { is_expected.to contain_class('apache').with_apache_version('2.2') } |
696 | 647 | end |
697 | 648 | end |
698 | 649 | context 'on a FreeBSD OS' do |
699 | | - let :facts do |
700 | | - { |
701 | | - id: 'root', |
702 | | - kernel: 'FreeBSD', |
703 | | - osfamily: 'FreeBSD', |
704 | | - operatingsystem: 'FreeBSD', |
705 | | - operatingsystemrelease: '10', |
706 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
707 | | - is_pe: false, |
708 | | - } |
709 | | - end |
| 650 | + include_examples 'FreeBSD 10' |
710 | 651 |
|
711 | 652 | it { is_expected.to contain_class('apache::params') } |
712 | 653 | it { is_expected.to contain_class('apache::package').with('ensure' => 'present') } |
|
764 | 705 | end |
765 | 706 | end |
766 | 707 | context 'on a Gentoo OS' do |
767 | | - let :facts do |
768 | | - { |
769 | | - id: 'root', |
770 | | - kernel: 'Linux', |
771 | | - osfamily: 'Gentoo', |
772 | | - operatingsystem: 'Gentoo', |
773 | | - operatingsystemrelease: '3.16.1-gentoo', |
774 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin', |
775 | | - is_pe: false, |
776 | | - } |
777 | | - end |
| 708 | + include_examples 'Gentoo' |
778 | 709 |
|
779 | 710 | it { is_expected.to contain_class('apache::params') } |
780 | 711 | it { is_expected.to contain_user('apache') } |
|
805 | 736 | } |
806 | 737 | end |
807 | 738 | context 'on all OSes' do |
808 | | - let :facts do |
809 | | - { |
810 | | - id: 'root', |
811 | | - kernel: 'Linux', |
812 | | - osfamily: 'RedHat', |
813 | | - operatingsystem: 'RedHat', |
814 | | - operatingsystemrelease: '6', |
815 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
816 | | - is_pe: false, |
817 | | - } |
818 | | - end |
| 739 | + include_examples 'RedHat 6' |
819 | 740 |
|
820 | 741 | context 'with a custom apache_name parameter' do |
821 | 742 | let :params do |
|
900 | 821 | end |
901 | 822 | end |
902 | 823 | context 'with unsupported osfamily' do |
903 | | - let :facts do |
904 | | - { osfamily: 'Darwin', |
905 | | - operatingsystemrelease: '13.1.0', |
906 | | - is_pe: false } |
907 | | - end |
| 824 | + include_examples 'Darwin' |
908 | 825 |
|
909 | 826 | it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily}) } |
910 | 827 | end |
|
0 commit comments