test(requires): verify dependencies in vhosts

This commit is contained in:
Javier Bértoli 2021-04-28 10:56:22 -03:00
parent 622d22f971
commit 64781431b9
5 changed files with 43 additions and 0 deletions

View File

@ -309,9 +309,13 @@ verifier:
suites: suites:
- name: default - name: default
provisioner: provisioner:
dependencies:
- name: test_dep
path: test/salt/default/states
state_top: state_top:
base: base:
'*': '*':
- test_dep.create_dependency_file
- nginx._mapdata - nginx._mapdata
- nginx - nginx
pillars: pillars:

View File

@ -71,5 +71,16 @@ control 'Nginx configuration' do
its('content') { should include 'try_files $uri $uri/ =404;' } its('content') { should include 'try_files $uri $uri/ =404;' }
its('content') { should include 'include snippets/letsencrypt.conf;' } its('content') { should include 'include snippets/letsencrypt.conf;' }
end 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
end end

View File

@ -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

View File

@ -37,6 +37,19 @@ nginx:
- location ~ .htm: - location ~ .htm:
- try_files: '$uri $uri/ =404' - try_files: '$uri $uri/ =404'
- include: 'snippets/letsencrypt.conf' - 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: dh_param:
'mydhparam2.pem': 'mydhparam2.pem':
keysize: 2048 keysize: 2048

View File

@ -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