Skip to content

Commit e51e5ea

Browse files
committed
Fix bootstrapping mechanism
As part of MySQL Server release 8.4.0, the server option `--ssl` has been removed. This change affected the bootstrapping mechanism used by Connector/Python for running tests. This patch fixes the issue by utilizing the option `--require_secure_transport` as a replacement. Change-Id: I5386c5296bca93626f81520ac18685d249723dd1
1 parent a5fdd71 commit e51e5ea

File tree

5 files changed

+28
-25
lines changed

5 files changed

+28
-25
lines changed

mysql-connector-python/tests/mysqld.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ def mysqlx_unix_socket(self):
645645
return self._mysqlx_unix_socket
646646

647647
def update_config(self, **kwargs):
648+
if kwargs.get("ssl"):
649+
kwargs["ssl"] = "on" if kwargs["ssl"] else "off"
650+
648651
options = {
649652
"name": self._name,
650653
"basedir": _convert_forward_slash(self._basedir),
@@ -663,7 +666,7 @@ def update_config(self, **kwargs):
663666
"pid_file": _convert_forward_slash(self._pid_file),
664667
"serverid": self._serverid,
665668
"lc_messages_dir": _convert_forward_slash(self._lc_messages_dir),
666-
"ssl": 1,
669+
"ssl": "off",
667670
}
668671

669672
cnf = kwargs.pop("my_cnf", self._cnf)

mysql-connector-python/tests/test_bugs.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4789,15 +4789,15 @@ def _enable_ssl(self):
47894789
self.server.stop()
47904790
self.server.wait_down()
47914791

4792-
self.server.start()
4792+
self.server.start(ssl=1)
47934793
self.server.wait_up()
47944794
time.sleep(1)
47954795

4796-
def _verify_ssl(self, cnx, available=True):
4796+
def _verify_ssl(self, cnx, ssl_available=True):
47974797
cur = cnx.cursor()
47984798
cur.execute("SHOW STATUS LIKE 'Ssl_version'")
47994799
result = cur.fetchall()[0]
4800-
if available:
4800+
if ssl_available:
48014801
self.assertNotEqual(result[1], "")
48024802
else:
48034803
self.assertEqual(result[1], "")
@@ -4812,33 +4812,24 @@ def test_ssl_disabled_cext(self):
48124812
self._test_ssl_modes()
48134813

48144814
def _test_ssl_modes(self):
4815+
# SSL isn't disabled by default on the connector side,
4816+
# however, it is disabled, on the custom bootstrapped server.
48154817
config = self.config.copy()
4816-
# With SSL on server
4817-
# default
4818-
cnx = mysql.connector.connect(**config)
4819-
self._verify_ssl(cnx)
48204818

48214819
# disabled
48224820
config["ssl_disabled"] = True
48234821
cnx = mysql.connector.connect(**config)
4824-
self._verify_ssl(cnx, False)
4822+
self._verify_ssl(cnx, ssl_available=False)
48254823

4826-
self._disable_ssl()
4827-
config = self.config.copy()
4828-
config["ssl_ca"] = tests.SSL_CA
4829-
# Without SSL on server
4824+
# With SSL on server
48304825
try:
4831-
# default
4832-
cnx = mysql.connector.connect(**config)
4833-
self._verify_ssl(cnx, False)
4834-
4835-
# disabled
4836-
config["ssl_disabled"] = True
4826+
self._enable_ssl()
4827+
config["ssl_ca"] = tests.SSL_CA
4828+
config["ssl_disabled"] = False
48374829
cnx = mysql.connector.connect(**config)
4838-
self._verify_ssl(cnx, False)
4839-
4830+
self._verify_ssl(cnx, ssl_available=True)
48404831
finally:
4841-
self._enable_ssl()
4832+
self._disable_ssl()
48424833

48434834

48444835
class BugOra25589496(tests.MySQLConnectorTests):

mysql-connector-python/unittests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@
168168
"MYSQL", os.path.join("/", "usr", "local", "mysql")
169169
)
170170

171-
MY_CNF += "\nssl={ssl}"
171+
# When this option is enabled, connections attempted using
172+
# insecure transport will be rejected. Secure transports
173+
# are SSL/TLS, Unix socket or Shared Memory (on Windows).
174+
MY_CNF += "\nrequire_secure_transport={ssl}"
172175

173176
MYSQL_DEFAULT_TOPDIR = _TOPDIR
174177

mysqlx-connector-python/tests/mysqld.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ def mysqlx_unix_socket(self):
645645
return self._mysqlx_unix_socket
646646

647647
def update_config(self, **kwargs):
648+
if kwargs.get("ssl"):
649+
kwargs["ssl"] = "on" if kwargs["ssl"] else "off"
650+
648651
options = {
649652
"name": self._name,
650653
"basedir": _convert_forward_slash(self._basedir),
@@ -663,7 +666,7 @@ def update_config(self, **kwargs):
663666
"pid_file": _convert_forward_slash(self._pid_file),
664667
"serverid": self._serverid,
665668
"lc_messages_dir": _convert_forward_slash(self._lc_messages_dir),
666-
"ssl": 1,
669+
"ssl": "off",
667670
}
668671

669672
cnf = kwargs.pop("my_cnf", self._cnf)

mysqlx-connector-python/unittests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@
165165
"MYSQL", os.path.join("/", "usr", "local", "mysql")
166166
)
167167

168-
MY_CNF += "\nssl={ssl}"
168+
# When this option is enabled, connections attempted using
169+
# insecure transport will be rejected. Secure transports
170+
# are SSL/TLS, Unix socket or Shared Memory (on Windows).
171+
MY_CNF += "\nrequire_secure_transport={ssl}"
169172

170173
MYSQL_DEFAULT_TOPDIR = _TOPDIR
171174

0 commit comments

Comments
 (0)