File tree Expand file tree Collapse file tree 4 files changed +75
-1
lines changed Expand file tree Collapse file tree 4 files changed +75
-1
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,8 @@ TEST_F(Sess, auth_method)
301
301
302
302
SKIP_IF_NO_XPLUGIN;
303
303
304
+ USE_NATIVE_PWD;
305
+
304
306
auto check_user = [](mysqlx::Session &sess)
305
307
{
306
308
SqlResult res = sess.sql (" SELECT CURRENT_USER()" ).execute ();
@@ -413,6 +415,8 @@ TEST_F(Sess, ssl_session)
413
415
414
416
SKIP_IF_NO_XPLUGIN;
415
417
418
+ USE_NATIVE_PWD;
419
+
416
420
// Test if ssl is enabled using cipher
417
421
auto check_ssl_impl = [](mysqlx::Session &sess, bool enable, int line)
418
422
{
@@ -698,6 +702,8 @@ TEST_F(Sess, ipv6)
698
702
699
703
SKIP_IF_NO_XPLUGIN;
700
704
705
+ USE_NATIVE_PWD;
706
+
701
707
{
702
708
mysqlx::Session sess (SessionOption::HOST, " ::1" ,
703
709
SessionOption::PORT, get_port (),
Original file line number Diff line number Diff line change @@ -211,6 +211,8 @@ class Xplugin : public ::testing::Test
211
211
}
212
212
213
213
}
214
+
215
+ friend class Use_native_pwd ;
214
216
};
215
217
216
218
@@ -223,7 +225,34 @@ class Xplugin::Session : public mysqlx::Session
223
225
{}
224
226
};
225
227
226
- }} // cdk::test
228
+
229
+ class Use_native_pwd
230
+ {
231
+ Xplugin& m_xplugin;
232
+ const char * m_user;
233
+ const char * m_password;
234
+
235
+ public:
236
+ Use_native_pwd (Xplugin &xplugin)
237
+ : m_xplugin(xplugin)
238
+ {
239
+ m_xplugin.sql (" CREATE USER unsecure_root IDENTIFIED WITH 'mysql_native_password';" );
240
+ m_xplugin.sql (" grant all on *.* to unsecure_root;" );
241
+ m_user = m_xplugin.m_user ;
242
+ m_password = m_xplugin.m_password ;
243
+ m_xplugin.m_user = " unsecure_root" ;
244
+ m_password = NULL ;
245
+ }
246
+
247
+ ~Use_native_pwd ()
248
+ {
249
+ m_xplugin.sql (" DROP USER unsecure_root" );
250
+ m_xplugin.m_user = m_user;
251
+ m_xplugin.m_password = m_password;
252
+ }
253
+ };
254
+
255
+ }} // mysql::test
227
256
228
257
229
258
#define SKIP_IF_NO_XPLUGIN \
@@ -255,3 +284,6 @@ class Xplugin::Session : public mysqlx::Session
255
284
} while (false )
256
285
257
286
#endif
287
+
288
+ #define USE_NATIVE_PWD \
289
+ mysqlx::test::Use_native_pwd __dummy_user__ (*this )
Original file line number Diff line number Diff line change @@ -284,6 +284,31 @@ class xapi : public ::testing::Test
284
284
public:
285
285
mysqlx_session_t *get_session () { return m_sess; }
286
286
287
+ friend class use_native_pwd ;
288
+ };
289
+
290
+
291
+ class use_native_pwd
292
+ {
293
+ xapi& m_xapi;
294
+ const char * m_user;
295
+
296
+ public:
297
+ use_native_pwd (xapi &xapi_obj)
298
+ : m_xapi(xapi_obj)
299
+ {
300
+ m_xapi.authenticate ();
301
+ m_xapi.exec_sql (" CREATE USER unsecure_root IDENTIFIED WITH 'mysql_native_password';" );
302
+ m_xapi.exec_sql (" grant all on *.* to unsecure_root;" );
303
+ m_user = m_xapi.m_xplugin_usr ;
304
+ m_xapi.m_xplugin_usr = " unsecure_root" ;
305
+ }
306
+
307
+ ~use_native_pwd ()
308
+ {
309
+ m_xapi.exec_sql (" DROP USER unsecure_root" );
310
+ m_xapi.m_xplugin_usr = m_user;
311
+ }
287
312
};
288
313
289
314
@@ -306,6 +331,11 @@ class xapi : public ::testing::Test
306
331
return ; \
307
332
}
308
333
334
+ #define USE_NATIVE_PWD \
335
+ use_native_pwd __dummy_user__ (*this )
336
+
337
+
338
+
309
339
class xapi_bugs : public xapi
310
340
{};
311
341
Original file line number Diff line number Diff line change @@ -321,6 +321,8 @@ TEST_F(xapi, conn_string_test)
321
321
{
322
322
SKIP_IF_NO_XPLUGIN
323
323
324
+ USE_NATIVE_PWD;
325
+
324
326
unsigned short port = 0 ;
325
327
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
326
328
std::string conn_str_basic;
@@ -748,6 +750,8 @@ TEST_F(xapi, auth_method)
748
750
{
749
751
SKIP_IF_NO_XPLUGIN
750
752
753
+ USE_NATIVE_PWD;
754
+
751
755
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
752
756
int conn_err_code = 0 ;
753
757
mysqlx_session_t *local_sess = NULL ;
@@ -925,6 +929,8 @@ TEST_F(xapi, conn_options_test)
925
929
{
926
930
SKIP_IF_NO_XPLUGIN
927
931
932
+ USE_NATIVE_PWD;
933
+
928
934
unsigned int port2 = 0 ;
929
935
unsigned int ssl_enable = 0 ;
930
936
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
You can’t perform that action at this time.
0 commit comments