From 64781431b9187d392f56ce5461c3b1a9c2944f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Wed, 28 Apr 2021 10:56:22 -0300 Subject: [PATCH] test(requires): verify dependencies in vhosts --- kitchen.yml | 4 ++++ test/integration/default/controls/config.rb | 11 +++++++++++ test/integration/default/controls/file.rb | 9 +++++++++ test/salt/default/pillar/nginx.sls | 13 +++++++++++++ .../states/test_dep/create_dependency_file.sls | 6 ++++++ 5 files changed, 43 insertions(+) create mode 100644 test/integration/default/controls/file.rb create mode 100644 test/salt/default/states/test_dep/create_dependency_file.sls diff --git a/kitchen.yml b/kitchen.yml index b505c9b..db344af 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -309,9 +309,13 @@ verifier: suites: - name: default provisioner: + dependencies: + - name: test_dep + path: test/salt/default/states state_top: base: '*': + - test_dep.create_dependency_file - nginx._mapdata - nginx pillars: diff --git a/test/integration/default/controls/config.rb b/test/integration/default/controls/config.rb index 6d7c999..c2845eb 100644 --- a/test/integration/default/controls/config.rb +++ b/test/integration/default/controls/config.rb @@ -71,5 +71,16 @@ control 'Nginx configuration' do its('content') { should include 'try_files $uri $uri/ =404;' } its('content') { should include 'include snippets/letsencrypt.conf;' } end + describe file "#{dir}/mysite_with_require" do + it { should be_file } + it { should be_owned_by file_owner } + it { should be_grouped_into file_group } + its('mode') { should cmp '0644' } + its('content') { should include 'server_name with-deps;' } + its('content') { should include 'listen 80;' } + its('content') { should include 'index index.html index.htm;' } + its('content') { should include 'location ~ .htm {' } + its('content') { should include 'try_files $uri $uri/ =404;' } + end end end diff --git a/test/integration/default/controls/file.rb b/test/integration/default/controls/file.rb new file mode 100644 index 0000000..57151af --- /dev/null +++ b/test/integration/default/controls/file.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +control 'Dependency test file' do + title 'should exist' + + describe file('/tmp/created_to_test_dependencies') do + it { should be_file } + end +end diff --git a/test/salt/default/pillar/nginx.sls b/test/salt/default/pillar/nginx.sls index ef6ccfa..84afe98 100644 --- a/test/salt/default/pillar/nginx.sls +++ b/test/salt/default/pillar/nginx.sls @@ -37,6 +37,19 @@ nginx: - location ~ .htm: - try_files: '$uri $uri/ =404' - include: 'snippets/letsencrypt.conf' + mysite_with_require: + enabled: true + config: + - server: + - server_name: with-deps + - listen: + - '80' + - index: 'index.html index.htm' + - location ~ .htm: + - try_files: '$uri $uri/ =404' + requires: + file: created_to_test_dependencies + dh_param: 'mydhparam2.pem': keysize: 2048 diff --git a/test/salt/default/states/test_dep/create_dependency_file.sls b/test/salt/default/states/test_dep/create_dependency_file.sls new file mode 100644 index 0000000..e242927 --- /dev/null +++ b/test/salt/default/states/test_dep/create_dependency_file.sls @@ -0,0 +1,6 @@ +## this state creates a file that is used to test vhosts dependencies +# (see https://github.com/saltstack-formulas/nginx-formula/pull/278) + +created_to_test_dependencies: + file.managed: + - name: /tmp/created_to_test_dependencies