]> git.openstreetmap.org Git - chef.git/commitdiff
Add test for mail role
authorTom Hughes <tom@compton.nu>
Sun, 1 Mar 2020 16:40:07 +0000 (16:40 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 1 Mar 2020 16:40:07 +0000 (16:40 +0000)
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/exim/recipes/default.rb
roles/mail.rb
test/data_bags/exim/aliases.json [new file with mode: 0644]
test/data_bags/exim/dkim.json [new file with mode: 0644]
test/integration/mail/serverspec/clamav_spec.rb [new file with mode: 0644]
test/integration/mail/serverspec/exim_spec.rb [new file with mode: 0644]
test/integration/mail/serverspec/spamassassin_spec.rb [new file with mode: 0644]

index e15ed4eac7e511870c44d2cab167e336cf2849ee..613addabd8e243c9f0a693e43f7010a8a3899edd 100644 (file)
@@ -44,6 +44,7 @@ jobs:
           - letsencrypt
           - logstash
           - logstash-forwarder
+          - mail
           - mailman
           - memcached
           - munin
index e63b8b85518685c6f79f9c1f1e1b9745ea55f23c..c116e2411ab8597fe899871e1d1e14372ed7cef2 100644 (file)
@@ -165,6 +165,9 @@ suites:
               paths:
                 - /var/log/apache2/access.log
               type: apache
+  - name: mail
+    run_list:
+      - role[mail]
   - name: mailman
     run_list:
       - recipe[mailman::default]
index 6af07c8e1114de61398c7ad5b56bf014d0495f08..9266425e3a64c319948fb9a4d0337fa4db345239 100644 (file)
@@ -26,7 +26,9 @@ package %w[
   ssl-cert
 ]
 
-package "exim4-daemon-heavy" if File.exist?("/var/run/clamav/clamd.ctl")
+package "exim4-daemon-heavy" do
+  only_if { ::File.exist?("/var/run/clamav/clamd.ctl") }
+end
 
 group "ssl-cert" do
   action :modify
index 99fcf1a08fbc90d224f125c05a5e531eee90c529..c1c7d307cea2b959d99f05434efba5984859ba88 100644 (file)
@@ -91,5 +91,6 @@ default_attributes(
 
 run_list(
   "recipe[clamav]",
+  "recipe[exim]",
   "recipe[spamassassin]"
 )
diff --git a/test/data_bags/exim/aliases.json b/test/data_bags/exim/aliases.json
new file mode 100644 (file)
index 0000000..7003ab2
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "aliases",
+  "mail": {
+    "test": "test@example.com"
+  }
+}
diff --git a/test/data_bags/exim/dkim.json b/test/data_bags/exim/dkim.json
new file mode 100644 (file)
index 0000000..0a20d50
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "id": "dkim",
+  "openstreetmap.org": [
+    "-----BEGIN RSA PRIVATE KEY-----",
+    "-----END RSA PRIVATE KEY-----"
+  ]
+}
diff --git a/test/integration/mail/serverspec/clamav_spec.rb b/test/integration/mail/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/mail/serverspec/exim_spec.rb b/test/integration/mail/serverspec/exim_spec.rb
new file mode 100644 (file)
index 0000000..2a6f6b2
--- /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.with("tcp") }
+end
diff --git a/test/integration/mail/serverspec/spamassassin_spec.rb b/test/integration/mail/serverspec/spamassassin_spec.rb
new file mode 100644 (file)
index 0000000..1276f14
--- /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.with("tcp") }
+end