annotate modules/common/spec/defines/mkuser_spec.rb @ 388:750d36241580

Add missing dependency modules Probably required by SSH, but not obviously listed
author IBBoard <dev@ibboard.co.uk>
date Mon, 03 Jan 2022 17:15:14 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 require 'spec_helper'
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 clientversion = `facter puppetversion`
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 describe 'common::mkuser' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 let(:title) { 'alice' }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 let(:facts) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 { :osfamily => 'RedHat',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 :puppetversion => clientversion,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 context 'user alice with default values' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 let(:params) { { :uid => 1000 } }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 should contain_user('alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 'uid' => '1000',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 'gid' => '1000',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 'shell' => '/bin/bash',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 'home' => '/home/alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 'ensure' => 'present',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 'groups' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 'password' => '!!',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 'managehome' => 'true',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 'comment' => 'created via puppet',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 should contain_file('/home/alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 'owner' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 'group' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 'mode' => '0700',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 'require' => 'Common::Mkdir_p[/home/alice]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 should contain_file('/home/alice/.ssh').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 'ensure' => 'directory',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 'mode' => '0700',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 'owner' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 'group' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 'require' => 'User[alice]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 it { should contain_common__mkdir_p('/home/alice') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 should contain_group('alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 'ensure' => 'present',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 'gid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 'name' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 it { should_not contain_ssh_authorized_key('alice') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 context 'user alice with custom values' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 'uid' => 2000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 'group' => 'superusers',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 'gid' => 2000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 'shell' => '/bin/zsh',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 'home' => '/home/superu',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 'groups' => %w(superusers development admins),
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 'password' => 'puppet',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 'mode' => '0701',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 'comment' => 'a puppet master',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 should contain_user('alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 'uid' => '2000',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 'gid' => '2000',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 'shell' => '/bin/zsh',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 'home' => '/home/superu',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 'groups' => %w(superusers development admins),
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 'password' => 'puppet',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 'comment' => 'a puppet master',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 should contain_file('/home/superu').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 'owner' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 'group' => 'superusers',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 'mode' => '0701',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 'require' => 'Common::Mkdir_p[/home/superu]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 should contain_file('/home/superu/.ssh').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 'ensure' => 'directory',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 'mode' => '0700',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 'owner' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 'group' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 'require' => 'User[alice]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 it { should contain_common__mkdir_p('/home/superu') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 it { should_not contain_ssh_authorized_key('myuser') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 context 'do not manage home' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 'managehome' => false
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 it { should_not contain_file('/home/alice') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 it { should_not contain_common__mkdir_p('/home/alice') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 it { should contain_user('alice').with_managehome(false) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 context 'do not manage dotssh' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 'manage_dotssh' => false
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 it { should_not contain_file('/home/alice/.ssh') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 it { should_not contain_ssh_authorized_key('alice') }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 describe 'with ssh_auth_key parameter specified' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 context 'with defaults for ssh_auth_key_type parameter' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 should contain_ssh_authorized_key('alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 'ensure' => 'present',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 'user' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 'type' => 'ssh-dss',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 'require' => 'File[/home/alice/.ssh]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 context 'with ssh_auth_key_type parameter specified' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 'ssh_auth_key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 'ssh_auth_key_type' => 'ssh-rsa',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 it do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 should contain_ssh_authorized_key('alice').with({
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 'ensure' => 'present',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 'user' => 'alice',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 'key' => 'AAAB3NzaC1yc2EAAAABIwAAAQEArGElx46pD6NNnlxVaTbp0ZJMgBKCmbTCT3RaeCk0ZUJtQ8wkcwTtqIXmmiuFsynUT0DFSd8UIodnBOPqitimmooAVAiAi30TtJVzADfPScMiUnBJKZajIBkEMkwUcqsfh630jyBvLPE/kyQcxbEeGtbu1DG3monkeymanOBW1AKc5o+cJLXcInLnbowMG7NXzujT3BRYn/9s5vtT1V9cuZJs4XLRXQ50NluxJI7sVfRPVvQI9EMbTS4AFBXUej3yfgaLSV+nPZC/lmJ2gR4t/tKvMFF9m16f8IcZKK7o0rK7v81G/tREbOT5YhcKLK+0wBfR6RsmHzwy4EddZloyLQ==',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 'type' => 'ssh-rsa',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 'require' => 'File[/home/alice/.ssh]',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 })
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 # purge_ssh_keys was introduced with Puppet 3.6.0
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 # we need to know which version of Puppet is running this test
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 # to decide which results we need to expect
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 # dirty trick to get the running version of Puppet:
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 clientversion = `facter puppetversion`
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 # test environments contains no facts, we need to set it as fact
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 describe "with purge_ssh_keys running on Puppet version #{clientversion}" do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 let(:facts) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 :osfamily => 'RedHat',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 :puppetversion => clientversion,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 context 'set to undef/nil' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198 let(:params) { { :uid => 1000 } }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 if clientversion.to_f >= 3.6
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 it { should contain_user('alice').with_purge_ssh_keys(false) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 else
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 it { should contain_user('alice').without_purge_ssh_keys }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 context 'set to true' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 'purge_ssh_keys' => true,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215 if clientversion.to_f >= 3.6
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 it { should contain_user('alice').with_purge_ssh_keys(true) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 else
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 it { should contain_user('alice').without_purge_ssh_keys }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 context 'set to false' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 let(:params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 'uid' => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 'purge_ssh_keys' => false,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230 if clientversion.to_f >= 3.6
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 it { should contain_user('alice').with_purge_ssh_keys(false) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 else
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 it { should contain_user('alice').without_purge_ssh_keys }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
238 describe 'variable type and content validations' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 # set needed custom facts and variables
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 let(:facts) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 :osfamily => 'RedHat',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243 :puppetversion => clientversion,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246 let(:validation_params) do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 :uid => 1000,
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
252 validations = {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
253 'bool_stringified' => {
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
254 :name => %w(managehome manage_dotssh purge_ssh_keys),
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
255 :valid => [true, false, 'true', 'false'],
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
256 :invalid => ['invalid', %w(array), { 'ha' => 'sh' }, 3, 2.42, nil],
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
257 :message => '(str2bool|must be boolean or string)',
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
258 },
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
259 }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
260
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
261 validations.sort.each do |type, var|
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
262 var[:name].each do |var_name|
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
263 var[:valid].each do |valid|
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
264 context "with #{var_name} (#{type}) set to valid #{valid} (as #{valid.class})" do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
265 let(:params) { validation_params.merge({ :"#{var_name}" => valid, }) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
266 it { should compile }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
267 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
268 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
269
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
270 var[:invalid].each do |invalid|
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
271 context "with #{var_name} (#{type}) set to invalid #{invalid} (as #{invalid.class})" do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
272 let(:params) { validation_params.merge({ :"#{var_name}" => invalid, }) }
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
273 it 'should fail' do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
274 expect do
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
275 should contain_class(subject)
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
276 end.to raise_error(Puppet::Error, /#{var[:message]}/)
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
277 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
278 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
279 end
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
280 end # var[:name].each
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
281 end # validations.sort.each
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
282 end # describe 'variable type and content validations'
750d36241580 Add missing dependency modules
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
283 end