From 23be4020ddd4f95dc589ecebe57cd1b27d85248b Mon Sep 17 00:00:00 2001 From: Eli Young Date: Mon, 2 Feb 2015 16:41:38 -0800 Subject: (MODULES-1737) Add pw_hash() function --- spec/acceptance/pw_hash_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/acceptance/pw_hash_spec.rb (limited to 'spec/acceptance/pw_hash_spec.rb') diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb new file mode 100644 index 0000000..4768975 --- /dev/null +++ b/spec/acceptance/pw_hash_spec.rb @@ -0,0 +1,34 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper_acceptance' + +# Windows and OS X do not have useful implementations of crypt(3) +describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin']).include?(fact('operatingsystem')) do + describe 'success' do + it 'hashes passwords' do + pp = <<-EOS + $o = pw_hash('password', 6, 'salt') + notice(inline_template('pw_hash is <%= @o.inspect %>')) + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/) + end + end + + it 'returns nil if no password is provided' do + pp = <<-EOS + $o = pw_hash('', 6, 'salt') + notice(inline_template('pw_hash is <%= @o.inspect %>')) + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/pw_hash is ""/) + end + end + end + describe 'failure' do + it 'handles less than three arguments' + it 'handles more than three arguments' + it 'handles non strings' + end +end -- cgit v1.2.3 From 65116dafd507c5111044853861f9b10b02c91854 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Fri, 10 Apr 2015 09:09:46 -0700 Subject: Fix acceptance tests for #405 This fixes the acceptance tests by: - Ensuring the fqdn_rand_string spec is passed undef as the second parameter so that the seed is not used as the charset - Ensuring the pw_hash spec is passed the key specifying the type of hash, rather than the value that will be used to generate the password - Expecting puppet to report nil instead of empty string for undef passwords - Removing the fqdn_rand_base64 test because there is no such function --- spec/acceptance/pw_hash_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/acceptance/pw_hash_spec.rb') diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index 4768975..eddb782 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -6,7 +6,7 @@ describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Da describe 'success' do it 'hashes passwords' do pp = <<-EOS - $o = pw_hash('password', 6, 'salt') + $o = pw_hash('password', 'sha-512', 'salt') notice(inline_template('pw_hash is <%= @o.inspect %>')) EOS @@ -17,12 +17,12 @@ describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Da it 'returns nil if no password is provided' do pp = <<-EOS - $o = pw_hash('', 6, 'salt') + $o = pw_hash('', 'sha-512', 'salt') notice(inline_template('pw_hash is <%= @o.inspect %>')) EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/pw_hash is ""/) + expect(r.stdout).to match(/pw_hash is nil/) end end end -- cgit v1.2.3 From 615227918a72c54c2064b81183fc98f4abd513d4 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 21 Jul 2015 14:43:34 -0700 Subject: disable pw_hash test on sles, as it only supports md5 --- spec/acceptance/pw_hash_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/acceptance/pw_hash_spec.rb') diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index eddb782..cd4cb87 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' # Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin']).include?(fact('operatingsystem')) do +describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do describe 'success' do it 'hashes passwords' do pp = <<-EOS -- cgit v1.2.3