Skip to content

Commit 46df142

Browse files
committed
Fix tls_deprecation() UT.
1 parent 531c414 commit 46df142

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

test/unit/classes/connection.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,12 +3899,26 @@ void connection::mfa()
38993899

39003900
}
39013901

3902-
void connection::tls_deprecation()
3902+
bool connection::check_tls_ver(const char* tls_ver)
39033903
{
3904-
// TODO: remove this block when the test is fixed
3905-
if (!getenv("MYSQL_TLS_DEPRECATION"))
3906-
return;
3904+
try {
3905+
3906+
sql::ConnectOptionsMap opt;
3907+
opt[OPT_TLS_VERSION]=tls_ver;
3908+
3909+
Connection my_con(getConnection(&opt));
3910+
3911+
return my_con->isValid();
39073912

3913+
}
3914+
catch (const sql::SQLException&)
3915+
{
3916+
return false;
3917+
}
3918+
}
3919+
3920+
void connection::tls_deprecation()
3921+
{
39083922
sql::ConnectOptionsMap opt;
39093923
opt[OPT_HOSTNAME]=url;
39103924
opt[OPT_USERNAME]=user;
@@ -3920,7 +3934,9 @@ void connection::tls_deprecation()
39203934
TEST_CASES test_cases[] =
39213935
{
39223936
{"TLSv1.1,TLSv1.2" ,true },
3923-
{"foo,TLSv1.3" ,true },
3937+
//Not all platforms support TLSv1.3
3938+
{"foo,TLSv1.3" ,check_tls_ver("TLSv1.3")},
3939+
{"foo,TLSv1.2" ,true },
39243940
{"TLSv1.0,TLSv1.1" ,false},
39253941
{"foo,TLSv1.1" ,false},
39263942
{"foo,bar" ,false},

test/unit/classes/connection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class connection : public unit_fixture
4848
typedef unit_fixture super;
4949

5050
protected:
51+
52+
bool check_tls_ver(const char* tls_ver);
53+
5154
public:
5255

5356
EXAMPLE_TEST_FIXTURE(connection)

0 commit comments

Comments
 (0)