Validate keys parameter

Ensure that keys is a hash
This commit is contained in:
Garrett Honeycutt 2013-11-14 17:57:47 -05:00
parent 285cafe130
commit 359a041582
2 changed files with 13 additions and 4 deletions

View File

@ -239,9 +239,7 @@ class ssh (
# manage users' ssh authorized keys if present
if $keys != undef {
$keys_type = type($keys)
if $keys_type == 'hash' {
create_resources(ssh_authorized_key, $keys)
}
validate_hash($keys)
create_resources(ssh_authorized_key, $keys)
}
}

View File

@ -710,4 +710,15 @@ describe 'ssh' do
})
}
end
context 'with keys specified as not of type hash' do
let(:params) { { :keys => [ 'not', 'a', 'hash' ] } }
let(:facts) { { :osfamily => 'RedHat' } }
it 'should fail' do
expect {
should include_class('ssh')
}.to raise_error(Puppet::Error)
end
end
end