Skip to content

Commit b9b7b9a

Browse files
committed
Fixed testcase asserting default auth plugin name
Fixed bug where used auth plugin was not updated
1 parent 7c3bfbf commit b9b7b9a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

aiomysql/connection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,10 @@ async def _process_auth(self, plugin_name, auth_packet):
798798
# These auth plugins do their own packet handling
799799
if plugin_name == b"caching_sha2_password":
800800
await self.caching_sha2_password_auth(auth_packet)
801+
self._auth_plugin_used = plugin_name
801802
elif plugin_name == b"sha256_password":
802803
await self.sha256_password_auth(auth_packet)
804+
self._auth_plugin_used = plugin_name
803805
else:
804806

805807
if plugin_name == b"mysql_native_password":

tests/test_ssl.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ async def test_auth_plugin_renegotiation(mysql_server, loop):
4444

4545
assert len(value), 'No databases found'
4646

47+
# Check we tried to use the cleartext plugin
4748
assert conn._client_auth_plugin == 'mysql_clear_password', \
4849
'Client did not try clear password auth'
49-
assert conn._server_auth_plugin == 'mysql_native_password', \
50+
51+
# Check the server asked us to use MySQL's default plugin
52+
assert conn._server_auth_plugin in (
53+
'mysql_native_password', 'caching_sha2_password'), \
5054
'Server did not ask for native auth'
51-
assert conn._auth_plugin_used == b'mysql_native_password', \
52-
'Client did not renegotiate with native auth'
55+
# Check we actually used the servers default plugin
56+
assert conn._auth_plugin_used in (
57+
b'mysql_native_password', b'caching_sha2_password'), \
58+
'Client did not renegotiate with server\'s default auth'

0 commit comments

Comments
 (0)