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
Fixed #403 - Guard new GPG key from being downloaded always #404
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,66 @@ | ||
describe 'datadog::repository' do | ||
context 'on debianoids' do | ||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new( | ||
platform: 'debian', version: '8.5' | ||
).converge(described_recipe) | ||
end | ||
|
||
it 'include apt cookbook' do | ||
expect(chef_run).to include_recipe('apt::default') | ||
end | ||
|
||
it 'installs apt-transport-https' do | ||
expect(chef_run).to install_package('apt-transport-https') | ||
end | ||
|
||
it 'installs new apt key' do | ||
expect(chef_run).to run_execute('apt-key import key 382E94DE').with( | ||
command: 'apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 A2923DFF56EDA6E76E55E492D3A80E30382E94DE' | ||
) | ||
end | ||
|
||
it 'sets up an apt repo' do | ||
expect(chef_run).to add_apt_repository('datadog') | ||
end | ||
end | ||
|
||
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 create_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 create_yum_repository('datadog').with( | ||
gpgkey: 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' | ||
) | ||
end | ||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new( | ||
platform: 'centos', version: '6.5' | ||
).converge(described_recipe) | ||
end | ||
|
||
it 'sets the yumrepo_gpgkey_new attribute' do | ||
expect(chef_run.node['datadog']['yumrepo_gpgkey_new']).to match( | ||
/DATADOG_RPM_KEY_E09422B3.public/ | ||
) | ||
end | ||
|
||
it 'installs gnupg' do | ||
expect(chef_run).to install_package('gnupg') | ||
end | ||
|
||
it 'downloads the new RPM key' do | ||
expect(chef_run).to create_remote_file('DATADOG_RPM_KEY_E09422B3.public').with(path: '/var/chef/cache/DATADOG_RPM_KEY_E09422B3.public') | ||
end | ||
|
||
it 'notifies the GPG key install if a new one is downloaded' do | ||
keyfile_r = chef_run.remote_file('DATADOG_RPM_KEY_E09422B3.public') | ||
expect(keyfile_r).to notify('execute[rpm-import datadog key e09422b3]') | ||
.to(:run).immediately | ||
end | ||
|
||
it 'doesn\'t execute[rpm-import datadog key e09422b3] by default' do | ||
keyfile_exec_r = chef_run.execute('rpm-import datadog key e09422b3') | ||
expect(keyfile_exec_r).to do_nothing | ||
end | ||
|
||
it 'sets up a yum repo' do | ||
expect(chef_run).to create_yum_repository('datadog').with( | ||
gpgkey: 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' | ||
) | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for removing this test on RHEL <= 5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @olivielpeau I can add it back, but the repository recipe doesn't have any logic dependent on platform version. The separate test for RHEL5 wasn't actually exercising anything specific, so I thought I'd condense the spec by removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there's one RHEL5-specific thing: the yum repository has to be configured with a gpgkey downloaded through plain text
http
(the logic that handles that is in the default attributes file: https://github.com/DataDog/chef-datadog/blob/v2.8.1/attributes/default.rb#L85-L91).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh.. good catch. This should be fixed in bc60110.