File tree 3 files changed +30
-3
lines changed
3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,9 @@ def system_database
119
119
end
120
120
121
121
# Take root@localhost and munge it to 'root'@'localhost'
122
+ # Take root@id123@localhost and munge it to 'root@id123'@'localhost'
122
123
def self . cmd_user ( user )
123
- "'#{ user . sub ( '@' , "'@'" ) } '"
124
+ "'#{ user . reverse . sub ( '@' , "'@'" ) . reverse } '"
124
125
end
125
126
126
127
# Take root.* and return ON `root`.*
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ def self.prefetch(resources)
50
50
end
51
51
52
52
def create
53
- merged_name = @resource [ :name ] . sub ( '@' , "'@'" )
53
+ # (MODULES-3539) Allow @ in username
54
+ merged_name = @resource [ :name ] . reverse . sub ( '@' , "'@'" ) . reverse
54
55
password_hash = @resource . value ( :password_hash )
55
56
plugin = @resource . value ( :plugin )
56
57
max_user_connections = @resource . value ( :max_user_connections ) || 0
@@ -102,7 +103,8 @@ def create
102
103
end
103
104
104
105
def destroy
105
- merged_name = @resource [ :name ] . sub ( '@' , "'@'" )
106
+ # (MODULES-3539) Allow @ in username
107
+ merged_name = @resource [ :name ] . reverse . sub ( '@' , "'@'" ) . reverse
106
108
if_exists = if newer_than ( 'mysql' => '5.7' , 'percona' => '5.7' , 'mariadb' => '10.1.3' )
107
109
'IF EXISTS '
108
110
else
Original file line number Diff line number Diff line change @@ -104,6 +104,30 @@ class { 'mysql::server': }
104
104
end
105
105
end
106
106
107
+ context 'using foo@bar@localhost' do
108
+ describe 'adding user' do
109
+ pp_three = <<-MANIFEST
110
+ mysql_user { 'foo@bar@localhost':
111
+ password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5',
112
+ }
113
+ MANIFEST
114
+ it 'works without errors' do
115
+ execute_manifest ( pp_three , catch_failures : true )
116
+ end
117
+
118
+ it 'finds the user #stdout' do
119
+ shell ( "mysql -NBe \" select '1' from mysql.user where CONCAT(user, '@', host) = 'foo@bar@localhost'\" " ) do |r |
120
+ expect ( r . stdout ) . to match ( %r{^1$} )
121
+ end
122
+ end
123
+ it 'finds the user #stderr' do
124
+ shell ( "mysql -NBe \" select '1' from mysql.user where CONCAT(user, '@', host) = 'foo@bar@localhost'\" " ) do |r |
125
+ expect ( r . stderr ) . to be_empty
126
+ end
127
+ end
128
+ end
129
+ end
130
+
107
131
context 'using ashp@LocalHost' do
108
132
describe 'adding user' do
109
133
pp_four = <<-MANIFEST
You can’t perform that action at this time.
0 commit comments