pw_hash_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. require 'spec_helper_acceptance'
  2. # Windows and OS X do not have useful implementations of crypt(3)
  3. describe 'pw_hash function', :unless => %w[windows Darwin SLES].include?(fact('operatingsystem')) do
  4. describe 'success' do
  5. pp1 = <<-DOC
  6. $o = pw_hash('password', 'sha-512', 'salt')
  7. notice(inline_template('pw_hash is <%= @o.inspect %>'))
  8. DOC
  9. it 'hashes passwords' do
  10. apply_manifest(pp1, :catch_failures => true) do |r|
  11. expect(r.stdout).to match(%r{pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."})
  12. end
  13. end
  14. pp2 = <<-DOC
  15. $o = pw_hash('', 'sha-512', 'salt')
  16. notice(inline_template('pw_hash is <%= @o.inspect %>'))
  17. DOC
  18. it 'returns nil if no password is provided' do
  19. apply_manifest(pp2, :catch_failures => true) do |r|
  20. expect(r.stdout).to match(%r{pw_hash is nil})
  21. end
  22. end
  23. end
  24. describe 'failure' do
  25. it 'handles less than three arguments'
  26. it 'handles more than three arguments'
  27. it 'handles non strings'
  28. end
  29. end