forked from puppetlabs/puppetlabs-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_server_account_security_spec.rb
86 lines (78 loc) · 2.33 KB
/
mysql_server_account_security_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require 'spec_helper'
describe 'mysql::server::account_security' do
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',
})
}
[ 'root@myhost.mydomain',
'root@127.0.0.1',
'root@::1',
'@myhost.mydomain',
'@localhost',
'@%',
].each do |user|
it "removes Mysql_User[#{user}]" do
is_expected.to contain_mysql_user(user).with_ensure('absent')
end
end
# 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|
it "removes Mysql_User[#{user}]" do
is_expected.to contain_mysql_user(user).with_ensure('absent')
end
end
it 'should remove Mysql_database[test]' do
is_expected.to contain_mysql_database('test').with_ensure('absent')
end
end
context "with fqdn==localhost" do
let(:facts) {
facts.merge({
:root_home => '/root',
:fqdn => 'localhost',
:hostname => 'localhost',
})
}
[ '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
context "with fqdn==localhost.localdomain" do
let(:facts) {
facts.merge({
:root_home => '/root',
:fqdn => 'localhost.localdomain',
:hostname => 'localhost',
})
}
[ '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
end
end
end