-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(MODULES-7613) use name and type as composite namevar
- Loading branch information
Ciprian Badescu
committed
Feb 25, 2020
1 parent
9f710d8
commit 188f27c
Showing
9 changed files
with
243 additions
and
21 deletions.
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
2 changes: 1 addition & 1 deletion
2
spec/acceptance/tests/resource/ssh_authorized_key/destroy_spec.rb
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
2 changes: 1 addition & 1 deletion
2
spec/acceptance/tests/resource/ssh_authorized_key/modify_spec.rb
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
RSpec.context 'sshkeys: Destroy' do | ||
let(:keyname) { "pl#{rand(999_999).to_i}" } | ||
|
||
# FIXME: This is bletcherous | ||
let(:ssh_known_hosts) { '/etc/ssh/ssh_known_hosts' } | ||
|
||
before(:each) do | ||
posix_agents.agents.each do |agent| | ||
# The 'cp' might fail because the source file doesn't exist | ||
on( | ||
agent, | ||
"cp -fv #{ssh_known_hosts} /tmp/ssh_known_hosts", | ||
acceptable_exit_codes: [0, 1], | ||
) | ||
on(agent, "echo '' > #{ssh_known_hosts} && echo '#{keyname} ssh-rsa how_about_the_initial_rsa_key_of_c' >> #{ssh_known_hosts} && echo '#{keyname} ssh-dss how_about_the_initial_dss_key_of_c' >> #{ssh_known_hosts}") | ||
|
||
end | ||
end | ||
|
||
after(:each) do | ||
posix_agents.each do |agent| | ||
# Is it present? | ||
rc = on( | ||
agent, | ||
'[ -e /tmp/ssh_known_hosts ]', | ||
accept_all_exit_codes: true, | ||
) | ||
if rc.exit_code == 0 | ||
# It's present, so restore the original | ||
on( | ||
agent, | ||
"mv -fv /tmp/ssh_known_hosts #{ssh_known_hosts}", | ||
accept_all_exit_codes: true, | ||
) | ||
else | ||
# It's missing, which means there wasn't one to backup; just | ||
# delete the one we laid down | ||
on( | ||
agent, | ||
"rm -fv #{ssh_known_hosts}", | ||
accept_all_exit_codes: true, | ||
) | ||
end | ||
end | ||
end | ||
|
||
posix_agents.each do |agent| | ||
it "#{agent} should delete an rsa entry for an SSH known host key" do | ||
args = ['ensure=absent', | ||
"type='rsa'"] | ||
on(agent, puppet_resource('sshkey', keyname.to_s, args)) | ||
|
||
on(agent, "cat #{ssh_known_hosts}") do |_res| | ||
expect(stdout).not_to include("how_about_the_initial_rsa_key_of_c") | ||
end | ||
end | ||
|
||
it "#{agent} should delete an dss entry for an SSH known host key" do | ||
args = ['ensure=absent', | ||
"type='ssh-dss'"] | ||
on(agent, puppet_resource('sshkey', keyname.to_s, args)) | ||
|
||
on(agent, "cat #{ssh_known_hosts}") do |_res| | ||
expect(stdout).not_to include("how_about_the_initial_dss_key_of_c") | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
RSpec.context 'sshkeys: Modify' do | ||
let(:keyname) { "pl#{rand(999_999).to_i}" } | ||
|
||
# FIXME: This is bletcherous | ||
let(:ssh_known_hosts) { '/etc/ssh/ssh_known_hosts' } | ||
|
||
before(:each) do | ||
posix_agents.agents.each do |agent| | ||
# The 'cp' might fail because the source file doesn't exist | ||
on( | ||
agent, | ||
"cp -fv #{ssh_known_hosts} /tmp/ssh_known_hosts", | ||
acceptable_exit_codes: [0, 1], | ||
) | ||
on(agent, "echo '' > #{ssh_known_hosts} && echo '#{keyname} ssh-rsa how_about_the_initial_rsa_key_of_c' >> #{ssh_known_hosts} && echo '#{keyname} ssh-dss how_about_the_initial_dss_key_of_c' >> #{ssh_known_hosts}") | ||
|
||
end | ||
end | ||
|
||
after(:each) do | ||
posix_agents.each do |agent| | ||
# Is it present? | ||
rc = on( | ||
agent, | ||
'[ -e /tmp/ssh_known_hosts ]', | ||
accept_all_exit_codes: true, | ||
) | ||
if rc.exit_code == 0 | ||
# It's present, so restore the original | ||
on( | ||
agent, | ||
"mv -fv /tmp/ssh_known_hosts #{ssh_known_hosts}", | ||
accept_all_exit_codes: true, | ||
) | ||
else | ||
# It's missing, which means there wasn't one to backup; just | ||
# delete the one we laid down | ||
on( | ||
agent, | ||
"rm -fv #{ssh_known_hosts}", | ||
accept_all_exit_codes: true, | ||
) | ||
end | ||
end | ||
end | ||
|
||
posix_agents.each do |agent| | ||
it "#{agent} should update an rsa entry for an SSH known host key" do | ||
args = ['ensure=present', | ||
"type='rsa'", | ||
"key='how_about_the_updated_rsa_key_of_c'"] | ||
on(agent, puppet_resource('sshkey', keyname.to_s, args)) | ||
|
||
on(agent, "cat #{ssh_known_hosts}") do |_res| | ||
expect(stdout).to include("how_about_the_updated_rsa_key_of_c") | ||
expect(stdout).not_to include("how_about_the_initial_rsa_key_of_c") | ||
end | ||
end | ||
|
||
it "#{agent} should update an dss entry for an SSH known host key" do | ||
args = ['ensure=present', | ||
"type='ssh-dss'", | ||
"key='how_about_the_updated_dss_key_of_c'"] | ||
on(agent, puppet_resource('sshkey', keyname.to_s, args)) | ||
|
||
on(agent, "cat #{ssh_known_hosts}") do |_res| | ||
expect(stdout).to include("how_about_the_updated_dss_key_of_c") | ||
expect(stdout).not_to include("how_about_the_initial_dss_key_of_c") | ||
end | ||
end | ||
end | ||
end |
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