forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,78 @@ | ||
require 'spec_helper' | ||
|
||
describe 'ssh::server', :type => 'class' do | ||
context "On Debian with no other parameters" do | ||
let :facts do | ||
describe 'ssh::server' do | ||
let :default_params do | ||
{ | ||
:osfamily => 'Debian', | ||
:interfaces => 'eth0', | ||
:ipaddress_eth0 => '192.168.1.1' | ||
} | ||
end | ||
it { | ||
should contain_package('openssh-server').with(:ensure => 'present') | ||
:ensure => 'present', | ||
:storeconfigs_enabled => true, | ||
:options => {} | ||
} | ||
end | ||
context "On Debian with custom ensure" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:interfaces => 'eth0', | ||
:ipaddress_eth0 => '192.168.1.1' | ||
} | ||
|
||
[ {}, | ||
{ | ||
:ensure => 'latest', | ||
:storeconfigs_enabled => true, | ||
:options => {} | ||
}, | ||
{ | ||
:ensure => 'present', | ||
:storeconfigs_enabled => false, | ||
:options => {} | ||
} | ||
].each do |param_set| | ||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do | ||
let :param_hash do | ||
default_params.merge(param_set) | ||
end | ||
|
||
let :params do | ||
{ | ||
:ensure => 'latest' | ||
} | ||
param_set | ||
end | ||
it { | ||
should contain_package('openssh-server').with(:ensure => 'latest') | ||
} | ||
|
||
['Debian'].each do |osfamily| | ||
let :facts do | ||
{ | ||
:osfamily => osfamily, | ||
:interfaces => 'eth0', | ||
:ipaddress_eth0 => '192.168.1.1' | ||
} | ||
end | ||
|
||
describe "on supported osfamily: #{osfamily}" do | ||
it { should contain_class('ssh::params') } | ||
it { should contain_package('openssh-server').with_ensure(param_hash[:ensure]) } | ||
|
||
it { should contain_file('/etc/ssh/sshd_config').with( | ||
'owner' => 0, | ||
'group' => 0, | ||
)} | ||
|
||
it { should contain_service('ssh').with( | ||
'ensure' => 'running', | ||
'enable' => true, | ||
'hasrestart' => true, | ||
'hasstatus' => true, | ||
)} | ||
|
||
it 'should compile the template based on the class parameters' do | ||
content = param_value( | ||
subject, | ||
'file', | ||
'/etc/ssh/sshd_config', | ||
'content' | ||
) | ||
expected_lines = [ | ||
'ChallengeResponseAuthentication no', | ||
'X11Forwarding yes', | ||
'PrintMotd no', | ||
'AcceptEnv LANG LC_*', | ||
'Subsystem sftp /usr/lib/openssh/sftp-server', | ||
'UsePAM yes' | ||
] | ||
(content.split("\n") & expected_lines).should =~ expected_lines | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |