Skip to content

Commit

Permalink
Merge pull request #646 from dveeden/emptypwd
Browse files Browse the repository at this point in the history
Return an empty string for an empty input.
  • Loading branch information
hunner committed Feb 5, 2015
2 parents fa66b38 + 279c13b commit 3fa7050
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/mysql_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Puppet::Parser::Functions
raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' +
"given (#{args.size} for 1)") if args.size != 1

return '' if args[0].empty?
'*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase
end
end
2 changes: 1 addition & 1 deletion lib/puppet/type/mysql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

newproperty(:password_hash) do
desc 'The password hash of the user. Use mysql_password() for creating such a hash.'
newvalue(/\w+/)
newvalue(/\w*/)
end

newproperty(:max_user_connections) do
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/puppet/functions/mysql_password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
result = scope.function_mysql_password(%w(password))
expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'))
end

it 'should convert an empty password into a empty string' do
result = scope.function_mysql_password([""])
expect(result).to(eq(''))
end

end

0 comments on commit 3fa7050

Please sign in to comment.