diff --git a/example/db_setup.sql b/example/db_setup.sql index 71ddec1ab..c8face994 100644 --- a/example/db_setup.sql +++ b/example/db_setup.sql @@ -82,7 +82,6 @@ DELIMITER ; -- User DROP USER IF EXISTS 'example_user'@'%'; -CREATE USER 'example_user'@'%' IDENTIFIED WITH 'mysql_native_password'; -ALTER USER 'example_user'@'%' IDENTIFIED BY 'example_password'; +CREATE USER 'example_user'@'%' IDENTIFIED BY 'example_password'; GRANT ALL PRIVILEGES ON boost_mysql_examples.* TO 'example_user'@'%'; FLUSH PRIVILEGES; diff --git a/test/integration/db_setup.sql b/test/integration/db_setup.sql index b256eb776..d04ac3a17 100644 --- a/test/integration/db_setup.sql +++ b/test/integration/db_setup.sql @@ -492,20 +492,9 @@ INSERT INTO types_flags VALUES -- Users DROP USER IF EXISTS 'integ_user'@'%'; -CREATE USER 'integ_user'@'%' IDENTIFIED WITH 'mysql_native_password'; -ALTER USER 'integ_user'@'%' IDENTIFIED BY 'integ_password'; +CREATE USER 'integ_user'@'%' IDENTIFIED BY 'integ_password'; GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'integ_user'@'%'; -DROP USER IF EXISTS 'mysqlnp_user'@'%'; -CREATE USER 'mysqlnp_user'@'%' IDENTIFIED WITH 'mysql_native_password'; -ALTER USER 'mysqlnp_user'@'%' IDENTIFIED BY 'mysqlnp_password'; -GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_user'@'%'; - -DROP USER IF EXISTS 'mysqlnp_empty_password_user'@'%'; -CREATE USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED WITH 'mysql_native_password'; -ALTER USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED BY ''; -GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_empty_password_user'@'%'; - -- Some containers don't allow remote root access. Enable it. CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY ''; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; diff --git a/test/integration/db_setup_mnp.sql b/test/integration/db_setup_mnp.sql new file mode 100644 index 000000000..390461b4e --- /dev/null +++ b/test/integration/db_setup_mnp.sql @@ -0,0 +1,21 @@ +-- +-- Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +-- +-- Distributed under the Boost Software License, Version 1.0. (See accompanying +-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-- + +USE boost_mysql_integtests; + +-- Setup that requires the presence of the mysql_native_password functionality +DROP USER IF EXISTS 'mysqlnp_user'@'%'; +CREATE USER 'mysqlnp_user'@'%' IDENTIFIED WITH 'mysql_native_password'; +ALTER USER 'mysqlnp_user'@'%' IDENTIFIED BY 'mysqlnp_password'; +GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_user'@'%'; + +DROP USER IF EXISTS 'mysqlnp_empty_password_user'@'%'; +CREATE USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED WITH 'mysql_native_password'; +ALTER USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED BY ''; +GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_empty_password_user'@'%'; + +FLUSH PRIVILEGES; diff --git a/test/integration/include/test_integration/server_features.hpp b/test/integration/include/test_integration/server_features.hpp index 017a29ecf..8d25219fc 100644 --- a/test/integration/include/test_integration/server_features.hpp +++ b/test/integration/include/test_integration/server_features.hpp @@ -25,6 +25,9 @@ struct server_features // Includes caching_sha2_password and sha256_password bool sha256{true}; + // Does the server support the mysql_native_password authentication method? + bool mnp{true}; + // Does the server support the dedicated JSON type? bool json_type{true}; diff --git a/test/integration/src/server_features.cpp b/test/integration/src/server_features.cpp index f5246cc4a..e3ac2e8b9 100644 --- a/test/integration/src/server_features.cpp +++ b/test/integration/src/server_features.cpp @@ -56,6 +56,7 @@ static test::server_features do_get_server_features() {"json-type", &test::server_features::json_type }, {"regex-error-codes", &test::server_features::regex_error_codes }, {"dup-query-error-codes", &test::server_features::dup_query_error_codes}, + {"mnp", &test::server_features::mnp }, }; // Match disabled features against the possible set diff --git a/test/integration/test/handshake.cpp b/test/integration/test/handshake.cpp index 186e63f23..819f1569e 100644 --- a/test/integration/test/handshake.cpp +++ b/test/integration/test/handshake.cpp @@ -102,6 +102,7 @@ void check_ssl(Conn& conn, bool expected, boost::source_location loc = BOOST_MYS } // mysql_native_password +BOOST_TEST_DECORATOR(*run_if(&server_features::mnp)) BOOST_AUTO_TEST_SUITE(mysql_native_password) constexpr const char* regular_user = "mysqlnp_user"; diff --git a/tools/ci/ci_util/db_setup.py b/tools/ci/ci_util/db_setup.py index 86a57086c..e3322493e 100644 --- a/tools/ci/ci_util/db_setup.py +++ b/tools/ci/ci_util/db_setup.py @@ -18,7 +18,8 @@ class _DbSystemType(Enum): mysql5 = 1 mysql8 = 2 - mariadb = 3 + mysql9 = 3 + mariadb = 4 def _run_piped_stdin(args: List[str], fname: Path) -> None: @@ -54,8 +55,12 @@ def _parse_db_version(db: str) -> _DbSystemType: # Perform the matching if is_mariadb: return _DbSystemType.mariadb + elif vmaj == 8: + return _DbSystemType.mysql8 + elif vmaj >= 9: + return _DbSystemType.mysql9 else: - return _DbSystemType.mysql8 if vmaj >= 8 else _DbSystemType.mysql5 + return _DbSystemType.mysql5 def _compute_disabled_features(db: _DbSystemType) -> Dict[str, bool]: @@ -73,7 +78,10 @@ def _compute_disabled_features(db: _DbSystemType) -> Dict[str, bool]: 'regex-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mariadb), # dup-query-error-codes. Disabled in mysql systems - 'dup-query-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mysql8), + 'dup-query-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mysql8, _DbSystemType.mysql9), + + # mysql_native_password. Disabled in mysql9 + 'mnp': db == _DbSystemType.mysql9, } @@ -96,6 +104,8 @@ def db_setup( _run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup.sql')) if not disabled_features['sha256']: _run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup_sha256.sql')) + if not disabled_features['mnp']: + _run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup_mnp.sql')) # Setup environment variables os.environ['BOOST_MYSQL_SERVER_HOST'] = server_host