diff --git a/manifests/init.pp b/manifests/init.pp index f7b35f8..ee8e668 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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) } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index ab766fc..339fe3b 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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