Skip to content

mysql_grant fixed to properly handle PROCEDURE grants #412

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

Merged
merged 2 commits into from
Jan 22, 2014
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/puppet/provider/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def self.cmd_table(table)
# We can't escape *.* so special case this.
if table == '*.*'
table_string << '*.*'
# Special case also for PROCEDURES
elsif table.start_with?('PROCEDURE ')
table_string << table.sub(/^PROCEDURE (.*)(\..*)/, 'PROCEDURE `\1`\2')
else
table_string << table.sub(/^(.*)(\..*)/, '`\1`\2')
end
Expand Down
22 changes: 22 additions & 0 deletions spec/acceptance/types/mysql_grant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,26 @@ class { 'mysql::server': }
expect(apply_manifest(pp, :catch_failures => true).exit_code).to eq(0)
end
end

describe 'adding procedure privileges' do
it 'should work without errors' do
pp = <<-EOS
mysql_grant { 'test2@tester/PROCEDURE test.simpleproc':
ensure => 'present',
table => 'PROCEDURE test.simpleproc',
user => 'test2@tester',
privileges => ['EXECUTE'],
}
EOS

apply_manifest(pp, :catch_failures => true)
end

it 'should find the user' do
shell("mysql -NBe \"SHOW GRANTS FOR test2@tester\"") do |r|
expect(r.stdout).to match(/GRANT EXECUTE ON PROCEDURE `test`.`simpleproc` TO 'test2'@'tester'/)
expect(r.stderr).to be_empty
end
end
end
end