summaryrefslogtreecommitdiff
path: root/puppet/modules/sshd/spec/defines/ssh_authorized_key_spec.rb
blob: c73a91cc86683612f01b016864b25b4e4d37fe54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'spec_helper'

describe 'sshd::ssh_authorized_key' do

  context 'manage authorized key' do
    let(:title) { 'foo' }
    let(:ssh_key) { 'some_secret_ssh_key' }

    let(:params) {{
        :key => ssh_key,
    }}

    it { should contain_ssh_authorized_key('foo').with({
        'ensure' => 'present',
        'type'   => 'ssh-dss',
        'user'   => 'foo',
        'target' => '/home/foo/.ssh/authorized_keys',
        'key'    => ssh_key,
      })
    }
  end
  context 'manage authoried key with options' do
    let(:title) { 'foo2' }
    let(:ssh_key) { 'some_secret_ssh_key' }

    let(:params) {{
        :key      => ssh_key,
        :options  => ['command="/usr/bin/date"',
                      'no-pty','no-X11-forwarding','no-agent-forwarding',
                      'no-port-forwarding']
    }}

    it { should contain_ssh_authorized_key('foo2').with({
        'ensure'  => 'present',
        'type'    => 'ssh-dss',
        'user'    => 'foo2',
        'target'  => '/home/foo2/.ssh/authorized_keys',
        'key'     => ssh_key,
        'options' => ['command="/usr/bin/date"',
                      'no-pty','no-X11-forwarding','no-agent-forwarding',
                      'no-port-forwarding']
      })
    }
  end
end