Browse Source

client spec

Tomas Barton 10 years ago
parent
commit
5ce0dcda97
2 changed files with 46 additions and 3 deletions
  1. 4 3
      manifests/client/base.pp
  2. 42 0
      spec/classes/client_spec.rb

+ 4 - 3
manifests/client/base.pp

@@ -1,9 +1,10 @@
 class sshd::client::base {
   # this is needed because the gid might have changed
   file { '/etc/ssh/ssh_known_hosts':
-    mode  => '0644',
-    owner => root,
-    group => 0;
+    ensure => present,
+    mode   => '0644',
+    owner  => root,
+    group  => 0;
   }
 
   # Now collect all server keys

+ 42 - 0
spec/classes/client_spec.rb

@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+describe 'sshd::client' do
+
+  shared_examples "a Linux OS" do
+    it { should contain_file('/etc/ssh/ssh_known_hosts').with(
+      {
+        'ensure'  => 'present',
+        'owner'   => 'root',
+        'group'   => '0',
+        'mode'    => '0644',
+      }
+    )}
+  end
+
+  context "Debian OS" do
+    let :facts do
+      {
+        :operatingsystem => 'Debian',
+        :osfamily        => 'Debian',
+        :lsbdistcodename => 'wheezy',
+      }
+    end
+    it_behaves_like "a Linux OS"
+    it { should contain_package('openssh-clients').with({
+      'name' => 'openssh-client'
+    }) }
+  end
+
+  context "CentOS" do
+    it_behaves_like "a Linux OS" do
+      let :facts do
+        {
+        :operatingsystem => 'CentOS',
+        :osfamily        => 'RedHat',
+        :lsbdistcodename => 'Final',
+       }
+      end
+    end
+  end
+
+end