Skip to content

Commit

Permalink
Merge pull request #29 from hunner/validate_password
Browse files Browse the repository at this point in the history
Validate password length
  • Loading branch information
hunner committed Sep 18, 2013
2 parents 71749c8 + 585c710 commit 0f8a3de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/puppet/type/java_ks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def insync?(is)
subsequently also protected this password will be used to attempt
unlocking...P.S. Let me know if you ever need a separate private key
password parameter...'

validate do |value|
raise Puppet::Error, "password is #{value.length} characters long; must be of length 6 or greater" if value.length < 6
end
end

newparam(:password_file) do
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/puppet/type/java_ks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
Puppet::Type.type(:java_ks).new(jks)
}.to raise_error(Puppet::Error, /You must pass one of/)
end

it 'should fail if :password is fewer than 6 characters' do
jks = jks_resource.dup
jks[:password] = 'aoeui'
expect {
Puppet::Type.type(:java_ks).new(jks)
}.to raise_error(Puppet::Error, /length 6/)
end
end

describe 'when ensure is set to latest' do
Expand Down

0 comments on commit 0f8a3de

Please sign in to comment.