Skip to content

Commit 1de5714

Browse files
committed
Add tests for extra config options
Signed-off-by: Brian Dwyer <[email protected]>
1 parent e65f964 commit 1de5714

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

attributes/default.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
client['send_env'] = ['LANG', 'LC_*', 'LANGUAGE']
6767

6868
# extra client configuration options
69-
client['extras'].tap = {}
69+
client['extras'] = {}
7070
end
7171

7272
# sshd

spec/recipes/client_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,32 @@
191191
end
192192
end
193193

194+
describe 'extra configuration values' do
195+
context 'without custom extra config value' do
196+
cached(:chef_run) do
197+
ChefSpec::ServerRunner.new.converge(described_recipe)
198+
end
199+
200+
it 'does not have any extra config options' do
201+
expect(chef_run).to render_file('/etc/ssh/ssh_config').
202+
without_content(/^# Extra Configuration Options/)
203+
end
204+
end
205+
206+
context 'with custom extra config value' do
207+
cached(:chef_run) do
208+
ChefSpec::ServerRunner.new do |node|
209+
node.normal['ssh-hardening']['ssh']['client']['extras']['#ExtraConfig'] = 'Value'
210+
end.converge(described_recipe)
211+
end
212+
213+
it 'uses the extra config attributes' do
214+
expect(chef_run).to render_file('/etc/ssh/ssh_config').with_content(/^# Extra Configuration Options/)
215+
expect(chef_run).to render_file('/etc/ssh/ssh_config').with_content(/^#ExtraConfig Value/)
216+
end
217+
end
218+
end
219+
194220
context 'chef-solo' do
195221
cached(:chef_run) do
196222
ChefSpec::SoloRunner.new.converge(described_recipe)

spec/recipes/server_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,32 @@
403403
end
404404
end
405405

406+
describe 'extra configuration values' do
407+
context 'without custom extra config value' do
408+
cached(:chef_run) do
409+
ChefSpec::ServerRunner.new.converge(described_recipe)
410+
end
411+
412+
it 'does not have any extra config options' do
413+
expect(chef_run).to render_file('/etc/ssh/sshd_config').
414+
without_content(/^# Extra Configuration Options/)
415+
end
416+
end
417+
418+
context 'with custom extra config value' do
419+
cached(:chef_run) do
420+
ChefSpec::ServerRunner.new do |node|
421+
node.normal['ssh-hardening']['ssh']['server']['extras']['#ExtraConfig'] = 'Value'
422+
end.converge(described_recipe)
423+
end
424+
425+
it 'uses the extra config attributes' do
426+
expect(chef_run).to render_file('/etc/ssh/sshd_config').with_content(/^# Extra Configuration Options/)
427+
expect(chef_run).to render_file('/etc/ssh/sshd_config').with_content(/^#ExtraConfig Value/)
428+
end
429+
end
430+
end
431+
406432
it 'disables the challenge response authentication' do
407433
expect(chef_run).to render_file('/etc/ssh/sshd_config').
408434
with_content(/ChallengeResponseAuthentication no/)

0 commit comments

Comments
 (0)