ssh_authorized_key_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. require 'spec_helper'
  2. describe 'sshd::ssh_authorized_key' do
  3. context 'manage authorized key' do
  4. let(:title) { 'foo' }
  5. let(:ssh_key) { 'some_secret_ssh_key' }
  6. let(:params) {{
  7. :key => ssh_key,
  8. }}
  9. it { should contain_ssh_authorized_key('foo').with({
  10. 'ensure' => 'present',
  11. 'type' => 'ssh-dss',
  12. 'user' => 'foo',
  13. 'target' => '/home/foo/.ssh/authorized_keys',
  14. 'key' => ssh_key,
  15. })
  16. }
  17. end
  18. context 'manage authoried key with options' do
  19. let(:title) { 'foo2' }
  20. let(:ssh_key) { 'some_secret_ssh_key' }
  21. let(:params) {{
  22. :key => ssh_key,
  23. :options => ['command="/usr/bin/date"',
  24. 'no-pty','no-X11-forwarding','no-agent-forwarding',
  25. 'no-port-forwarding']
  26. }}
  27. it { should contain_ssh_authorized_key('foo2').with({
  28. 'ensure' => 'present',
  29. 'type' => 'ssh-dss',
  30. 'user' => 'foo2',
  31. 'target' => '/home/foo2/.ssh/authorized_keys',
  32. 'key' => ssh_key,
  33. 'options' => ['command="/usr/bin/date"',
  34. 'no-pty','no-X11-forwarding','no-agent-forwarding',
  35. 'no-port-forwarding']
  36. })
  37. }
  38. end
  39. end