mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Merge pull request #10140 from BohuTANG/20200409_bug_fix_mysql_handshake_scramble
Fix scramble issue for native mysql-connector-java(JDBC)
This commit is contained in:
commit
9203db0ad5
@ -914,8 +914,17 @@ public:
|
||||
scramble.resize(SCRAMBLE_LENGTH + 1, 0);
|
||||
Poco::RandomInputStream generator;
|
||||
|
||||
for (size_t i = 0; i < SCRAMBLE_LENGTH; i++)
|
||||
/** Generate a random string using ASCII characters but avoid separator character,
|
||||
* produce pseudo random numbers between with about 7 bit worth of entropty between 1-127.
|
||||
* https://github.com/mysql/mysql-server/blob/8.0/mysys/crypt_genhash_impl.cc#L427
|
||||
*/
|
||||
for (size_t i = 0; i < SCRAMBLE_LENGTH; ++i)
|
||||
{
|
||||
generator >> scramble[i];
|
||||
scramble[i] &= 0x7f;
|
||||
if (scramble[i] == '\0' || scramble[i] == '$')
|
||||
scramble[i] = scramble[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
String getName() override
|
||||
@ -993,8 +1002,13 @@ public:
|
||||
scramble.resize(SCRAMBLE_LENGTH + 1, 0);
|
||||
Poco::RandomInputStream generator;
|
||||
|
||||
for (size_t i = 0; i < SCRAMBLE_LENGTH; i++)
|
||||
for (size_t i = 0; i < SCRAMBLE_LENGTH; ++i)
|
||||
{
|
||||
generator >> scramble[i];
|
||||
scramble[i] &= 0x7f;
|
||||
if (scramble[i] == '\0' || scramble[i] == '$')
|
||||
scramble[i] = scramble[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
String getName() override
|
||||
|
@ -278,15 +278,29 @@ def test_java_client(server_address, java_container):
|
||||
with open(os.path.join(SCRIPT_DIR, 'clients', 'java', '0.reference')) as fp:
|
||||
reference = fp.read()
|
||||
|
||||
# database not exists exception.
|
||||
code, (stdout, stderr) = java_container.exec_run('java JavaConnectorTest --host {host} --port {port} --user user_with_empty_password --database '
|
||||
'abc'.format(host=server_address, port=server_port), demux=True)
|
||||
assert code == 1
|
||||
|
||||
# empty password passed.
|
||||
code, (stdout, stderr) = java_container.exec_run('java JavaConnectorTest --host {host} --port {port} --user user_with_empty_password --database '
|
||||
'default'.format(host=server_address, port=server_port), demux=True)
|
||||
assert code == 0
|
||||
assert stdout == reference
|
||||
|
||||
# non-empty password passed.
|
||||
code, (stdout, stderr) = java_container.exec_run('java JavaConnectorTest --host {host} --port {port} --user default --password 123 --database '
|
||||
'default'.format(host=server_address, port=server_port), demux=True)
|
||||
assert code == 0
|
||||
assert stdout == reference
|
||||
|
||||
# double-sha1 password passed.
|
||||
code, (stdout, stderr) = java_container.exec_run('java JavaConnectorTest --host {host} --port {port} --user user_with_double_sha1 --password abacaba --database '
|
||||
'default'.format(host=server_address, port=server_port), demux=True)
|
||||
assert code == 0
|
||||
assert stdout == reference
|
||||
|
||||
|
||||
def test_types(server_address):
|
||||
client = pymysql.connections.Connection(host=server_address, user='default', password='123', database='default', port=server_port)
|
||||
|
Loading…
Reference in New Issue
Block a user