Skip to content

Commit 6478143

Browse files
committed
test(requires): verify dependencies in vhosts
1 parent 622d22f commit 6478143

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

kitchen.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,13 @@ verifier:
309309
suites:
310310
- name: default
311311
provisioner:
312+
dependencies:
313+
- name: test_dep
314+
path: test/salt/default/states
312315
state_top:
313316
base:
314317
'*':
318+
- test_dep.create_dependency_file
315319
- nginx._mapdata
316320
- nginx
317321
pillars:

test/integration/default/controls/config.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,16 @@
7171
its('content') { should include 'try_files $uri $uri/ =404;' }
7272
its('content') { should include 'include snippets/letsencrypt.conf;' }
7373
end
74+
describe file "#{dir}/mysite_with_require" do
75+
it { should be_file }
76+
it { should be_owned_by file_owner }
77+
it { should be_grouped_into file_group }
78+
its('mode') { should cmp '0644' }
79+
its('content') { should include 'server_name with-deps;' }
80+
its('content') { should include 'listen 80;' }
81+
its('content') { should include 'index index.html index.htm;' }
82+
its('content') { should include 'location ~ .htm {' }
83+
its('content') { should include 'try_files $uri $uri/ =404;' }
84+
end
7485
end
7586
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
control 'Dependency test file' do
4+
title 'should exist'
5+
6+
describe file('/tmp/created_to_test_dependencies') do
7+
it { should be_file }
8+
end
9+
end

test/salt/default/pillar/nginx.sls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ nginx:
3737
- location ~ .htm:
3838
- try_files: '$uri $uri/ =404'
3939
- include: 'snippets/letsencrypt.conf'
40+
mysite_with_require:
41+
enabled: true
42+
config:
43+
- server:
44+
- server_name: with-deps
45+
- listen:
46+
- '80'
47+
- index: 'index.html index.htm'
48+
- location ~ .htm:
49+
- try_files: '$uri $uri/ =404'
50+
requires:
51+
file: created_to_test_dependencies
52+
4053
dh_param:
4154
'mydhparam2.pem':
4255
keysize: 2048
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## this state creates a file that is used to test vhosts dependencies
2+
# (see https://github.com/saltstack-formulas/nginx-formula/pull/278)
3+
4+
created_to_test_dependencies:
5+
file.managed:
6+
- name: /tmp/created_to_test_dependencies

0 commit comments

Comments
 (0)