2014-01-26 09:36:35 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'sshd' do
|
|
|
|
|
|
|
|
shared_examples "a Linux OS" do
|
|
|
|
it { should compile.with_all_deps }
|
|
|
|
it { should contain_class('sshd') }
|
|
|
|
it { should contain_class('sshd::client') }
|
2014-01-26 11:19:11 +01:00
|
|
|
|
2014-01-26 11:25:11 +01:00
|
|
|
it { should contain_service('sshd').with({
|
2014-01-26 11:19:11 +01:00
|
|
|
:ensure => 'running',
|
|
|
|
:enable => true,
|
2014-01-26 11:25:11 +01:00
|
|
|
:hasstatus => true
|
|
|
|
})}
|
2014-01-26 11:19:11 +01:00
|
|
|
|
|
|
|
it { should contain_file('sshd_config').with(
|
|
|
|
{
|
|
|
|
'ensure' => 'present',
|
|
|
|
'owner' => 'root',
|
|
|
|
'group' => '0',
|
|
|
|
'mode' => '0600',
|
|
|
|
}
|
|
|
|
)}
|
2014-01-26 11:59:34 +01:00
|
|
|
|
|
|
|
context 'change ssh port' do
|
|
|
|
let(:params){{
|
|
|
|
:ports => [ 22222],
|
|
|
|
}}
|
|
|
|
it { should contain_file(
|
|
|
|
'sshd_config'
|
|
|
|
).with_content(/Port 22222/)}
|
|
|
|
end
|
2014-01-26 09:36:35 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context "Debian OS" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'Debian',
|
|
|
|
:osfamily => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it_behaves_like "a Linux OS"
|
2014-01-26 11:19:11 +01:00
|
|
|
it { should contain_package('openssh') }
|
|
|
|
it { should contain_class('sshd::debian') }
|
|
|
|
it { should contain_service('sshd').with(
|
|
|
|
:hasrestart => true
|
|
|
|
)}
|
|
|
|
|
|
|
|
context "Ubuntu" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'Ubuntu',
|
|
|
|
:lsbdistcodename => 'precise',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it_behaves_like "a Linux OS"
|
|
|
|
it { should contain_package('openssh') }
|
2014-01-26 11:25:11 +01:00
|
|
|
it { should contain_service('sshd').with({
|
2014-01-26 11:19:11 +01:00
|
|
|
:hasrestart => true
|
2014-01-26 11:25:11 +01:00
|
|
|
})}
|
2014-01-26 11:19:11 +01:00
|
|
|
end
|
2014-01-26 09:36:35 +01:00
|
|
|
end
|
|
|
|
|
2014-01-26 11:19:11 +01:00
|
|
|
|
|
|
|
# context "RedHat OS" do
|
|
|
|
# it_behaves_like "a Linux OS" do
|
|
|
|
# let :facts do
|
|
|
|
# {
|
|
|
|
# :operatingsystem => 'RedHat',
|
|
|
|
# :osfamily => 'RedHat',
|
|
|
|
# }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
context "CentOS" do
|
|
|
|
it_behaves_like "a Linux OS" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'CentOS',
|
|
|
|
:osfamily => 'RedHat',
|
|
|
|
:lsbdistcodename => 'Final',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "Gentoo" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'Gentoo',
|
|
|
|
:osfamily => 'Gentoo',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it_behaves_like "a Linux OS"
|
|
|
|
it { should contain_class('sshd::gentoo') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "OpenBSD" do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:operatingsystem => 'OpenBSD',
|
|
|
|
:osfamily => 'OpenBSD',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
it_behaves_like "a Linux OS"
|
|
|
|
it { should contain_class('sshd::openbsd') }
|
|
|
|
end
|
|
|
|
|
|
|
|
# context "FreeBSD" do
|
|
|
|
# it_behaves_like "a Linux OS" do
|
|
|
|
# let :facts do
|
|
|
|
# {
|
|
|
|
# :operatingsystem => 'FreeBSD',
|
|
|
|
# :osfamily => 'FreeBSD',
|
|
|
|
# }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
2014-01-26 09:36:35 +01:00
|
|
|
end
|