From 679f59947ae0b34f56598c9f4c1232a833237d51 Mon Sep 17 00:00:00 2001
From: Tom Hughes <tom@compton.nu>
Date: Tue, 18 Feb 2020 00:18:59 +0000
Subject: [PATCH 1/1] Add test for blog cookbook

---
 .kitchen.yml                                  |  3 +++
 cookbooks/wordpress/metadata.rb               |  3 +++
 cookbooks/wordpress/recipes/default.rb        |  3 +++
 test/data_bags/accounts/wordpress.json        |  5 +++++
 test/data_bags/blog/passwords.json            |  4 ++++
 .../blog/serverspec/apache_spec.rb            | 21 +++++++++++++++++++
 6 files changed, 39 insertions(+)
 create mode 100644 test/data_bags/accounts/wordpress.json
 create mode 100644 test/data_bags/blog/passwords.json
 create mode 100644 test/integration/blog/serverspec/apache_spec.rb

diff --git a/.kitchen.yml b/.kitchen.yml
index 13b3d46a3..879ca82af 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -38,6 +38,9 @@ suites:
     attributes:
       bind:
         clients: none
+  - name: blog
+    run_list:
+      - recipe[blog::default]
   - name: blogs
     run_list:
       - recipe[blogs::default]
diff --git a/cookbooks/wordpress/metadata.rb b/cookbooks/wordpress/metadata.rb
index 6aaf82745..3ef2a0c9b 100644
--- a/cookbooks/wordpress/metadata.rb
+++ b/cookbooks/wordpress/metadata.rb
@@ -6,8 +6,11 @@ description       "Installs and configures Wordpress"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
 depends           "apache"
 depends           "chef"
+depends           "fail2ban"
+depends           "git"
 depends           "mysql"
 depends           "ssl"
 gem               "httpclient"
diff --git a/cookbooks/wordpress/recipes/default.rb b/cookbooks/wordpress/recipes/default.rb
index 52c544db5..2ca2b240b 100644
--- a/cookbooks/wordpress/recipes/default.rb
+++ b/cookbooks/wordpress/recipes/default.rb
@@ -17,7 +17,10 @@
 # limitations under the License.
 #
 
+include_recipe "accounts"
 include_recipe "apache"
+include_recipe "fail2ban"
+include_recipe "git"
 include_recipe "mysql"
 
 package %w[
diff --git a/test/data_bags/accounts/wordpress.json b/test/data_bags/accounts/wordpress.json
new file mode 100644
index 000000000..a0815197a
--- /dev/null
+++ b/test/data_bags/accounts/wordpress.json
@@ -0,0 +1,5 @@
+{
+  "id": "wordpress",
+  "uid": "516",
+  "comment": "Wordpress"
+}
diff --git a/test/data_bags/blog/passwords.json b/test/data_bags/blog/passwords.json
new file mode 100644
index 000000000..7db48607c
--- /dev/null
+++ b/test/data_bags/blog/passwords.json
@@ -0,0 +1,4 @@
+{
+  "id": "passwords",
+  "osm-blog-user": "osm-blog-password"
+}
diff --git a/test/integration/blog/serverspec/apache_spec.rb b/test/integration/blog/serverspec/apache_spec.rb
new file mode 100644
index 000000000..446d3b915
--- /dev/null
+++ b/test/integration/blog/serverspec/apache_spec.rb
@@ -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.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
-- 
2.39.5