From 42efd6ebfcc42eb8067e9e082fae9c2cd23f79ed Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Sat, 21 Dec 2013 02:21:06 -0500 Subject: [PATCH] Clean up contributions and improve spec tests --- .gitignore | 1 + README.md | 8 ++++---- manifests/init.pp | 26 +++++++++++++------------- spec/classes/init_spec.rb | 20 ++++++++++---------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 4bc8945..2e7f696 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ metadata.json coverage/ spec/fixtures/modules/* Gemfile.lock +spec/fixtures/ diff --git a/README.md b/README.md index 8ecb836..b0fe70c 100644 --- a/README.md +++ b/README.md @@ -136,25 +136,25 @@ Banner option in sshd_config. sshd_banner_content ------------------- -Banner content in sshd_config_banner +content parameter for file specified in sshd_config_banner - *Default*: undef sshd_banner_owner ----------------- -sshd_config_banner owner +owner parameter for file specified in sshd_config_banner - *Default*: 'root' sshd_banner_group ----------------- -sshd_config_banner group +group parameter for file specified in sshd_config_banner - *Default*: 'root' sshd_banner_mode ---------------- -sshd_config_banner mode +mode parameter for file specified in sshd_config_banner - *Default*: '0644' diff --git a/manifests/init.pp b/manifests/init.pp index e471539..fa40f78 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -50,18 +50,18 @@ class ssh ( ) { # validate params - validate_re($sshd_config_port, '^\d+$', "sshd_config_port must be a valid number and is set to <${sshd_config_port}>") - validate_re($sshd_password_authentication, '^(yes|no)$', "sshd_password_authentication may be either 'yes' or 'no' and is set to <${sshd_password_authentication}>.") - validate_re($sshd_allow_tcp_forwarding, '^(yes|no)$', "sshd_allow_tcp_forwarding may be either 'yes' or 'no' and is set to <${sshd_allow_tcp_forwarding}>.") - validate_re($sshd_x11_forwarding, '^(yes|no)$', "sshd_x11_forwarding may be either 'yes' or 'no' and is set to <${sshd_x11_forwarding}>.") - validate_re($sshd_use_pam, '^(yes|no)$', "sshd_use_pam may be either 'yes' or 'no' and is set to <${sshd_use_pam}>.") - if is_integer($sshd_client_alive_interval) == false { fail("sshd_client_alive_interval must be an integer and is set to <${sshd_client_alive_interval}>.") } + validate_re($sshd_config_port, '^\d+$', "ssh::sshd_config_port must be a valid number and is set to <${sshd_config_port}>.") + validate_re($sshd_password_authentication, '^(yes|no)$', "ssh::sshd_password_authentication may be either 'yes' or 'no' and is set to <${sshd_password_authentication}>.") + validate_re($sshd_allow_tcp_forwarding, '^(yes|no)$', "ssh::sshd_allow_tcp_forwarding may be either 'yes' or 'no' and is set to <${sshd_allow_tcp_forwarding}>.") + validate_re($sshd_x11_forwarding, '^(yes|no)$', "ssh::sshd_x11_forwarding may be either 'yes' or 'no' and is set to <${sshd_x11_forwarding}>.") + validate_re($sshd_use_pam, '^(yes|no)$', "ssh::sshd_use_pam may be either 'yes' or 'no' and is set to <${sshd_use_pam}>.") + if is_integer($sshd_client_alive_interval) == false { fail("ssh::sshd_client_alive_interval must be an integer and is set to <${sshd_client_alive_interval}>.") } if $sshd_config_banner != 'none' { validate_absolute_path($sshd_config_banner) } if $sshd_banner_content != undef and $sshd_config_banner == 'none' { - fail("sshd_config_banner must be set to be able to use sshd_banner_content") + fail("ssh::sshd_config_banner must be set to be able to use sshd_banner_content.") } case type($ssh_config_sendenv_xmodifiers) { @@ -72,7 +72,7 @@ class ssh ( $ssh_config_sendenv_xmodifiers_real = $ssh_config_sendenv_xmodifiers } default: { - fail("ssh_config_sendenv_xmodifiers type must be true or false.") + fail("ssh::ssh_config_sendenv_xmodifiers type must be true or false.") } } @@ -81,7 +81,7 @@ class ssh ( # noop } default: { - fail("permit_root_login may be either 'yes', 'without-password', 'forced-commands-only' or 'no' and is set to <${permit_root_login}>") + fail("ssh::permit_root_login may be either 'yes', 'without-password', 'forced-commands-only' or 'no' and is set to <${permit_root_login}>.") } } @@ -93,7 +93,7 @@ class ssh ( $key = $::sshdsakey } default: { - fail("ssh_key_type must be 'ssh-rsa', 'rsa', 'ssh-dsa', or 'dsa' and is <${ssh_key_type}>") + fail("ssh::ssh_key_type must be 'ssh-rsa', 'rsa', 'ssh-dsa', or 'dsa' and is <${ssh_key_type}>.") } } @@ -102,7 +102,7 @@ class ssh ( # noop } default: { - fail("purge_keys must be 'true' or 'false' and is <${purge_keys}>") + fail("ssh::purge_keys must be 'true' or 'false' and is <${purge_keys}>.") } } @@ -186,9 +186,9 @@ class ssh ( file { 'sshd_banner' : ensure => file, path => $sshd_config_banner, - mode => $sshd_banner_mode, owner => $sshd_banner_owner, group => $sshd_banner_group, + mode => $sshd_banner_mode, content => $sshd_banner_content, require => Package['ssh_packages'], } @@ -223,7 +223,7 @@ class ssh ( # noop } default: { - fail("manage_root_ssh_config is <${manage_root_ssh_config}> and must be \'true\' or \'false\'.") + fail("ssh::manage_root_ssh_config is <${manage_root_ssh_config}> and must be \'true\' or \'false\'.") } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 08446b0..c4393b0 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -356,7 +356,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/ssh supports osfamilies RedHat, Suse and Debian. Detected osfamily is ./) + }.to raise_error(Puppet::Error,/^ssh supports osfamilies RedHat, Suse and Debian. Detected osfamily is \./) end end @@ -525,7 +525,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_config_port must be a valid number and is set to <22invalid>./) + }.to raise_error(Puppet::Error,/^ssh::sshd_config_port must be a valid number and is set to <22invalid>\./) end end @@ -545,7 +545,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/manage_root_ssh_config is and must be \'true\' or \'false\'./) + }.to raise_error(Puppet::Error,/^ssh::manage_root_ssh_config is and must be \'true\' or \'false\'\./) end end @@ -564,7 +564,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_password_authentication may be either \'yes\' or \'no\' and is set to ./) + }.to raise_error(Puppet::Error,/^ssh::sshd_password_authentication may be either \'yes\' or \'no\' and is set to \./) end end @@ -583,7 +583,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_allow_tcp_forwarding may be either \'yes\' or \'no\' and is set to ./) + }.to raise_error(Puppet::Error,/^ssh::sshd_allow_tcp_forwarding may be either \'yes\' or \'no\' and is set to \./) end end @@ -602,7 +602,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_x11_forwarding may be either \'yes\' or \'no\' and is set to ./) + }.to raise_error(Puppet::Error,/^ssh::sshd_x11_forwarding may be either \'yes\' or \'no\' and is set to \./) end end @@ -621,7 +621,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_use_pam may be either \'yes\' or \'no\' and is set to ./) + }.to raise_error(Puppet::Error,/^ssh::sshd_use_pam may be either \'yes\' or \'no\' and is set to \./) end end @@ -640,7 +640,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_client_alive_interval must be an integer and is set to ./) + }.to raise_error(Puppet::Error,/^ssh::sshd_client_alive_interval must be an integer and is set to \./) end end @@ -680,7 +680,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/sshd_config_banner must be set to be able to use sshd_banner_content/) + }.to raise_error(Puppet::Error,/^ssh::sshd_config_banner must be set to be able to use sshd_banner_content\./) end end @@ -700,7 +700,7 @@ describe 'ssh' do it 'should fail' do expect { should contain_class('ssh') - }.to raise_error(Puppet::Error,/ssh_config_sendenv_xmodifiers type must be true or false./) + }.to raise_error(Puppet::Error,/^ssh::ssh_config_sendenv_xmodifiers type must be true or false\./) end end