Handle MySQL 8.0 AuthSwitchRequest during authentication#5
Handle MySQL 8.0 AuthSwitchRequest during authentication#5kerryjiang merged 11 commits intomasterfrom
Conversation
…ted to true Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
… comment Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
…aching_sha2 Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
| /// Checks if MySQL server is available for integration tests. | ||
| /// The result is cached after the first check. | ||
| /// </summary> | ||
| public static bool IsMySQLAvailable |
There was a problem hiding this comment.
we should remove the MySQL Availability tool, since MySQL should be available when we run integration tests
There was a problem hiding this comment.
Removed the MySQL availability check tool from TestConst.cs in 4deddb1.
| [Trait("Category", "Integration")] | ||
| public async Task ConnectAsync_WithValidCredentials_ShouldAuthenticateSuccessfully() | ||
| { | ||
| if (!TestConst.IsMySQLAvailable) |
There was a problem hiding this comment.
remove all this kind of checks, since we can always ensure mysql server is available if we want to run integration tests
There was a problem hiding this comment.
Removed all MySQL availability checks from MainTest.cs and other test files in 4deddb1.
…available for integration tests Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
.github/workflows/build.yml
Outdated
| cp tests/SuperSocket.MySQL.Test/mysql.cnf ~/.my.cnf | ||
| sudo systemctl start mysql.service | ||
| mysql -V | ||
| mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;" |
There was a problem hiding this comment.
I got the error "ERROR 1045 (28000): Access denied for user 'runner'@'localhost' (using password: NO)" from this line
There was a problem hiding this comment.
Fixed in e541db7 by using sudo mysql instead of mysql. On Ubuntu, the root MySQL user uses auth_socket by default, so sudo mysql can connect without credentials while mysql as the runner user cannot.
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
.github/workflows/build.yml
Outdated
| cp tests/SuperSocket.MySQL.Test/mysql.cnf ~/.my.cnf | ||
| sudo systemctl start mysql.service | ||
| mysql -V | ||
| sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; FLUSH PRIVILEGES;" |
There was a problem hiding this comment.
I got the error "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)" right now. Can we set auth type for root from ENV?
There was a problem hiding this comment.
Fixed in db4462f by switching to a MySQL Docker service container. This uses MYSQL_ROOT_PASSWORD: root env var to set the password directly, avoiding the auth_socket issues with Ubuntu's pre-installed MySQL. Also changed TestConst.Host to 127.0.0.1 for Docker compatibility.
Co-authored-by: kerryjiang <456060+kerryjiang@users.noreply.github.com>
MySQL 8.0 defaults to
caching_sha2_password. When our client requestsmysql_native_password, the server sends an AuthSwitchRequest (0xFE header) which was incorrectly treated as an EOF packet, causing all integration tests to fail with "Unknown command or packet type. (Error 1047)".Changes
Protocol handling
AuthSwitchRequestPacketto decode plugin name and auth data from switch requestsAuthSwitchResponsePacketto encode auth response for switched pluginMySQLPacketDecoderto distinguish AuthSwitchRequest from EOF during handshake (AuthSwitch has >4 bytes payload)MySQLConnection.ConnectAsync()CI configuration
MYSQL_ROOT_PASSWORDenvironment variable for reliable root password setupmysql_native_passwordauthentication pluginlocalhostto127.0.0.1for Docker compatibilityTests
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.