Browse Source

Merge pull request #185 from baby-gnu/feature/test-known_hosts

test(config_spec): verify the generation of /etc/ssh/ssh_known_hosts
tags/v1.2.1
Imran Iqbal 4 years ago
parent
commit
9c8b77ca24
No account linked to committer's email address
4 changed files with 18 additions and 2 deletions
  1. +1
    -0
      kitchen.yml
  2. +0
    -1
      openssh/known_hosts.sls
  3. +1
    -1
      openssh/osfamilymap.yaml
  4. +16
    -0
      test/integration/default/controls/config_spec.rb

+ 1
- 0
kitchen.yml View File

base: base:
'*': '*':
- openssh.config - openssh.config
- openssh.known_hosts
pillars: pillars:
top.sls: top.sls:
base: base:

+ 0
- 1
openssh/known_hosts.sls View File

ensure dig is available: ensure dig is available:
pkg.installed: pkg.installed:
- name: {{ openssh.dig_pkg }} - name: {{ openssh.dig_pkg }}
- unless: which dig


manage ssh_known_hosts file: manage ssh_known_hosts file:
file.managed: file.managed:

+ 1
- 1
openssh/osfamilymap.yaml View File

server: openssh server: openssh
client: openssh client: openssh
service: sshd service: sshd
dig_pkg: bind-tools
dig_pkg: bind
sshd_config: sshd_config:
Subsystem: sftp /usr/lib/ssh/sftp-server Subsystem: sftp /usr/lib/ssh/sftp-server



+ 16
- 0
test/integration/default/controls/config_spec.rb View File

'root' 'root'
end end


github_known_host = 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGm[...]'
gitlab_known_host_re = /gitlab.com,[0-9a-f.:,]* ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA/
minion_rsa_known_host = 'minion.id,alias.of.minion.id ssh-rsa [...]'
minion_ed25519_known_host = 'minion.id,alias.of.minion.id ssh-ed25519 [...]'

control 'openssh configuration' do control 'openssh configuration' do
title 'should match desired lines' title 'should match desired lines'


its('content') { should include ' HashKnownHosts yes' } its('content') { should include ' HashKnownHosts yes' }
its('content') { should include ' SendEnv LANG LC_*' } its('content') { should include ' SendEnv LANG LC_*' }
end end

describe file('/etc/ssh/ssh_known_hosts') do
it { should be_file }
its('mode') { should cmp '0644' }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('content') { should include github_known_host }
its('content') { should match(gitlab_known_host_re) }
its('content') { should include minion_rsa_known_host }
its('content') { should include minion_ed25519_known_host }
end
end end

Loading…
Cancel
Save