@@ -2220,6 +2220,16 @@ class BugOra16217765(tests.MySQLConnectorTests):
2220
2220
'password' : 'nativeP@ss' ,
2221
2221
},
2222
2222
}
2223
+ users_nopass = {
2224
+ 'sha256_password' : {
2225
+ 'username' : 'sha256user_np' ,
2226
+ 'password' : '' ,
2227
+ },
2228
+ 'mysql_native_password' : {
2229
+ 'username' : 'nativeuser_np' ,
2230
+ 'password' : '' ,
2231
+ },
2232
+ }
2223
2233
2224
2234
def _create_user (self , cnx , user , password , host , database ,
2225
2235
plugin ):
@@ -2281,28 +2291,28 @@ def test_sha256(self):
2281
2291
})
2282
2292
2283
2293
auth_plugin = 'sha256_password'
2284
- user = self .users [auth_plugin ]
2285
- self ._create_user (self .admin_cnx , user ['username' ],
2286
- user ['password' ],
2287
- self .host ,
2288
- config ['database' ],
2289
- plugin = auth_plugin )
2294
+ for user in ( self .users [auth_plugin ], self . users_nopass [ auth_plugin ]):
2295
+ self ._create_user (self .admin_cnx , user ['username' ],
2296
+ user ['password' ],
2297
+ self .host ,
2298
+ config ['database' ],
2299
+ plugin = auth_plugin )
2290
2300
2291
- config ['user' ] = user ['username' ]
2292
- config ['password' ] = user ['password' ]
2293
- config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2301
+ config ['user' ] = user ['username' ]
2302
+ config ['password' ] = user ['password' ]
2303
+ config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2294
2304
2295
- try :
2296
- cnx = connection .MySQLConnection (** config )
2297
- except :
2298
- import traceback
2299
- traceback .print_exc ()
2300
- self .fail ("Connecting using sha256_password auth failed" )
2305
+ try :
2306
+ cnx = connection .MySQLConnection (** config )
2307
+ except :
2308
+ import traceback
2309
+ traceback .print_exc ()
2310
+ self .fail ("Connecting using sha256_password auth failed" )
2301
2311
2302
- try :
2303
- cnx .cmd_change_user (config ['user' ], config ['password' ])
2304
- except :
2305
- self .fail ("Changing user using sha256_password auth failed" )
2312
+ try :
2313
+ cnx .cmd_change_user (config ['user' ], config ['password' ])
2314
+ except :
2315
+ self .fail ("Changing user using sha256_password auth failed" )
2306
2316
2307
2317
@unittest .skipIf (tests .MYSQL_VERSION < (5 , 6 , 6 ),
2308
2318
"MySQL {0} does not support sha256_password auth" .format (
@@ -2312,18 +2322,18 @@ def test_sha256_nonssl(self):
2312
2322
config ['unix_socket' ] = None
2313
2323
2314
2324
auth_plugin = 'sha256_password'
2315
- user = self .users [auth_plugin ]
2316
- self ._create_user (self .admin_cnx , user ['username' ],
2317
- user ['password' ],
2318
- self .host ,
2319
- config ['database' ],
2320
- plugin = auth_plugin )
2321
-
2322
- config ['user' ] = user ['username' ]
2323
- config ['password' ] = user ['password' ]
2324
- config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2325
- self .assertRaises (errors .InterfaceError , connection .MySQLConnection ,
2326
- ** config )
2325
+ for user in ( self .users [auth_plugin ], self . users_nopass [ auth_plugin ]):
2326
+ self ._create_user (self .admin_cnx , user ['username' ],
2327
+ user ['password' ],
2328
+ self .host ,
2329
+ config ['database' ],
2330
+ plugin = auth_plugin )
2331
+
2332
+ config ['user' ] = user ['username' ]
2333
+ config ['password' ] = user ['password' ]
2334
+ config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2335
+ self .assertRaises (errors .InterfaceError , connection .MySQLConnection ,
2336
+ ** config )
2327
2337
2328
2338
@unittest .skipIf (tests .MYSQL_VERSION < (5 , 5 , 7 ),
2329
2339
"MySQL {0} does not support authentication plugins" .format (
@@ -2333,21 +2343,21 @@ def test_native(self):
2333
2343
config ['unix_socket' ] = None
2334
2344
2335
2345
auth_plugin = 'mysql_native_password'
2336
- user = self .users [auth_plugin ]
2337
- self ._create_user (self .admin_cnx , user ['username' ],
2338
- user ['password' ],
2339
- self .host ,
2340
- config ['database' ],
2341
- plugin = auth_plugin )
2342
-
2343
- config ['user' ] = user ['username' ]
2344
- config ['password' ] = user ['password' ]
2345
- config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2346
- try :
2347
- cnx = connection .MySQLConnection (** config )
2348
- except Exception as exc :
2349
- self .fail ("Connecting using {0} auth failed: {1}" .format (
2350
- auth_plugin , exc ))
2346
+ for user in ( self .users [auth_plugin ], self . users_nopass [ auth_plugin ]):
2347
+ self ._create_user (self .admin_cnx , user ['username' ],
2348
+ user ['password' ],
2349
+ self .host ,
2350
+ config ['database' ],
2351
+ plugin = auth_plugin )
2352
+
2353
+ config ['user' ] = user ['username' ]
2354
+ config ['password' ] = user ['password' ]
2355
+ config ['client_flags' ] = [constants .ClientFlag .PLUGIN_AUTH ]
2356
+ try :
2357
+ cnx = connection .MySQLConnection (** config )
2358
+ except Exception as exc :
2359
+ self .fail ("Connecting using {0} auth failed: {1}" .format (
2360
+ auth_plugin , exc ))
2351
2361
2352
2362
2353
2363
class BugOra18144971 (tests .MySQLConnectorTests ):
0 commit comments