File: init_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-ssh-keygen 2.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 324 kB
  • sloc: ruby: 164; makefile: 12; sh: 10
file content (115 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (3)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require 'spec_helper'

describe 'ssh_keygen' do
  let(:title) { 'john' }
  let(:facts) { { fqdn: 'www.acme.com' } }

  context 'not passing parameters' do
    let(:params) { {} }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/home/john/.ssh/id_rsa' -N ''",
        user: 'john',
        creates: '/home/john/.ssh/id_rsa'
      )
    }
  end

  context 'passing user other parameter' do
    let(:params) { { user: 'other' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/home/other/.ssh/id_rsa' -N ''",
        user: 'other',
        creates: '/home/other/.ssh/id_rsa'
      )
    }
  end

  context 'passing user root parameter' do
    let(:params) { { user: 'root' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/root/.ssh/id_rsa' -N ''",
        user: 'root',
        creates: '/root/.ssh/id_rsa'
      )
    }
  end

  context 'passing type parameter' do
    let(:params) { { type: 'dsa' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t dsa -f '/home/john/.ssh/id_dsa' -N ''",
        user: 'john',
        creates: '/home/john/.ssh/id_dsa'
      )
    }
  end

  context 'passing bits parameter' do
    let(:params) { { bits: 4096 } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -b 4096 -f '/home/john/.ssh/id_rsa' -N ''",
        user: 'john',
        creates: '/home/john/.ssh/id_rsa'
      )
    }
  end

  context 'passing home parameter' do
    let(:params) { { home: '/h/j' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/h/j/.ssh/id_rsa' -N ''",
        user: 'john',
        creates: '/h/j/.ssh/id_rsa'
      )
    }
  end

  context 'passing filename parameter' do
    let(:title)  { 'root' }
    let(:params) { { filename: '/etc/ssh/ssh_host_rsa_key' } }

    it {
      is_expected.to contain_exec('ssh_keygen-root').with(
        command: "ssh-keygen -t rsa -f '/etc/ssh/ssh_host_rsa_key' -N ''",
        user: 'root',
        creates: '/etc/ssh/ssh_host_rsa_key'
      )
    }
  end

  context 'passing comment parameter' do
    let(:params) { { comment: 'my key' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/home/john/.ssh/id_rsa' -N '' -C 'my key'",
        user: 'john',
        creates: '/home/john/.ssh/id_rsa'
      )
    }
  end

  context 'passing options parameter' do
    let(:params) { { options: '-q' } }

    it {
      is_expected.to contain_exec('ssh_keygen-john').with(
        command: "ssh-keygen -t rsa -f '/home/john/.ssh/id_rsa' -N '' -q",
        user: 'john',
        creates: '/home/john/.ssh/id_rsa'
      )
    }
  end
end