Clean up contributions and improve spec tests

This commit is contained in:
Garrett Honeycutt 2013-12-21 02:21:06 -05:00
parent 8ed84f7e18
commit 42efd6ebfc
4 changed files with 28 additions and 27 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ metadata.json
coverage/ coverage/
spec/fixtures/modules/* spec/fixtures/modules/*
Gemfile.lock Gemfile.lock
spec/fixtures/

View File

@ -136,25 +136,25 @@ Banner option in sshd_config.
sshd_banner_content sshd_banner_content
------------------- -------------------
Banner content in sshd_config_banner content parameter for file specified in sshd_config_banner
- *Default*: undef - *Default*: undef
sshd_banner_owner sshd_banner_owner
----------------- -----------------
sshd_config_banner owner owner parameter for file specified in sshd_config_banner
- *Default*: 'root' - *Default*: 'root'
sshd_banner_group sshd_banner_group
----------------- -----------------
sshd_config_banner group group parameter for file specified in sshd_config_banner
- *Default*: 'root' - *Default*: 'root'
sshd_banner_mode sshd_banner_mode
---------------- ----------------
sshd_config_banner mode mode parameter for file specified in sshd_config_banner
- *Default*: '0644' - *Default*: '0644'

View File

@ -50,18 +50,18 @@ class ssh (
) { ) {
# validate params # 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_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)$', "sshd_password_authentication may be either 'yes' or 'no' and is set to <${sshd_password_authentication}>.") 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)$', "sshd_allow_tcp_forwarding may be either 'yes' or 'no' and is set to <${sshd_allow_tcp_forwarding}>.") 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)$', "sshd_x11_forwarding may be either 'yes' or 'no' and is set to <${sshd_x11_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)$', "sshd_use_pam may be either 'yes' or 'no' and is set to <${sshd_use_pam}>.") 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("sshd_client_alive_interval must be an integer and is set to <${sshd_client_alive_interval}>.") } 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' { if $sshd_config_banner != 'none' {
validate_absolute_path($sshd_config_banner) validate_absolute_path($sshd_config_banner)
} }
if $sshd_banner_content != undef and $sshd_config_banner == 'none' { 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) { case type($ssh_config_sendenv_xmodifiers) {
@ -72,7 +72,7 @@ class ssh (
$ssh_config_sendenv_xmodifiers_real = $ssh_config_sendenv_xmodifiers $ssh_config_sendenv_xmodifiers_real = $ssh_config_sendenv_xmodifiers
} }
default: { 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 # noop
} }
default: { 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 $key = $::sshdsakey
} }
default: { 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 # noop
} }
default: { 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' : file { 'sshd_banner' :
ensure => file, ensure => file,
path => $sshd_config_banner, path => $sshd_config_banner,
mode => $sshd_banner_mode,
owner => $sshd_banner_owner, owner => $sshd_banner_owner,
group => $sshd_banner_group, group => $sshd_banner_group,
mode => $sshd_banner_mode,
content => $sshd_banner_content, content => $sshd_banner_content,
require => Package['ssh_packages'], require => Package['ssh_packages'],
} }
@ -223,7 +223,7 @@ class ssh (
# noop # noop
} }
default: { 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\'.")
} }
} }

View File

@ -356,7 +356,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/ssh supports osfamilies RedHat, Suse and Debian. Detected osfamily is <C64>./) }.to raise_error(Puppet::Error,/^ssh supports osfamilies RedHat, Suse and Debian. Detected osfamily is <C64>\./)
end end
end end
@ -525,7 +525,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') 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
end end
@ -545,7 +545,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/manage_root_ssh_config is <invalid> and must be \'true\' or \'false\'./) }.to raise_error(Puppet::Error,/^ssh::manage_root_ssh_config is <invalid> and must be \'true\' or \'false\'\./)
end end
end end
@ -564,7 +564,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/sshd_password_authentication may be either \'yes\' or \'no\' and is set to <invalid>./) }.to raise_error(Puppet::Error,/^ssh::sshd_password_authentication may be either \'yes\' or \'no\' and is set to <invalid>\./)
end end
end end
@ -583,7 +583,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/sshd_allow_tcp_forwarding may be either \'yes\' or \'no\' and is set to <invalid>./) }.to raise_error(Puppet::Error,/^ssh::sshd_allow_tcp_forwarding may be either \'yes\' or \'no\' and is set to <invalid>\./)
end end
end end
@ -602,7 +602,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/sshd_x11_forwarding may be either \'yes\' or \'no\' and is set to <invalid>./) }.to raise_error(Puppet::Error,/^ssh::sshd_x11_forwarding may be either \'yes\' or \'no\' and is set to <invalid>\./)
end end
end end
@ -621,7 +621,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/sshd_use_pam may be either \'yes\' or \'no\' and is set to <invalid>./) }.to raise_error(Puppet::Error,/^ssh::sshd_use_pam may be either \'yes\' or \'no\' and is set to <invalid>\./)
end end
end end
@ -640,7 +640,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') should contain_class('ssh')
}.to raise_error(Puppet::Error,/sshd_client_alive_interval must be an integer and is set to <invalid>./) }.to raise_error(Puppet::Error,/^ssh::sshd_client_alive_interval must be an integer and is set to <invalid>\./)
end end
end end
@ -680,7 +680,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') 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
end end
@ -700,7 +700,7 @@ describe 'ssh' do
it 'should fail' do it 'should fail' do
expect { expect {
should contain_class('ssh') 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
end end