]> git.openstreetmap.org Git - chef.git/commitdiff
Add tests for git cookbook
authorTom Hughes <tom@compton.nu>
Sun, 23 Feb 2020 22:42:49 +0000 (22:42 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 23 Feb 2020 22:45:24 +0000 (22:45 +0000)
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/git/attributes/default.rb
cookbooks/git/metadata.rb
cookbooks/git/recipes/server.rb
cookbooks/git/templates/default/apache.erb
roles/sarel.rb
test/data_bags/accounts/git.json [new file with mode: 0644]
test/integration/git-web/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/git-web/serverspec/gitweb_spec.rb [new file with mode: 0644]
test/integration/git/serverspec/git_spec.rb [new file with mode: 0644]

index 086850543af6254278d6af20ca00dbf4e1626dee..1c83e25f4423e4a476f04051f13f574b090e5e37 100644 (file)
@@ -32,6 +32,9 @@ jobs:
           - ftp
           - geodns
           - geoipupdate
           - ftp
           - geodns
           - geoipupdate
+          - git
+          - git-server
+          - git-web
           - gps-tile
           - hardware
           - incron
           - gps-tile
           - hardware
           - incron
index c136565f1255241d5804b6d16e5be5d1aa2c4f01..8414198bb327c14e91e830d4ccc63449eabe8724 100644 (file)
@@ -117,6 +117,15 @@ suites:
   - name: geoipupdate
     run_list:
       - recipe[geoipupdate::default]
   - name: geoipupdate
     run_list:
       - recipe[geoipupdate::default]
+  - name: git
+    run_list:
+      - recipe[git::default]
+  - name: git-server
+    run_list:
+      - recipe[git::server]
+  - name: git-web
+    run_list:
+      - recipe[git::web]
   - name: gps-tile
     run_list:
       - recipe[gps-tile::default]
   - name: gps-tile
     run_list:
       - recipe[gps-tile::default]
index 2d89a83de9e5c9765075b1169fd1a9a43c052eba..fd641f37a5b3472ec441a8acdde217a552883f14 100644 (file)
@@ -1,5 +1,7 @@
+default[:git][:host] = "git.openstreetmap.org"
 default[:git][:directory] = "/var/lib/git"
 default[:git][:public_user] = "git"
 default[:git][:public_group] = "git"
 default[:git][:private_user] = "git"
 default[:git][:private_group] = "git"
 default[:git][:directory] = "/var/lib/git"
 default[:git][:public_user] = "git"
 default[:git][:public_group] = "git"
 default[:git][:private_user] = "git"
 default[:git][:private_group] = "git"
+default[:git][:private_nodes] = "fqdn:*"
index 003590d110f9e817758578e5b8094e2223aec4c6..19f53944f1871e1d42bc67489f17839eddd720e3 100644 (file)
@@ -6,5 +6,6 @@ description       "Installs and configures git"
 
 version           "1.0.0"
 supports          "ubuntu"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
 depends           "apache"
 depends           "networking"
 depends           "apache"
 depends           "networking"
index 4a98818e32880ce109eb561317d83a52f5040511..78c1b828afa06fc2b9c8b84b70c45902e89591c3 100644 (file)
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
+node.default[:accounts][:users][:git][:status] = :role
+
+include_recipe "accounts"
 include_recipe "networking"
 
 git_directory = node[:git][:directory]
 include_recipe "networking"
 
 git_directory = node[:git][:directory]
index 39a68012021f4da01ed44351dd409f0cdd532f76..67dc1913bd2f6b850d72c3f4918c58f7190a6d1c 100644 (file)
         <Location />
                   Require all granted
         </Location>
         <Location />
                   Require all granted
         </Location>
+<% unless @private_allowed.empty? -%>
 
         <Location /private>
                   Require ip <%= @private_allowed.sort.join(" ") %>
         </Location>
 
         <Location /private>
                   Require ip <%= @private_allowed.sort.join(" ") %>
         </Location>
+<% end -%>
 
         <Location /private/chef.git>
                   Require all denied
 
         <Location /private/chef.git>
                   Require all denied
index 647aa57c5e7a0f963c092729d2b426a6f6267dcc..e3f550d9cbf59ce044b4e1af41f8fe5b3f004661 100644 (file)
@@ -4,8 +4,7 @@ description "Master role applied to sarel"
 default_attributes(
   :git => {
     :private_user => "chefrepo",
 default_attributes(
   :git => {
     :private_user => "chefrepo",
-    :private_group => "chefrepo",
-    :private_nodes => "fqdn:*"
+    :private_group => "chefrepo"
   },
   :networking => {
     :interfaces => {
   },
   :networking => {
     :interfaces => {
diff --git a/test/data_bags/accounts/git.json b/test/data_bags/accounts/git.json
new file mode 100644 (file)
index 0000000..1938a3f
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "id": "git",
+  "uid": "508",
+  "comment": "git.openstreetmap.org",
+  "home": "/var/lib/git"
+}
diff --git a/test/integration/git-web/serverspec/apache_spec.rb b/test/integration/git-web/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /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.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/git-web/serverspec/gitweb_spec.rb b/test/integration/git-web/serverspec/gitweb_spec.rb
new file mode 100644 (file)
index 0000000..3818bea
--- /dev/null
@@ -0,0 +1,8 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("gitweb") do
+  it { should be_installed }
+end
diff --git a/test/integration/git/serverspec/git_spec.rb b/test/integration/git/serverspec/git_spec.rb
new file mode 100644 (file)
index 0000000..b34c37d
--- /dev/null
@@ -0,0 +1,8 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("git") do
+  it { should be_installed }
+end