@@ -1014,8 +1014,8 @@ pub fn test_connect() -> *mut TAOS {
10141014 unsafe {
10151015 let taos = taos_connect (
10161016 c"localhost" . as_ptr ( ) ,
1017- c"root" . as_ptr ( ) ,
1018- c"taosdata" . as_ptr ( ) ,
1017+ ptr :: null ( ) ,
1018+ ptr :: null ( ) ,
10191019 ptr:: null ( ) ,
10201020 6041 ,
10211021 ) ;
@@ -1056,6 +1056,7 @@ mod tests {
10561056 use std:: ptr;
10571057
10581058 use faststr:: FastStr ;
1059+ use taos_query:: util:: test_utils:: { test_password, test_username} ;
10591060
10601061 use super :: * ;
10611062 use crate :: ws:: error:: { taos_errno, taos_errstr} ;
@@ -1064,10 +1065,13 @@ mod tests {
10641065 #[ test]
10651066 fn test_taos_connect ( ) {
10661067 unsafe {
1068+ let user = CString :: new ( test_username ( ) ) . unwrap ( ) ;
1069+ let pass = CString :: new ( test_password ( ) ) . unwrap ( ) ;
1070+
10671071 let taos = taos_connect (
10681072 c"localhost" . as_ptr ( ) ,
1069- c"root" . as_ptr ( ) ,
1070- c"taosdata" . as_ptr ( ) ,
1073+ user . as_ptr ( ) ,
1074+ pass . as_ptr ( ) ,
10711075 ptr:: null ( ) ,
10721076 6041 ,
10731077 ) ;
@@ -1098,10 +1102,13 @@ mod tests {
10981102 #[ test]
10991103 fn test_taos_connect_unable_to_establish_connection ( ) {
11001104 unsafe {
1105+ let user = CString :: new ( test_username ( ) ) . unwrap ( ) ;
1106+ let pass = CString :: new ( test_password ( ) ) . unwrap ( ) ;
1107+
11011108 let taos = taos_connect (
11021109 c"invalid_host" . as_ptr ( ) ,
1103- c"root" . as_ptr ( ) ,
1104- c"taosdata" . as_ptr ( ) ,
1110+ user . as_ptr ( ) ,
1111+ pass . as_ptr ( ) ,
11051112 ptr:: null ( ) ,
11061113 6041 ,
11071114 ) ;
@@ -1335,12 +1342,23 @@ mod tests {
13351342 assert ! ( !taos. is_null( ) ) ;
13361343 taos_close ( taos) ;
13371344
1338- let taos = taos_connect_with_dsn ( c"ws://root:taosdata@localhost:6041" . as_ptr ( ) ) ;
1345+ let dsn = CString :: new ( format ! (
1346+ "ws://{}:{}@localhost:6041" ,
1347+ test_username( ) ,
1348+ test_password( )
1349+ ) )
1350+ . unwrap ( ) ;
1351+ let taos = taos_connect_with_dsn ( dsn. as_ptr ( ) ) ;
13391352 assert ! ( !taos. is_null( ) ) ;
13401353 taos_close ( taos) ;
13411354
1342- let taos =
1343- taos_connect_with_dsn ( c"ws://root:taosdata@localhost:6041?read_timeout=1" . as_ptr ( ) ) ;
1355+ let dsn = CString :: new ( format ! (
1356+ "ws://{}:{}@localhost:6041?read_timeout=1" ,
1357+ test_username( ) ,
1358+ test_password( )
1359+ ) )
1360+ . unwrap ( ) ;
1361+ let taos = taos_connect_with_dsn ( dsn. as_ptr ( ) ) ;
13441362 assert ! ( !taos. is_null( ) ) ;
13451363 taos_close ( taos) ;
13461364
@@ -1417,7 +1435,11 @@ mod tests {
14171435
14181436 unsafe {
14191437 let dsn = build_dsn_from_options ( & opts as * const _ ) . unwrap ( ) ;
1420- assert ! ( dsn. starts_with( "ws://root:taosdata@localhost:6041/" ) ) ;
1438+ assert ! ( dsn. starts_with( & format!(
1439+ "ws://{}:{}@localhost:6041/" ,
1440+ test_username( ) ,
1441+ test_password( )
1442+ ) ) ) ;
14211443 }
14221444 }
14231445
@@ -1436,7 +1458,11 @@ mod tests {
14361458
14371459 unsafe {
14381460 let dsn = build_dsn_from_options ( & opts as * const _ ) . unwrap ( ) ;
1439- assert ! ( dsn. starts_with( "ws://root:taosdata@localhost:6041/" ) ) ;
1461+ assert ! ( dsn. starts_with( & format!(
1462+ "ws://{}:{}@localhost:6041/" ,
1463+ test_username( ) ,
1464+ test_password( )
1465+ ) ) ) ;
14401466 }
14411467 }
14421468
@@ -1510,11 +1536,14 @@ mod tests {
15101536 ] ,
15111537 ) ;
15121538
1539+ let user = test_username ( ) ;
1540+ let pass = test_password ( ) ;
1541+
15131542 let opts = make_options ( & [
15141543 ( IP , "localhost" ) ,
15151544 ( PORT , "6041" ) ,
1516- ( USER , "root" ) ,
1517- ( PASS , "taosdata" ) ,
1545+ ( USER , & user ) ,
1546+ ( PASS , & pass ) ,
15181547 ( DB , "test_1765508846" ) ,
15191548 ] ) ;
15201549 let taos = taos_connect_with ( & opts as * const _ ) ;
@@ -1767,12 +1796,15 @@ mod tests {
17671796 ] ,
17681797 ) ;
17691798
1799+ let user = test_username ( ) ;
1800+ let pass = test_password ( ) ;
1801+
17701802 unsafe {
17711803 let opts = make_options ( & [
17721804 ( IP , "localhost" ) ,
17731805 ( PORT , "6445" ) ,
1774- ( USER , "root" ) ,
1775- ( PASS , "taosdata" ) ,
1806+ ( USER , & user ) ,
1807+ ( PASS , & pass ) ,
17761808 ( DB , "test_1765519301" ) ,
17771809 ( WS_TLS_MODE , "3" ) ,
17781810 ( WS_TLS_VERSION , "TLSv1.3,TLSv1.2" ) ,
0 commit comments