diff --git a/manifests/init.pp b/manifests/init.pp index e9d54bb..8e02308 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -593,6 +593,17 @@ class ssh ( if $ssh_config_include == 'USE_DEFAULTS' { $ssh_config_include_real = $default_ssh_config_include } else { + case type3x($ssh_config_include) { + 'array': { + validate_array($ssh_config_include) + } + 'string': { + validate_string($ssh_config_include) + } + default: { + fail('ssh::ssh_config_include type must be a strting or array.') + } + } $ssh_config_include_real = $ssh_config_include } @@ -668,6 +679,17 @@ class ssh ( if $sshd_config_include == 'USE_DEFAULTS' { $sshd_config_include_real = $default_sshd_config_include } else { + case type3x($sshd_config_include) { + 'array': { + validate_array($sshd_config_include) + } + 'string': { + validate_string($sshd_config_include) + } + default: { + fail('ssh::sshd_config_include type must be a strting or array.') + } + } $sshd_config_include_real = $sshd_config_include } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 6a9449f..a1c743f 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -2786,4 +2786,61 @@ describe 'sshd_config_print_last_log param' do end # var[:name].each end # validations.sort.each end # describe 'variable type and content validations' + + describe 'sshd_config_include' do + context 'when set to an array' do + let(:params) { {'sshd_config_include' => ['file1','file2'] } } + + it { should contain_file('sshd_config').with_content(/^Include file1 file2$/) } + end + + context 'when set to a string' do + let(:params) { {'sshd_config_include' => 'file1' } } + + it { should contain_file('sshd_config').with_content(/^Include file1$/) } + end + + context 'when not set' do + it { should_not contain_file('sshd_config').with_content(/^\s*Include/) } + end + + context 'when set to an invalid type (not string or array)' do + let(:params) { {'sshd_config_include' => true } } + + it 'should fail' do + expect { + should contain_class('ssh') + }.to raise_error(Puppet::Error) + end + end + end + + describe 'ssh_config_include' do + context 'when set to an array' do + let(:params) { {'ssh_config_include' => ['file1','file2'] } } + + it { should contain_file('ssh_config').with_content(/^Include file1 file2$/) } + end + + context 'when set to a string' do + let(:params) { {'ssh_config_include' => 'file1' } } + + it { should contain_file('ssh_config').with_content(/^Include file1$/) } + end + + context 'when not set' do + it { should_not contain_file('ssh_config').with_content(/^\s*Include/) } + end + + context 'when set to an invalid type (not string or array)' do + let(:params) { {'ssh_config_include' => true } } + + it 'should fail' do + expect { + should contain_class('ssh') + }.to raise_error(Puppet::Error) + end + end + end + end diff --git a/types/include.pp b/types/include.pp deleted file mode 100644 index f5b5f20..0000000 --- a/types/include.pp +++ /dev/null @@ -1,5 +0,0 @@ -# config files to be includes -# @summary -# directory of array of directories to be included -# -type Ssh::Include = Variant[String[1],Array[String[1]]]