2012-04-24 08:41:12 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'mysql::server::account_security' do
|
2015-10-13 12:29:42 +02:00
|
|
|
on_supported_os.each do |os, facts|
|
|
|
|
context "on #{os}" do
|
|
|
|
context "with fqdn==myhost.mydomain" do
|
|
|
|
let(:facts) {
|
|
|
|
facts.merge({
|
|
|
|
:root_home => '/root',
|
|
|
|
:fqdn => 'myhost.mydomain',
|
|
|
|
:hostname => 'myhost',
|
|
|
|
})
|
|
|
|
}
|
2012-04-24 08:41:12 +02:00
|
|
|
|
2014-08-08 22:41:23 +02:00
|
|
|
[ 'root@myhost.mydomain',
|
|
|
|
'root@127.0.0.1',
|
|
|
|
'root@::1',
|
|
|
|
'@myhost.mydomain',
|
|
|
|
'@localhost',
|
|
|
|
'@%',
|
|
|
|
].each do |user|
|
2015-01-10 17:17:35 +01:00
|
|
|
it "removes Mysql_User[#{user}]" do
|
2014-08-08 22:41:23 +02:00
|
|
|
is_expected.to contain_mysql_user(user).with_ensure('absent')
|
|
|
|
end
|
2014-07-28 07:51:22 +02:00
|
|
|
end
|
2014-08-08 22:41:23 +02:00
|
|
|
|
|
|
|
# When the hostname doesn't match the fqdn we also remove these.
|
|
|
|
# We don't need to test the inverse as when they match they are
|
|
|
|
# covered by the above list.
|
|
|
|
[ 'root@myhost', '@myhost' ].each do |user|
|
2015-01-10 17:17:35 +01:00
|
|
|
it "removes Mysql_User[#{user}]" do
|
2014-08-08 22:41:23 +02:00
|
|
|
is_expected.to contain_mysql_user(user).with_ensure('absent')
|
|
|
|
end
|
2014-07-28 07:51:22 +02:00
|
|
|
end
|
2012-04-24 08:41:12 +02:00
|
|
|
|
2014-07-28 07:51:22 +02:00
|
|
|
it 'should remove Mysql_database[test]' do
|
2014-08-08 21:27:07 +02:00
|
|
|
is_expected.to contain_mysql_database('test').with_ensure('absent')
|
2014-07-28 07:51:22 +02:00
|
|
|
end
|
|
|
|
end
|
2015-01-10 17:17:35 +01:00
|
|
|
|
2015-10-13 12:29:42 +02:00
|
|
|
context "with fqdn==localhost" do
|
|
|
|
let(:facts) {
|
|
|
|
facts.merge({
|
|
|
|
:root_home => '/root',
|
|
|
|
:fqdn => 'localhost',
|
|
|
|
:hostname => 'localhost',
|
|
|
|
})
|
|
|
|
}
|
2015-01-10 17:17:35 +01:00
|
|
|
|
|
|
|
[ 'root@127.0.0.1',
|
|
|
|
'root@::1',
|
|
|
|
'@localhost',
|
|
|
|
'root@localhost.localdomain',
|
|
|
|
'@localhost.localdomain',
|
|
|
|
'@%',
|
|
|
|
].each do |user|
|
|
|
|
it "removes Mysql_User[#{user}]" do
|
|
|
|
is_expected.to contain_mysql_user(user).with_ensure('absent')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-13 12:29:42 +02:00
|
|
|
context "with fqdn==localhost.localdomain" do
|
|
|
|
let(:facts) {
|
|
|
|
facts.merge({
|
|
|
|
:root_home => '/root',
|
|
|
|
:fqdn => 'localhost.localdomain',
|
|
|
|
:hostname => 'localhost',
|
|
|
|
})
|
|
|
|
}
|
2015-01-10 17:17:35 +01:00
|
|
|
|
|
|
|
[ 'root@127.0.0.1',
|
|
|
|
'root@::1',
|
|
|
|
'@localhost',
|
|
|
|
'root@localhost.localdomain',
|
|
|
|
'@localhost.localdomain',
|
|
|
|
'@%',
|
|
|
|
].each do |user|
|
|
|
|
it "removes Mysql_User[#{user}]" do
|
|
|
|
is_expected.to contain_mysql_user(user).with_ensure('absent')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-07-28 07:51:22 +02:00
|
|
|
end
|
2012-04-24 08:41:12 +02:00
|
|
|
end
|
|
|
|
end
|