1919
2020package org .apache .iotdb .pipe .it .single ;
2121
22- import org .apache .iotdb .commons .client .sync .SyncConfigNodeIServiceClient ;
23- import org .apache .iotdb .confignode .rpc .thrift .TShowPipeReq ;
2422import org .apache .iotdb .db .it .utils .TestUtils ;
2523import org .apache .iotdb .it .framework .IoTDBTestRunner ;
2624import org .apache .iotdb .itbase .category .MultiClusterIT1 ;
3331import org .junit .runner .RunWith ;
3432
3533import java .sql .Connection ;
34+ import java .sql .ResultSet ;
3635import java .sql .SQLException ;
3736import java .sql .Statement ;
3837import java .util .Arrays ;
4443public class IoTDBPipePermissionIT extends AbstractPipeSingleIT {
4544 @ Test
4645 public void testSinkPermission () {
47- TestUtils .executeNonQuery (env , "create user `thulab` 'passwd '" , null );
46+ TestUtils .executeNonQuery (env , "create user `thulab` 'StrngPsWd@623451 '" , null );
4847
4948 // Shall fail if username is specified without password
5049 try (final Connection connection = env .getConnection (BaseEnv .TABLE_SQL_DIALECT );
@@ -90,7 +89,8 @@ public void testSinkPermission() {
9089 // Successfully alter
9190 try (final Connection connection = env .getConnection (BaseEnv .TABLE_SQL_DIALECT );
9291 final Statement statement = connection .createStatement ()) {
93- statement .execute ("alter pipe a2b modify sink ('username'='thulab', 'password'='passwd')" );
92+ statement .execute (
93+ "alter pipe a2b modify sink ('username'='thulab', 'password'='StrngPsWd@623451')" );
9494 } catch (final SQLException e ) {
9595 e .printStackTrace ();
9696 fail ("Alter pipe shall not fail if user and password are specified" );
@@ -156,14 +156,12 @@ public void testSinkPermission() {
156156 }
157157
158158 // A user shall only see its own pipe
159- try (final SyncConfigNodeIServiceClient client =
160- (SyncConfigNodeIServiceClient ) env .getLeaderConfigNodeConnection ()) {
161- Assert .assertEquals (
162- 1 ,
163- client
164- .showPipe (new TShowPipeReq ().setIsTableModel (true ).setUserName ("thulab" ))
165- .pipeInfoList
166- .size ());
159+ try (final Connection connection =
160+ env .getConnection ("thulab" , "StrngPsWd@623451" , BaseEnv .TABLE_SQL_DIALECT );
161+ final Statement statement = connection .createStatement ()) {
162+ final ResultSet result = statement .executeQuery ("show pipes" );
163+ Assert .assertTrue (result .next ());
164+ Assert .assertFalse (result .next ());
167165 } catch (Exception e ) {
168166 fail (e .getMessage ());
169167 }
@@ -181,7 +179,8 @@ public void testSinkPermissionWithHistoricalDataAndTablePattern() {
181179 BaseEnv .TABLE_SQL_DIALECT ,
182180 env ,
183181 Arrays .asList (
184- "create user thulab 'passwD@123456'" , "grant INSERT on test.test1 to user thulab" ),
182+ "create user thulab 'StrngPsWd@623451@123456'" ,
183+ "grant INSERT on test.test1 to user thulab" ),
185184 null );
186185
187186 // Write some data
@@ -196,7 +195,7 @@ public void testSinkPermissionWithHistoricalDataAndTablePattern() {
196195 "create pipe a2b "
197196 + "with source ('database'='test1', 'table'='test1') "
198197 + "with processor('processor'='rename-database-processor', 'processor.new-db-name'='test') "
199- + "with sink ('sink'='write-back-sink', 'username'='thulab', 'password'='passwD @123456')" );
198+ + "with sink ('sink'='write-back-sink', 'username'='thulab', 'password'='StrngPsWd@623451 @123456')" );
200199 } catch (final SQLException e ) {
201200 e .printStackTrace ();
202201 fail ("Create pipe without user shall succeed if use the current session" );
0 commit comments