Merge pull request #646 from dveeden/emptypwd
Return an empty string for an empty input.
This commit is contained in:
commit
3fa70506c4
3 changed files with 7 additions and 1 deletions
|
@ -10,6 +10,7 @@ module Puppet::Parser::Functions
|
||||||
raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' +
|
raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' +
|
||||||
"given (#{args.size} for 1)") if args.size != 1
|
"given (#{args.size} for 1)") if args.size != 1
|
||||||
|
|
||||||
|
return '' if args[0].empty?
|
||||||
'*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase
|
'*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ Puppet::Type.newtype(:mysql_user) do
|
||||||
|
|
||||||
newproperty(:password_hash) do
|
newproperty(:password_hash) do
|
||||||
desc 'The password hash of the user. Use mysql_password() for creating such a hash.'
|
desc 'The password hash of the user. Use mysql_password() for creating such a hash.'
|
||||||
newvalue(/\w+/)
|
newvalue(/\w*/)
|
||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:max_user_connections) do
|
newproperty(:max_user_connections) do
|
||||||
|
|
|
@ -24,4 +24,9 @@ describe 'the mysql_password function' do
|
||||||
expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'))
|
expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert an empty password into a empty string' do
|
||||||
|
result = scope.function_mysql_password([""])
|
||||||
|
expect(result).to(eq(''))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue