Skip to content

Commit 04e5cc0

Browse files
committed
(maint) Plugins don't exist before 5.5; password field name changed
1 parent e0e0c0f commit 04e5cc0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

spec/acceptance/types/mysql_user_spec.rb

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper_acceptance'
2+
require_relative '../mysql_helper.rb'
23

34
describe 'mysql_user' do
45
describe 'setup' do
@@ -44,7 +45,9 @@ class { 'mysql::server': }
4445
end
4546
end
4647

47-
describe 'changing authentication plugin' do
48+
pre_run
49+
50+
describe 'changing authentication plugin', if: version_is_greater_than('5.5.0') do
4851
it 'should work without errors' do
4952
pp = <<-EOS
5053
mysql_user { 'ashp@localhost':
@@ -63,7 +66,13 @@ class { 'mysql::server': }
6366
end
6467

6568
it 'should not have a password' do
66-
shell("mysql -NBe \"select password from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
69+
pre_run
70+
table = if version_is_greater_than('5.7.0')
71+
"authentication_string"
72+
else
73+
"password"
74+
end
75+
shell("mysql -NBe \"select #{table} from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r|
6776
expect(r.stdout.rstrip).to be_empty
6877
expect(r.stderr).to be_empty
6978
end

spec/unit/puppet/provider/mysql_user/mysql_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
context 'MySQL < 5.7.6' do
283283
it 'changes the authentication plugin' do
284284
provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string])
285-
provider.expects(:mysql).with([defaults_file, system_database, '-e', "UPDATE mysql.user SET plugin = 'auth_socket', password = '' WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('0')
285+
provider.class.expects(:mysql_caller).with("UPDATE mysql.user SET plugin = 'auth_socket', password = '' WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'system').returns('0')
286286

287287
provider.expects(:plugin).returns('auth_socket')
288288
provider.plugin = 'auth_socket'
@@ -292,7 +292,7 @@
292292
context 'MySQL >= 5.7.6' do
293293
it 'changes the authentication plugin' do
294294
provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string])
295-
provider.expects(:mysql).with([defaults_file, system_database, '-e', "ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'auth_socket'"]).returns('0')
295+
provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'auth_socket'", 'system').returns('0')
296296

297297
provider.expects(:plugin).returns('auth_socket')
298298
provider.plugin = 'auth_socket'
@@ -304,7 +304,7 @@
304304
context 'MySQL < 5.7.6' do
305305
it 'changes the authentication plugin' do
306306
provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string])
307-
provider.expects(:mysql).with([defaults_file, system_database, '-e', "UPDATE mysql.user SET plugin = 'mysql_native_password', password = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4' WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('0')
307+
provider.class.expects(:mysql_caller).with("UPDATE mysql.user SET plugin = 'mysql_native_password', password = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4' WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'system').returns('0')
308308

309309
provider.expects(:plugin).returns('mysql_native_password')
310310
provider.plugin = 'mysql_native_password'
@@ -314,7 +314,7 @@
314314
context 'MySQL >= 5.7.6' do
315315
it 'changes the authentication plugin' do
316316
provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string])
317-
provider.expects(:mysql).with([defaults_file, system_database, '-e', "ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'"]).returns('0')
317+
provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'", 'system').returns('0')
318318

319319
provider.expects(:plugin).returns('mysql_native_password')
320320
provider.plugin = 'mysql_native_password'

0 commit comments

Comments
 (0)