summaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
authorHunter Haugen <hunter@puppetlabs.com>2015-04-09 10:43:34 -0700
committerHunter Haugen <hunter@puppetlabs.com>2015-04-09 10:43:34 -0700
commit487e8d4cd7384e9c3170f93a71f14c0a78766a3f (patch)
treebf23536e44b7642826bad88cc4f44e018dc4d221 /spec/acceptance
parent5ecfe2f67640c33be0efb97ccd727001a43bbbb4 (diff)
parent23be4020ddd4f95dc589ecebe57cd1b27d85248b (diff)
downloadpuppet-stdlib-487e8d4cd7384e9c3170f93a71f14c0a78766a3f.tar.gz
puppet-stdlib-487e8d4cd7384e9c3170f93a71f14c0a78766a3f.tar.bz2
Merge pull request #408 from elyscape/feature/pw_hash
(MODULES-1737) Add pw_hash() function
Diffstat (limited to 'spec/acceptance')
-rw-r--r--spec/acceptance/pw_hash_spec.rb34
1 files changed, 34 insertions, 0 deletions
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