Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate password length #29

Merged
merged 1 commit into from
Sep 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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