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 @@ -306,6 +306,8 @@ TEST_F(Sess, auth_method)
306
306
{
307
307
SKIP_IF_NO_XPLUGIN;
308
308
309
+ USE_NATIVE_PWD;
310
+
309
311
auto check_user = [](mysqlx::Session &sess)
310
312
{
311
313
SqlResult res = sess.sql (" SELECT CURRENT_USER()" ).execute ();
@@ -418,6 +420,8 @@ TEST_F(Sess, ssl_session)
418
420
419
421
SKIP_IF_NO_XPLUGIN;
420
422
423
+ USE_NATIVE_PWD;
424
+
421
425
// Test if ssl is enabled using cipher
422
426
auto check_ssl_impl = [](mysqlx::Session &sess, bool enable, int line)
423
427
{
@@ -705,6 +709,8 @@ TEST_F(Sess, ipv6)
705
709
706
710
SKIP_IF_NO_XPLUGIN;
707
711
712
+ USE_NATIVE_PWD;
713
+
708
714
{
709
715
mysqlx::Session sess (SessionOption::HOST, " ::1" ,
710
716
SessionOption::PORT, get_port (),
Original file line number Diff line number Diff line change @@ -216,6 +216,8 @@ class Xplugin : public ::testing::Test
216
216
}
217
217
218
218
}
219
+
220
+ friend class Use_native_pwd ;
219
221
};
220
222
221
223
@@ -228,7 +230,34 @@ class Xplugin::Session : public mysqlx::Session
228
230
{}
229
231
};
230
232
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
232
261
233
262
234
263
#define SKIP_IF_NO_XPLUGIN \
@@ -260,3 +289,6 @@ class Xplugin::Session : public mysqlx::Session
260
289
} while (false )
261
290
262
291
#endif
292
+
293
+ #define USE_NATIVE_PWD \
294
+ mysqlx::test::Use_native_pwd __dummy_user__ (*this )
Original file line number Diff line number Diff line change @@ -290,6 +290,31 @@ class xapi : public ::testing::Test
290
290
public:
291
291
mysqlx_session_t *get_session () { return m_sess; }
292
292
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
+ }
293
318
};
294
319
295
320
@@ -312,6 +337,11 @@ class xapi : public ::testing::Test
312
337
return ; \
313
338
}
314
339
340
+ #define USE_NATIVE_PWD \
341
+ use_native_pwd __dummy_user__ (*this )
342
+
343
+
344
+
315
345
class xapi_bugs : public xapi
316
346
{};
317
347
Original file line number Diff line number Diff line change @@ -327,6 +327,8 @@ TEST_F(xapi, conn_string_test)
327
327
{
328
328
SKIP_IF_NO_XPLUGIN
329
329
330
+ USE_NATIVE_PWD;
331
+
330
332
unsigned short port = 0 ;
331
333
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
332
334
std::string conn_str_basic;
@@ -754,6 +756,8 @@ TEST_F(xapi, auth_method)
754
756
{
755
757
SKIP_IF_NO_XPLUGIN
756
758
759
+ USE_NATIVE_PWD;
760
+
757
761
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
758
762
int conn_err_code = 0 ;
759
763
mysqlx_session_t *local_sess = NULL ;
@@ -931,6 +935,8 @@ TEST_F(xapi, conn_options_test)
931
935
{
932
936
SKIP_IF_NO_XPLUGIN
933
937
938
+ USE_NATIVE_PWD;
939
+
934
940
unsigned int port2 = 0 ;
935
941
unsigned int ssl_enable = 0 ;
936
942
char conn_error[MYSQLX_MAX_ERROR_LEN] = { 0 };
You can’t perform that action at this time.
0 commit comments