File tree 3 files changed +29
-5
lines changed
3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 35
35
}
36
36
37
37
# show_diff was added with puppet 3.0
38
- if versioncmp($::puppetversion , ' 3.0' ) < = 0 {
38
+ if versioncmp($::puppetversion , ' 3.0' ) > = 0 {
39
39
File [" ${::root_home} /.my.cnf" ] { show_diff => false }
40
40
}
41
41
if $mysql::server::create_root_user == true {
Original file line number Diff line number Diff line change @@ -64,5 +64,21 @@ class { 'mysql::server':
64
64
apply_manifest ( pp , :catch_changes => true )
65
65
end
66
66
end
67
- end
68
67
68
+ describe 'when changing the password' do
69
+ let ( :password ) { 'THE NEW SECRET' }
70
+ let ( :manifest ) { "class { 'mysql::server': root_password => '#{ password } ' }" }
71
+
72
+ it 'should not display the password' do
73
+ result = apply_manifest ( manifest , :expect_changes => true )
74
+ # this does not actually prove anything, as show_diff in the puppet config defaults to false.
75
+ expect ( result . stdout ) . not_to match /#{ password } /
76
+ end
77
+
78
+ it 'should be idempotent' do
79
+ result = apply_manifest ( manifest , :catch_changes => true )
80
+ end
81
+
82
+ end
83
+
84
+ end
Original file line number Diff line number Diff line change 87
87
describe 'when root_password set' do
88
88
let ( :params ) { { :root_password => 'SET' } }
89
89
it { is_expected . to contain_mysql_user ( 'root@localhost' ) }
90
- it { is_expected . to contain_file ( '/root/.my.cnf' ) . that_requires ( 'Mysql_user[root@localhost]' ) }
90
+ if Puppet . version . to_f >= 3.0
91
+ it { is_expected . to contain_file ( '/root/.my.cnf' ) . with ( :show_diff => false ) . that_requires ( 'Mysql_user[root@localhost]' ) }
92
+ else
93
+ it { is_expected . to contain_file ( '/root/.my.cnf' ) . that_requires ( 'Mysql_user[root@localhost]' ) }
94
+ end
91
95
end
92
96
describe 'when root_password set, create_root_user set to false' do
93
97
let ( :params ) { { :root_password => 'SET' , :create_root_user => false } }
94
98
it { is_expected . not_to contain_mysql_user ( 'root@localhost' ) }
95
- it { is_expected . to contain_file ( '/root/.my.cnf' ) }
99
+ if Puppet . version . to_f >= 3.0
100
+ it { is_expected . to contain_file ( '/root/.my.cnf' ) . with ( :show_diff => false ) }
101
+ else
102
+ it { is_expected . to contain_file ( '/root/.my.cnf' ) }
103
+ end
96
104
end
97
105
describe 'when root_password set, create_root_my_cnf set to false' do
98
106
let ( :params ) { { :root_password => 'SET' , :create_root_my_cnf => false } }
112
120
:onlyif => 'test -f /root/.mysql_secret'
113
121
)
114
122
}
115
- end
123
+ end
116
124
end
117
125
118
126
context 'mysql::server::providers' do
You can’t perform that action at this time.
0 commit comments