Skip to content
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

Conditionally use HTTPS based on platform_version #240

Merged
merged 1 commit into from Oct 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion recipes/repository.rb
Expand Up @@ -41,7 +41,9 @@
name 'datadog'
description 'datadog'
url node['datadog']['yumrepo']
gpgkey 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public'
# Older versions of yum embed M2Crypto with SSL that doesn't support TLS1.2
prefix = node['platform_version'].to_i < 6 ? 'http' : 'https'
gpgkey "#{prefix}://yum.datadoghq.com/DATADOG_RPM_KEY.public"
action :add
end
end
37 changes: 37 additions & 0 deletions spec/repository_spec.rb
@@ -0,0 +1,37 @@
describe 'datadog::repository' do
context 'rhellions' do
describe 'on versions 5.x and lower' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(
:platform => 'centos',
:version => '5.8'
) do |node|
node.set['languages'] = { 'python' => { 'version' => '2.4.3' } }
end.converge described_recipe
end

it 'sets up a yum repo' do
expect(chef_run).to add_yum_repository('datadog').with(
gpgkey: 'http://yum.datadoghq.com/DATADOG_RPM_KEY.public'
)
end
end

describe 'on versions 6.x and higher' do
cached(:chef_run) do
ChefSpec::SoloRunner.new(
:platform => 'centos',
:version => '6.3'
) do |node|
node.set['languages'] = { 'python' => { 'version' => '2.7.3' } }
end.converge described_recipe
end

it 'sets up a yum repo' do
expect(chef_run).to add_yum_repository('datadog').with(
gpgkey: 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public'
)
end
end
end
end