|
230 | 230 | expect(chef_run).to render_file('/etc/ssh/sshd_config').with_content('UsePAM yes')
|
231 | 231 | end
|
232 | 232 |
|
| 233 | + describe 'version specifc options' do |
| 234 | + context 'running with OpenSSH < 7.4' do |
| 235 | + it 'should have UseLogin' do |
| 236 | + expect(chef_run).to render_file('/etc/ssh/sshd_config').with_content('UseLogin') |
| 237 | + end |
| 238 | + |
| 239 | + it 'should have UsePrivilegeSeparation' do |
| 240 | + expect(chef_run).to render_file('/etc/ssh/sshd_config').with_content('UsePrivilegeSeparation') |
| 241 | + end |
| 242 | + end |
| 243 | + |
| 244 | + context 'running with OpenSSH >= 7.4 on RHEL 7' do |
| 245 | + let(:chef_run) do |
| 246 | + ChefSpec::ServerRunner.new(platform: 'centos', version: '7.5.1804').converge(described_recipe) |
| 247 | + end |
| 248 | + |
| 249 | + before do |
| 250 | + stub_command('getenforce | grep -vq Disabled && semodule -l | grep -q ssh_password').and_return(true) |
| 251 | + end |
| 252 | + |
| 253 | + it 'should not have UseLogin' do |
| 254 | + expect(chef_run).to_not render_file('/etc/ssh/sshd_config').with_content('UseLogin') |
| 255 | + end |
| 256 | + end |
| 257 | + |
| 258 | + context 'running with Openssh >= 7.5 on Ubuntu 18.04' do |
| 259 | + let(:chef_run) do |
| 260 | + ChefSpec::ServerRunner.new(version: '18.04').converge(described_recipe) |
| 261 | + end |
| 262 | + |
| 263 | + it 'should not have UseLogin' do |
| 264 | + expect(chef_run).to_not render_file('/etc/ssh/sshd_config').with_content('UseLogin') |
| 265 | + end |
| 266 | + |
| 267 | + it 'should not have UsePrivilegeSeparation' do |
| 268 | + expect(chef_run).to_not render_file('/etc/ssh/sshd_config').with_content('UsePrivilegeSeparation') |
| 269 | + end |
| 270 | + end |
| 271 | + end |
| 272 | + |
233 | 273 | describe 'UsePAM option' do
|
234 | 274 | let(:use_pam) { true }
|
235 | 275 |
|
|
269 | 309 |
|
270 | 310 | context 'when running on CentOS' do
|
271 | 311 | let(:platform) { 'centos' }
|
272 |
| - let(:version) { '7.2.1511' } |
| 312 | + let(:version) { '7.5.1804' } |
273 | 313 |
|
274 | 314 | let(:selinux_disabled_or_policy_removed) { false }
|
275 | 315 | let(:selinux_enabled_and_policy_installed) { false }
|
|
392 | 432 | end
|
393 | 433 |
|
394 | 434 | cached(:chef_run) do
|
395 |
| - ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511') do |node| |
| 435 | + ChefSpec::ServerRunner.new(platform: 'centos', version: '7.5.1804') do |node| |
396 | 436 | node.normal['ssh-hardening']['ssh']['server']['os_banner'] = true
|
397 | 437 | end.converge(described_recipe)
|
398 | 438 | end
|
|
0 commit comments