Add basic tests for clamav, exim and spamassassin cookbooks
authorTom Hughes <tom@compton.nu>
Thu, 13 Feb 2020 22:39:44 +0000 (22:39 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 13 Feb 2020 22:39:44 +0000 (22:39 +0000)
.kitchen.yml
.travis.yml
cookbooks/clamav/recipes/default.rb
cookbooks/exim/metadata.rb
cookbooks/spamassassin/metadata.rb
test/integration/clamav/serverspec/clamav_spec.rb [new file with mode: 0644]
test/integration/exim/serverspec/exim_spec.rb [new file with mode: 0644]
test/integration/spamassassin/serverspec/spamassassin_spec.rb [new file with mode: 0644]

index d5132931b74e3de8525c76b583fa172768f002ba..0f9e0f7a1d348f93de2e834b3a51daa3217960eb 100644 (file)
@@ -42,6 +42,12 @@ suites:
     run_list:
       - recipe[accounts::default]
       - recipe[blogs::default]
+  - name: clamav
+    run_list:
+      - recipe[clamav::default]
+  - name: exim
+    run_list:
+      - recipe[exim::default]
   - name: forum
     run_list:
       - recipe[accounts::default]
@@ -78,6 +84,9 @@ suites:
   - name: python
     run_list:
       - recipe[python::default]
+  - name: spamassassin
+    run_list:
+      - recipe[spamassassin::default]
   - name: tools
     run_list:
       - recipe[tools::default]
index e5568cf8e71b11342bfc8c72c773e9033628b3ed..9cd34d6e05cb59feb29eaa9a64a183c86ca4c621 100644 (file)
@@ -23,6 +23,12 @@ jobs:
     - name: "Test Kitchen (blogs)"
       script:
         - bundle exec kitchen test blogs-ubuntu-1804
+    - name: "Test Kitchen (clamav)"
+      script:
+        - bundle exec kitchen test clamav-ubuntu-1804
+    - name: "Test Kitchen (exim)"
+      script:
+        - bundle exec kitchen test exim-ubuntu-1804
     - name: "Test Kitchen (forum)"
       script:
         - bundle exec kitchen test forum-ubuntu-1804
@@ -50,6 +56,9 @@ jobs:
     - name: "Test Kitchen (python)"
       script:
         - bundle exec kitchen test python-ubuntu-1804
+    - name: "Test Kitchen (spamassassin)"
+      script:
+        - bundle exec kitchen test spamassassin-ubuntu-1804
     - name: "Test Kitchen (tools)"
       script:
         - bundle exec kitchen test tools-ubuntu-1804
index 8e07f4fb76f23a8c597c4dd7f42f9134c0e388bf..3c95527ce3ea6bcf569b297a57ae3a8d9837c4f1 100644 (file)
@@ -30,6 +30,13 @@ template "/etc/clamav-unofficial-sigs.conf.d/50-chef.conf" do
   mode 0o644
 end
 
+execute "freshclam" do
+  command "/usr/bin/freshclam"
+  user "clamav"
+  group "clamav"
+  not_if { ::File.exist?("/var/lib/clamav/daily.cvd") }
+end
+
 service "clamav-daemon" do
   action [:enable, :start]
   supports :status => true, :restart => true
index 754ee82ded64e89f82675b5125278125a0150852..0c083b9916b1b40e1c07902cd3bc10bd1371ddb0 100644 (file)
@@ -6,6 +6,7 @@ description       "Installs and configures exim"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
+depends           "apache"
 depends           "networking"
 depends           "ssl"
-depends           "apache"
index 470463eafce467cb3d9a9dac59f8df88f0478a9d..acd564bf7a62c52d8cd0045f6de3ba96a7773007 100644 (file)
@@ -6,3 +6,4 @@ description       "Installs and configures spamassassin"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "exim"
diff --git a/test/integration/clamav/serverspec/clamav_spec.rb b/test/integration/clamav/serverspec/clamav_spec.rb
new file mode 100644 (file)
index 0000000..ce8687e
--- /dev/null
@@ -0,0 +1,22 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("clamav-daemon") do
+  it { should be_installed }
+end
+
+describe service("clamav-daemon") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe package("clamav-freshclam") do
+  it { should be_installed }
+end
+
+describe service("clamav-freshclam") do
+  it { should be_enabled }
+  it { should be_running }
+end
diff --git a/test/integration/exim/serverspec/exim_spec.rb b/test/integration/exim/serverspec/exim_spec.rb
new file mode 100644 (file)
index 0000000..752a58a
--- /dev/null
@@ -0,0 +1,17 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("exim4") do
+  it { should be_installed }
+end
+
+describe service("exim4") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(25) do
+  it { should be_listening }
+end
diff --git a/test/integration/spamassassin/serverspec/spamassassin_spec.rb b/test/integration/spamassassin/serverspec/spamassassin_spec.rb
new file mode 100644 (file)
index 0000000..2f2e643
--- /dev/null
@@ -0,0 +1,17 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("spamassassin") do
+  it { should be_installed }
+end
+
+describe service("spamassassin") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(783) do
+  it { should be_listening }
+end