File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 47
47
DEFAULT_USER = None
48
48
49
49
DEBUG = False
50
+ _DEFAULT_AUTH_PLUGIN = None # if this is not None, use it instead of server's default.
50
51
51
52
TEXT_TYPES = {
52
53
FIELD_TYPE .BIT ,
@@ -1158,6 +1159,9 @@ def _get_server_information(self):
1158
1159
else :
1159
1160
self ._auth_plugin_name = data [i :server_end ].decode ("utf-8" )
1160
1161
1162
+ if _DEFAULT_AUTH_PLUGIN is not None : # for tests
1163
+ self ._auth_plugin_name = _DEFAULT_AUTH_PLUGIN
1164
+
1161
1165
def get_server_info (self ):
1162
1166
return self .server_version
1163
1167
Original file line number Diff line number Diff line change @@ -71,6 +71,19 @@ def test_caching_sha2_password():
71
71
con .query ("FLUSH PRIVILEGES" )
72
72
con .close ()
73
73
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
+
74
87
75
88
def test_caching_sha2_password_ssl ():
76
89
con = pymysql .connect (
@@ -88,7 +101,20 @@ def test_caching_sha2_password_ssl():
88
101
password = pass_caching_sha2 ,
89
102
host = host ,
90
103
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 ,
92
117
)
93
118
con .query ("FLUSH PRIVILEGES" )
94
119
con .close ()
120
+ pymysql .connections ._DEFAULT_AUTH_PLUGIN = None
You can’t perform that action at this time.
0 commit comments