Skip to content

Commit 6e5a08d

Browse files
committed
update spec tests for kex changes
Signed-off-by: Dominik Richter <[email protected]>
1 parent 054bd11 commit 6e5a08d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

spec/recipes/client_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
end
4949

5050
it 'disables weak kexs' do
51+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
52+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
53+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
54+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
5155
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
5256
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
5357
end
@@ -102,6 +106,10 @@
102106
end
103107

104108
it 'allows weak kexs on the client' do
109+
expect(chef_run).to render_file('/etc/ssh/ssh_config')
110+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
111+
expect(chef_run).to render_file('/etc/ssh/ssh_config')
112+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
105113
expect(chef_run).to render_file('/etc/ssh/ssh_config')
106114
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
107115
end
@@ -119,6 +127,10 @@
119127
end
120128

121129
it 'does not allow weak kexs on the client' do
130+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
131+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
132+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
133+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
122134
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
123135
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
124136
end
@@ -170,6 +182,10 @@
170182
end
171183

172184
it 'still does not allow weak kexs' do
185+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
186+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
187+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
188+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
173189
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
174190
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
175191
end
@@ -194,6 +210,10 @@
194210
end
195211

196212
it 'allows weak kexs on the client' do
213+
expect(chef_run).to render_file('/etc/ssh/ssh_config')
214+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
215+
expect(chef_run).to render_file('/etc/ssh/ssh_config')
216+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
197217
expect(chef_run).to render_file('/etc/ssh/ssh_config')
198218
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
199219
end
@@ -235,6 +255,10 @@
235255
end
236256

237257
it 'still does not allow weak kexs' do
258+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
259+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
260+
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
261+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
238262
expect(chef_run).not_to render_file('/etc/ssh/ssh_config')
239263
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
240264
end

spec/recipes/server_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
end
5757

5858
it 'disables weak kexs' do
59+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
60+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
61+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
62+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
5963
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
6064
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
6165
end
@@ -111,6 +115,10 @@
111115
end
112116

113117
it 'enables weak kexs on the server' do
118+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
119+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
120+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
121+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
114122
expect(chef_run).to render_file('/etc/ssh/sshd_config')
115123
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
116124
end
@@ -129,6 +137,10 @@
129137
end
130138

131139
it 'does not enable weak kexs on the server' do
140+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
141+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
142+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
143+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
132144
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
133145
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
134146
end
@@ -182,6 +194,10 @@
182194
end
183195

184196
it 'still does not allow weak kexs' do
197+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
198+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
199+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
200+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
185201
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
186202
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
187203
end
@@ -207,6 +223,10 @@
207223
end
208224

209225
it 'allows weak kexs' do
226+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
227+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
228+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
229+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
210230
expect(chef_run).to render_file('/etc/ssh/sshd_config')
211231
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
212232
end
@@ -249,6 +269,10 @@
249269
end
250270

251271
it 'still does not allow weak kexs' do
272+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
273+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group14-sha1\b/)
274+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
275+
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group-exchange-sha1\b/)
252276
expect(chef_run).not_to render_file('/etc/ssh/sshd_config')
253277
.with_content(/KexAlgorithms [^#]*\bdiffie-hellman-group1-sha1\b/)
254278
end

0 commit comments

Comments
 (0)