Fix an issue with lowercase privileges.

This fixes the case where a user passes in lowercase privileges and
we incorrectly assume this means a change and reapply them.
This commit is contained in:
Ashley Penney 2013-10-28 12:44:48 -04:00
parent cec288d47b
commit d271ab5f76
2 changed files with 32 additions and 3 deletions

View file

@ -3,9 +3,7 @@ Puppet::Type.newtype(:mysql_grant) do
@doc = "Manage a MySQL user's rights." @doc = "Manage a MySQL user's rights."
ensurable ensurable
autorequire(:file) do autorequire(:file) { '/root/.my.cnf' }
'/root/.my.cnf'
end
def initialize(*args) def initialize(*args)
super super
@ -38,6 +36,10 @@ Puppet::Type.newtype(:mysql_grant) do
newproperty(:privileges, :array_matching => :all) do newproperty(:privileges, :array_matching => :all) do
desc 'Privileges for user' desc 'Privileges for user'
munge do |value|
value.upcase
end
end end
newproperty(:table) do newproperty(:table) do

View file

@ -283,5 +283,32 @@ describe 'mysql_grant' do
end end
end end
describe 'lower case privileges' do
it 'create ALL privs' do
pp = <<-EOS
mysql_grant { 'lowercase@localhost/*.*':
user => 'lowercase@localhost',
privileges => 'ALL',
table => '*.*',
}
EOS
puppet_apply(pp)
end
it 'create lowercase all privs' do
pp = <<-EOS
mysql_grant { 'lowercase@localhost/*.*':
user => 'lowercase@localhost',
privileges => 'all',
table => '*.*',
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should be_zero
end
end
end
end end