forked from puppetlabs/puppetlabs-mysql
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql_server_spec.rb
101 lines (92 loc) · 3.29 KB
/
mysql_server_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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
require 'spec_helper_acceptance'
describe 'mysql class' do
describe 'advanced config' do
let(:pp) do
<<-MANIFEST
class { 'mysql::server':
manage_config_file => 'true',
override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }},
package_ensure => 'present',
purge_conf_dir => 'true',
remove_default_accounts => 'true',
restart => 'true',
root_group => 'root',
root_password => 'test',
service_enabled => 'true',
service_manage => 'true',
users => {
'someuser@localhost' => {
ensure => 'present',
max_connections_per_hour => '0',
max_queries_per_hour => '0',
max_updates_per_hour => '0',
max_user_connections => '0',
password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF',
}},
grants => {
'someuser@localhost/somedb.*' => {
ensure => 'present',
options => ['GRANT'],
privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'],
table => 'somedb.*',
user => 'someuser@localhost',
},
},
databases => {
'somedb' => {
ensure => 'present',
charset => 'utf8',
},
}
}
MANIFEST
end
it_behaves_like 'a idempotent resource'
end
describe 'minimal config' do
before(:all) do
@tmpdir = default.tmpdir('mysql')
end
let(:pp) do
<<-MANIFEST
class { 'mysql::server':
manage_config_file => 'false',
override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }},
package_ensure => 'present',
purge_conf_dir => 'false',
remove_default_accounts => 'false',
restart => 'false',
root_group => 'root',
root_password => 'test',
service_enabled => 'false',
service_manage => 'false',
users => {},
grants => {},
databases => {},
}
MANIFEST
end
it_behaves_like 'a idempotent resource'
end
# rubocop:enable RSpec/InstanceVariable
describe 'syslog configuration' do
let(:pp) do
<<-MANIFEST
class { 'mysql::server':
override_options => { 'mysqld' => { 'log-error' => undef }, 'mysqld_safe' => { 'log-error' => false, 'syslog' => true }},
}
MANIFEST
end
it_behaves_like 'a idempotent resource'
end
context 'when changing the password' do
let(:password) { 'THE NEW SECRET' }
let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" }
it 'does not display the password' do
result = apply_manifest(pp, catch_failures: true)
# this does not actually prove anything, as show_diff in the puppet config defaults to false.
expect(result.stdout).not_to match %r{#{password}}
end
it_behaves_like 'a idempotent resource'
end
end