mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Merge pull request #919 from chef/vj/case-insens-ssh-conf
ssh_config parse should be case insensitive
This commit is contained in:
commit
cdfa8f720d
3 changed files with 17 additions and 2 deletions
|
@ -32,8 +32,16 @@ module Inspec::Resources
|
|||
end
|
||||
end
|
||||
|
||||
def convert_hash(hash)
|
||||
new_hash = {}
|
||||
hash.each do |k, v|
|
||||
new_hash[k.downcase] = v
|
||||
end
|
||||
new_hash
|
||||
end
|
||||
|
||||
def method_missing(name)
|
||||
param = read_params[name.to_s]
|
||||
param = read_params[name.to_s.downcase]
|
||||
return nil if param.nil?
|
||||
# extract first value if we have only one value in array
|
||||
return param[0] if param.length == 1
|
||||
|
@ -69,7 +77,7 @@ module Inspec::Resources
|
|||
assignment_re: /^\s*(\S+?)\s+(.*?)\s*$/,
|
||||
multiple_values: true,
|
||||
)
|
||||
@params = conf.params
|
||||
@params = convert_hash(conf.params)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ Host *
|
|||
# Tunnel no
|
||||
SendEnv LANG LC_*
|
||||
HashKnownHosts yes
|
||||
GSSAPIAuthentication no
|
||||
|
|
|
@ -15,6 +15,12 @@ describe 'Inspec::Resources::SshConf' do
|
|||
_(resource.SendEnv).must_equal 'LANG LC_*'
|
||||
_(resource.HashKnownHosts).must_equal 'yes'
|
||||
end
|
||||
|
||||
it 'is case insensitive' do
|
||||
resource = load_resource('ssh_config')
|
||||
_(resource.gssapiauthentication).must_equal 'no'
|
||||
_(resource.GSSAPIAuthentication).must_equal 'no'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sshd_config' do
|
||||
|
|
Loading…
Add table
Reference in a new issue