]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / pw_hash_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
3
4 # Windows and OS X do not have useful implementations of crypt(3)
5 describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin']).include?(fact('operatingsystem')) do
6   describe 'success' do
7     it 'hashes passwords' do
8       pp = <<-EOS
9       $o = pw_hash('password', 'sha-512', 'salt')
10       notice(inline_template('pw_hash is <%= @o.inspect %>'))
11       EOS
12
13       apply_manifest(pp, :catch_failures => true) do |r|
14         expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/)
15       end
16     end
17
18     it 'returns nil if no password is provided' do
19       pp = <<-EOS
20       $o = pw_hash('', 'sha-512', 'salt')
21       notice(inline_template('pw_hash is <%= @o.inspect %>'))
22       EOS
23
24       apply_manifest(pp, :catch_failures => true) do |r|
25         expect(r.stdout).to match(/pw_hash is nil/)
26       end
27     end
28   end
29   describe 'failure' do
30     it 'handles less than three arguments'
31     it 'handles more than three arguments'
32     it 'handles non strings'
33   end
34 end