fuel-library/deployment/puppet/osnailyfacter/spec/defines/osnailyfacter_mysql_grant_spec.rb
Alex Schultz 44e2c17a48 Fix access for detached database plugin
With the switch to the upstream mysql/galera modules we lost the
additional grants used by the detached database plugin to allow for
database creation and management from other hosts. This change brings
back the additional grants for access along with tests.

Additionally with this change we are adding an ensure_resource for the
/root/.my.cnf because when the detached database used the file does not
exist in the catalog to be switched to a symlink with the spaceship
operator.

Change-Id: I93c985db86ea1f1d27396ee0ef2920b9a9ee2802
Closes-Bug: #1547150
2016-02-22 15:10:43 +00:00

84 lines
1.9 KiB
Ruby

require 'spec_helper'
describe 'osnailyfacter::mysql_grant' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'with defaults' do
let(:title) { 'localhost' }
let(:params) do
{ :user => 'root' }
end
it 'should include mysql grant for localhost by default' do
is_expected.to contain_mysql_user('root@localhost').with(
:password_hash => ''
)
is_expected.to contain_mysql_grant('root@localhost/*.*').with(
:user => 'root@localhost',
:table => '*.*',
:options => ['GRANT'],
:privileges => ['ALL']
)
end
end
context 'with specific database and table' do
let(:title) { 'localhost' }
let(:params) do
{
:user => 'root',
:database => 'testing',
:table => 'testing'
}
end
it 'should include mysql grant for localhost by default' do
is_expected.to contain_mysql_user('root@localhost').with(
:password_hash => ''
)
is_expected.to contain_mysql_grant('root@localhost/testing.testing').with(
:user => 'root@localhost',
:table => 'testing.testing',
:options => ['GRANT'],
:privileges => ['ALL']
)
end
end
context 'with specific custom privileges' do
let(:title) { 'localhost' }
let(:params) do
{
:user => 'root',
:options => '',
:privileges => ['SELECT']
}
end
it 'should include mysql grant for localhost by default' do
is_expected.to contain_mysql_user('root@localhost').with(
:password_hash => ''
)
is_expected.to contain_mysql_grant('root@localhost/*.*').with(
:user => 'root@localhost',
:table => '*.*',
:options => '',
:privileges => ['SELECT']
)
end
end
end