aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Vincent <robert.vincent@conning.com>2019-07-23 10:20:39 -0400
committerGabriel Nagy <gabriel.nagy@puppet.com>2019-08-12 14:54:13 +0300
commit8fd51e76226ea0f2012dfad9e3e52156cccbe13d (patch)
tree46f3c8827b3254c711262cad01709ee85207e180
parentd01b4e369d8bdd5a5f02c035eae74413887039b1 (diff)
downloadpuppet-sshkeys_core-8fd51e76226ea0f2012dfad9e3e52156cccbe13d.tar.gz
puppet-sshkeys_core-8fd51e76226ea0f2012dfad9e3e52156cccbe13d.tar.bz2
(MODULES-9578) Add test for target attribute.
-rw-r--r--spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb b/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb
index 75eba1e..34154ee 100644
--- a/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb
+++ b/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb
@@ -5,11 +5,15 @@ RSpec.context 'ssh_authorized_key: Create' do
let(:auth_keys) { '~/.ssh/authorized_keys' }
let(:name) { "pl#{rand(999_999).to_i}" }
+ let(:custom_key_directory) { "/etc/ssh_authorized_keys_#{name}" }
+ let(:custom_key) { "#{custom_key_directory}/authorized_keys_#{name}" }
+ let(:custom_name) { "custom_#{name}" }
before(:each) do
posix_agents.each do |agent|
on(agent, "cp #{auth_keys} /tmp/auth_keys", acceptable_exit_codes: [0, 1])
- on(agent, "rm -f $LOGNAME #{auth_keys}")
+ on(agent, "rm -f #{auth_keys}")
+ on(agent, "mkdir #{custom_key_directory}")
end
end
@@ -17,6 +21,7 @@ RSpec.context 'ssh_authorized_key: Create' do
posix_agents.each do |agent|
# (teardown) restore the #{auth_keys} file
on(agent, "mv /tmp/auth_keys #{auth_keys}", acceptable_exit_codes: [0, 1])
+ on(agent, "rm -rf #{custom_key_directory}")
end
end
@@ -32,5 +37,18 @@ RSpec.context 'ssh_authorized_key: Create' do
fail_test "didn't find the ssh_authorized_key for #{name}" unless stdout.include? name.to_s
end
end
+ it "#{agent} should create an entry for an SSH authorized key in a custom location" do
+ custom_args = ['ensure=present',
+ 'user=$LOGNAME',
+ "type='rsa'",
+ "key='mykey'",
+ "target='#{custom_key}'"]
+
+ on(agent, puppet_resource('ssh_authorized_key', custom_name.to_s, custom_args))
+
+ on(agent, "cat #{custom_key}") do |_res|
+ fail_test "didn't find the ssh_authorized_key for #{custom_name}" unless stdout.include? name.to_s
+ end
+ end
end
end