File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 4747 DEFAULT_USER = None
4848
4949DEBUG = False
50+ _DEFAULT_AUTH_PLUGIN = None # if this is not None, use it instead of server's default.
5051
5152TEXT_TYPES = {
5253 FIELD_TYPE .BIT ,
@@ -1158,6 +1159,9 @@ def _get_server_information(self):
11581159 else :
11591160 self ._auth_plugin_name = data [i :server_end ].decode ("utf-8" )
11601161
1162+ if _DEFAULT_AUTH_PLUGIN is not None : # for tests
1163+ self ._auth_plugin_name = _DEFAULT_AUTH_PLUGIN
1164+
11611165 def get_server_info (self ):
11621166 return self .server_version
11631167
Original file line number Diff line number Diff line change @@ -71,6 +71,19 @@ def test_caching_sha2_password():
7171 con .query ("FLUSH PRIVILEGES" )
7272 con .close ()
7373
74+ # Fast path after auth_switch_request
75+ pymysql .connections ._DEFAULT_AUTH_PLUGIN = "mysql_native_password"
76+ con = pymysql .connect (
77+ user = "user_caching_sha2" ,
78+ password = pass_caching_sha2 ,
79+ host = host ,
80+ port = port ,
81+ ssl = ssl ,
82+ )
83+ con .query ("FLUSH PRIVILEGES" )
84+ con .close ()
85+ pymysql .connections ._DEFAULT_AUTH_PLUGIN = None
86+
7487
7588def test_caching_sha2_password_ssl ():
7689 con = pymysql .connect (
@@ -88,7 +101,20 @@ def test_caching_sha2_password_ssl():
88101 password = pass_caching_sha2 ,
89102 host = host ,
90103 port = port ,
91- ssl = None ,
104+ ssl = ssl ,
105+ )
106+ con .query ("FLUSH PRIVILEGES" )
107+ con .close ()
108+
109+ # Fast path after auth_switch_request
110+ pymysql .connections ._DEFAULT_AUTH_PLUGIN = "mysql_native_password"
111+ con = pymysql .connect (
112+ user = "user_caching_sha2" ,
113+ password = pass_caching_sha2 ,
114+ host = host ,
115+ port = port ,
116+ ssl = ssl ,
92117 )
93118 con .query ("FLUSH PRIVILEGES" )
94119 con .close ()
120+ pymysql .connections ._DEFAULT_AUTH_PLUGIN = None
You can’t perform that action at this time.
0 commit comments