Skip to content

Commit

Permalink
Add debian 7, fedora and opensuse-13.2 with ssh versions
Browse files Browse the repository at this point in the history
for old chef versions where autodetection does not work
  • Loading branch information
artem-sidorenko committed Feb 5, 2017
1 parent 4d17292 commit 98375b8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libraries/devsec_ssh.rb
Expand Up @@ -191,7 +191,7 @@ def get_ssh_version(package)
end

# Guess the version of ssh via OS matrix
def guess_ssh_version
def guess_ssh_version # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
family = node['platform_family']
platform = node['platform']
version = node['platform_version'].to_f
Expand All @@ -203,11 +203,20 @@ def guess_ssh_version
return 6.6 if version >= 14.04
when 'debian'
return 6.6 if version >= 8
return 6.0 if version >= 7
return 5.3 if version <= 6
end
when 'rhel'
return 6.6 if version >= 7
return 5.3 if version >= 6
when 'fedora'
return 7.3 if version >= 25
return 7.2 if version >= 24
when 'suse'
case platform
when 'opensuse'
return 6.6 if version >= 13.2
end
end
Chef::Log.info("Unknown platform #{node['platform']} with version #{node['platform_version']} and family #{node['platform_family']}. Assuming ssh version #{FALLBACK_SSH_VERSION}")
FALLBACK_SSH_VERSION
Expand Down
40 changes: 40 additions & 0 deletions spec/libraries/devsec_ssh_spec.rb
Expand Up @@ -109,6 +109,46 @@ def self.debug(*); end
end
end

context 'when running on Fedora 25' do
let(:family) { 'fedora' }
let(:platform) { 'fedora' }
let(:version) { '25' }

it 'should return ssh version 7.3' do
expect(subject.send(:guess_ssh_version)).to eq 7.3
end
end

context 'when running on Fedora 24' do
let(:family) { 'fedora' }
let(:platform) { 'fedora' }
let(:version) { '24' }

it 'should return ssh version 7.2' do
expect(subject.send(:guess_ssh_version)).to eq 7.2
end
end

context 'when running on Opensuse 13.2' do
let(:family) { 'opensuse' }
let(:platform) { 'opensuse' }
let(:version) { '13.2' }

it 'should return ssh version 6.6' do
expect(subject.send(:guess_ssh_version)).to eq 6.6
end
end

context 'when running on Opensuse 42.1' do
let(:family) { 'opensuse' }
let(:platform) { 'opensuse' }
let(:version) { '42.1' }

it 'should return ssh version 6.6' do
expect(subject.send(:guess_ssh_version)).to eq 6.6
end
end

context 'when running on unknown platform' do
let(:family) { 'unknown' }
let(:platform) { 'unknown' }
Expand Down

0 comments on commit 98375b8

Please sign in to comment.