Skip to content

Tests for GH-131 and GH-132 #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions spec/recipes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,42 @@
end
end

it 'disables the challenge response authentication' do
expect(chef_run).to render_file('/etc/ssh/sshd_config').
with_content(/ChallengeResponseAuthentication no/)
end

context 'with challenge response authentication enabled' do
cached(:chef_run) do
ChefSpec::ServerRunner.new do |node|
node.normal['ssh-hardening']['ssh']['server']['challenge_response_authentication'] = true
end.converge(described_recipe)
end

it 'enables the challenge response authentication' do
expect(chef_run).to render_file('/etc/ssh/sshd_config').
with_content(/ChallengeResponseAuthentication yes/)
end
end

it 'sets the login grace time to 30s' do
expect(chef_run).to render_file('/etc/ssh/sshd_config').
with_content(/LoginGraceTime 30s/)
end

context 'with configured login grace time to 60s' do
cached(:chef_run) do
ChefSpec::ServerRunner.new do |node|
node.normal['ssh-hardening']['ssh']['server']['login_grace_time'] = '60s'
end.converge(described_recipe)
end

it 'sets the login grace time to 60s' do
expect(chef_run).to render_file('/etc/ssh/sshd_config').
with_content(/LoginGraceTime 60s/)
end
end

it 'leaves deny users commented' do
expect(chef_run).to render_file('/etc/ssh/sshd_config').
with_content(/#DenyUsers */)
Expand Down