1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 # Windows and OS X do not have useful implementations of crypt(3)
5 describe 'pw_hash function', :unless => (['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do
7 it 'hashes passwords' do
9 $o = pw_hash('password', 'sha-512', 'salt')
10 notice(inline_template('pw_hash is <%= @o.inspect %>'))
13 apply_manifest(pp, :catch_failures => true) do |r|
14 expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/)
18 it 'returns nil if no password is provided' do
20 $o = pw_hash('', 'sha-512', 'salt')
21 notice(inline_template('pw_hash is <%= @o.inspect %>'))
24 apply_manifest(pp, :catch_failures => true) do |r|
25 expect(r.stdout).to match(/pw_hash is nil/)
30 it 'handles less than three arguments'
31 it 'handles more than three arguments'
32 it 'handles non strings'