Skip to content

Commit 38373bb

Browse files
committed
Merge remote-tracking branch 'origin/wl11231' into wl11451-jdbc
2 parents b51bb85 + 9274daf commit 38373bb

File tree

4 files changed

+75
-1
lines changed

4 files changed

+75
-1
lines changed

devapi/tests/session-t.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ TEST_F(Sess, auth_method)
306306
{
307307
SKIP_IF_NO_XPLUGIN;
308308

309+
USE_NATIVE_PWD;
310+
309311
auto check_user = [](mysqlx::Session &sess)
310312
{
311313
SqlResult res = sess.sql("SELECT CURRENT_USER()").execute();
@@ -418,6 +420,8 @@ TEST_F(Sess, ssl_session)
418420

419421
SKIP_IF_NO_XPLUGIN;
420422

423+
USE_NATIVE_PWD;
424+
421425
//Test if ssl is enabled using cipher
422426
auto check_ssl_impl = [](mysqlx::Session &sess, bool enable, int line)
423427
{
@@ -705,6 +709,8 @@ TEST_F(Sess, ipv6)
705709

706710
SKIP_IF_NO_XPLUGIN;
707711

712+
USE_NATIVE_PWD;
713+
708714
{
709715
mysqlx::Session sess(SessionOption::HOST, "::1",
710716
SessionOption::PORT, get_port(),

testing/test.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class Xplugin : public ::testing::Test
216216
}
217217

218218
}
219+
220+
friend class Use_native_pwd;
219221
};
220222

221223

@@ -228,7 +230,34 @@ class Xplugin::Session : public mysqlx::Session
228230
{}
229231
};
230232

231-
}} // cdk::test
233+
234+
class Use_native_pwd
235+
{
236+
Xplugin& m_xplugin;
237+
const char* m_user;
238+
const char* m_password;
239+
240+
public:
241+
Use_native_pwd(Xplugin &xplugin)
242+
: m_xplugin(xplugin)
243+
{
244+
m_xplugin.sql("CREATE USER unsecure_root IDENTIFIED WITH 'mysql_native_password';");
245+
m_xplugin.sql("grant all on *.* to unsecure_root;");
246+
m_user = m_xplugin.m_user;
247+
m_password = m_xplugin.m_password;
248+
m_xplugin.m_user = "unsecure_root";
249+
m_password = NULL;
250+
}
251+
252+
~Use_native_pwd()
253+
{
254+
m_xplugin.sql("DROP USER unsecure_root");
255+
m_xplugin.m_user = m_user;
256+
m_xplugin.m_password = m_password;
257+
}
258+
};
259+
260+
}} // mysql::test
232261

233262

234263
#define SKIP_IF_NO_XPLUGIN \
@@ -260,3 +289,6 @@ class Xplugin::Session : public mysqlx::Session
260289
} while(false)
261290

262291
#endif
292+
293+
#define USE_NATIVE_PWD \
294+
mysqlx::test::Use_native_pwd __dummy_user__(*this)

xapi/tests/test.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,31 @@ class xapi : public ::testing::Test
290290
public:
291291
mysqlx_session_t *get_session() { return m_sess; }
292292

293+
friend class use_native_pwd;
294+
};
295+
296+
297+
class use_native_pwd
298+
{
299+
xapi& m_xapi;
300+
const char* m_user;
301+
302+
public:
303+
use_native_pwd(xapi &xapi_obj)
304+
: m_xapi(xapi_obj)
305+
{
306+
m_xapi.authenticate();
307+
m_xapi.exec_sql("CREATE USER unsecure_root IDENTIFIED WITH 'mysql_native_password';");
308+
m_xapi.exec_sql("grant all on *.* to unsecure_root;");
309+
m_user = m_xapi.m_xplugin_usr;
310+
m_xapi.m_xplugin_usr = "unsecure_root";
311+
}
312+
313+
~use_native_pwd()
314+
{
315+
m_xapi.exec_sql("DROP USER unsecure_root");
316+
m_xapi.m_xplugin_usr = m_user;
317+
}
293318
};
294319

295320

@@ -312,6 +337,11 @@ class xapi : public ::testing::Test
312337
return; \
313338
}
314339

340+
#define USE_NATIVE_PWD \
341+
use_native_pwd __dummy_user__(*this)
342+
343+
344+
315345
class xapi_bugs : public xapi
316346
{};
317347

xapi/tests/xapi-t.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ TEST_F(xapi, conn_string_test)
327327
{
328328
SKIP_IF_NO_XPLUGIN
329329

330+
USE_NATIVE_PWD;
331+
330332
unsigned short port = 0;
331333
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
332334
std::string conn_str_basic;
@@ -754,6 +756,8 @@ TEST_F(xapi, auth_method)
754756
{
755757
SKIP_IF_NO_XPLUGIN
756758

759+
USE_NATIVE_PWD;
760+
757761
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
758762
int conn_err_code = 0;
759763
mysqlx_session_t *local_sess = NULL;
@@ -931,6 +935,8 @@ TEST_F(xapi, conn_options_test)
931935
{
932936
SKIP_IF_NO_XPLUGIN
933937

938+
USE_NATIVE_PWD;
939+
934940
unsigned int port2 = 0;
935941
unsigned int ssl_enable = 0;
936942
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };

0 commit comments

Comments
 (0)