diff 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
line wrap: on
line diff
--- a/modules/apache/spec/acceptance/default_mods_spec.rb	Sun Dec 22 09:41:45 2019 -0500
+++ b/modules/apache/spec/acceptance/default_mods_spec.rb	Sun Dec 22 14:43:29 2019 -0500
@@ -1,72 +1,68 @@
 require 'spec_helper_acceptance'
+require_relative './version.rb'
 
-case fact('osfamily')
-when 'RedHat'
-  mod_dir     = '/etc/httpd/conf.d'
-  servicename = 'httpd'
-when 'Debian'
-  mod_dir     = '/etc/apache2/mods-available'
-  servicename = 'apache2'
-when 'FreeBSD'
-  mod_dir     = '/usr/local/etc/apache24/Modules'
-  servicename = 'apache24'
-end
-
-describe 'apache::default_mods class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apache::default_mods class' do
   describe 'no default mods' do
     # Using puppet_apply as a helper
-    it 'should apply with no errors' do
-      pp = <<-EOS
+    let(:pp) do
+      <<-EOS
         class { 'apache':
           default_mods => false,
         }
       EOS
-
-      # Run it twice and test for idempotency
-      apply_manifest(pp, :catch_failures => true)
-      expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
     end
 
-    describe service(servicename) do
+    # Run it twice and test for idempotency
+    it_behaves_like "a idempotent resource"
+    describe service($service_name) do
       it { is_expected.to be_running }
     end
   end
 
-  describe 'no default mods and failing' do
-    # Using puppet_apply as a helper
-    it 'should apply with errors' do
-      pp = <<-EOS
-        class { 'apache':
-          default_mods => false,
-        }
-        apache::vhost { 'defaults.example.com':
-          docroot => '/var/www/defaults',
-          aliases => {
-            alias => '/css',
-            path  => '/var/www/css',
-          },
-          setenv  => 'TEST1 one',
-        }
-      EOS
+  unless (fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12')
+    describe 'no default mods and failing' do
+      before :all do
+        pp = <<-PP
+        include apache::params
+        class { 'apache': default_mods => false, service_ensure => stopped, }
+        PP
+        apply_manifest(pp)
+      end
+      # Using puppet_apply as a helper
+      it 'should apply with errors' do
+        pp = <<-EOS
+          class { 'apache':
+            default_mods => false,
+          }
+          apache::vhost { 'defaults.example.com':
+            docroot     => '#{$doc_root}/defaults',
+            aliases     => {
+              alias => '/css',
+              path  => '#{$doc_root}/css',
+            },
+            directories => [
+            {
+                'path'            => "#{$doc_root}/admin",
+                'auth_basic_fake' => 'demo demopass',
+              }
+            ],
+            setenv      => 'TEST1 one',
+          }
+        EOS
 
-      apply_manifest(pp, { :expect_failures => true })
-    end
+        apply_manifest(pp, { :expect_failures => true })
+      end
+  end
 
-    # Are these the same?
-    describe service(servicename) do
+    describe service($service_name) do
       it { is_expected.not_to be_running }
     end
-    describe "service #{servicename}" do
-      it 'should not be running' do
-        shell("pidof #{servicename}", {:acceptable_exit_codes => 1})
-      end
-    end
   end
 
   describe 'alternative default mods' do
     # Using puppet_apply as a helper
-    it 'should apply with no errors' do
-      pp = <<-EOS
+    let(:pp) do
+      <<-EOS
         class { 'apache':
           default_mods => [
             'info',
@@ -77,43 +73,38 @@
           ],
         }
         apache::vhost { 'defaults.example.com':
-          docroot => '/var/www/defaults',
+          docroot => '#{$doc_root}/defaults',
           aliases => {
             alias => '/css',
-            path  => '/var/www/css',
+            path  => '#{$doc_root}/css',
           },
           setenv  => 'TEST1 one',
         }
       EOS
+    end
+    it_behaves_like "a idempotent resource"
 
-      apply_manifest(pp, :catch_failures => true)
-      shell('sleep 10')
-      expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
-    end
-
-    describe service(servicename) do
+    describe service($service_name) do
       it { is_expected.to be_running }
     end
   end
 
   describe 'change loadfile name' do
-    it 'should apply with no errors' do
-      pp = <<-EOS
+    let(:pp) do
+      <<-EOS
         class { 'apache': default_mods => false }
-        ::apache::mod { 'auth_basic': 
+        ::apache::mod { 'auth_basic':
           loadfile_name => 'zz_auth_basic.load',
         }
       EOS
-      # Run it twice and test for idempotency
-      apply_manifest(pp, :catch_failures => true)
-      expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
     end
-
-    describe service(servicename) do
+    # Run it twice and test for idempotency
+    it_behaves_like "a idempotent resource"
+    describe service($service_name) do
       it { is_expected.to be_running }
     end
 
-    describe file("#{mod_dir}/zz_auth_basic.load") do
+    describe file("#{$mod_dir}/zz_auth_basic.load") do
       it { is_expected.to be_file }
     end
   end