Add basic tests for apache cookbook
authorTom Hughes <tom@compton.nu>
Wed, 26 Oct 2016 22:13:10 +0000 (23:13 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 27 Oct 2016 09:01:30 +0000 (10:01 +0100)
.kitchen.yml
cookbooks/apache/metadata.rb
test/data_bags/apache/admins.json [new file with mode: 0644]
test/data_bags/ssl/keys.json [new file with mode: 0644]
test/integration/apache-ssl/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/apache/serverspec/apache_spec.rb [new file with mode: 0644]

index e266712..12ffa49 100644 (file)
@@ -7,11 +7,18 @@ driver:
 
 provisioner:
   name: chef_zero
+  data_bags_path: test/data_bags
 
 platforms:
   - name: ubuntu-16.04
 
 suites:
+  - name: apache
+    run_list:
+      - recipe[apache::default]
+  - name: apache-ssl
+    run_list:
+      - recipe[apache::ssl]
   - name: apt
     run_list:
       - recipe[apt::default]
index 24c69d7..635f9cf 100644 (file)
@@ -5,4 +5,5 @@ license           "Apache 2.0"
 description       "Installs and configures apache"
 long_description  IO.read(File.join(File.dirname(__FILE__), "README.md"))
 version           "1.0.0"
+depends           "munin"
 depends           "ssl"
diff --git a/test/data_bags/apache/admins.json b/test/data_bags/apache/admins.json
new file mode 100644 (file)
index 0000000..20853a9
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "admins",
+  "hosts": [
+    "192.168.1.1"
+  ]
+}
diff --git a/test/data_bags/ssl/keys.json b/test/data_bags/ssl/keys.json
new file mode 100644 (file)
index 0000000..fdc5266
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "id": "keys",
+  "openstreetmap": [
+    "-----BEGIN RSA PRIVATE KEY-----",
+    "dummy",
+    "-----END RSA PRIVATE KEY-----"
+  ],
+  "tile.openstreetmap": [
+    "-----BEGIN RSA PRIVATE KEY-----",
+    "dummy",
+    "-----END RSA PRIVATE KEY-----"
+  ],
+  "osmfoundation": [
+    "-----BEGIN PRIVATE KEY-----",
+    "dummy",
+    "-----END PRIVATE KEY-----"
+  ]
+}
diff --git a/test/integration/apache-ssl/serverspec/apache_spec.rb b/test/integration/apache-ssl/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..9d52682
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening }
+end
+
+describe port(443) do
+  it { should be_listening }
+end
diff --git a/test/integration/apache/serverspec/apache_spec.rb b/test/integration/apache/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..57b0b7d
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening }
+end
+
+describe port(443) do
+  it { should_not be_listening }
+end