77import java .util .Properties ;
88
99import org .junit .jupiter .api .AfterAll ;
10+ import org .junit .jupiter .api .Assertions ;
1011import org .junit .jupiter .api .BeforeAll ;
1112import org .junit .jupiter .api .Test ;
1213import org .junit .jupiter .api .extension .RegisterExtension ;
@@ -64,8 +65,9 @@ private ConnectionSupplier connectByAuthority(String username, String password)
6465 return () -> DriverManager .getConnection (jdbcURL .disableToken ().withAutority (username , password ).build ());
6566 }
6667
67- private void testConnection (ConnectionSupplier connectionSupplier ) throws SQLException {
68+ private void testConnection (ConnectionSupplier connectionSupplier , String userName ) throws SQLException {
6869 try (Connection connection = connectionSupplier .get ()) {
70+ Assertions .assertEquals (userName , connection .getMetaData ().getUserName ());
6971 try (Statement statement = connection .createStatement ()) {
7072 statement .execute ("SELECT 1;" );
7173 }
@@ -75,22 +77,22 @@ private void testConnection(ConnectionSupplier connectionSupplier) throws SQLExc
7577 private void wrongConnection (ConnectionSupplier connectionSupplier ) {
7678 ExceptionAssert .sqlException ("Cannot connect to YDB: gRPC error: (INTERNAL) get token exception: "
7779 + "Can't login, code: UNAUTHORIZED, issues: [#400020 Invalid password (S_FATAL)]" ,
78- () -> testConnection (connectionSupplier ));
80+ () -> testConnection (connectionSupplier , null ));
7981 }
8082
8183 @ Test
8284 public void connectOK () throws SQLException {
83- testConnection (connectByProperties ("user1" , "" ));
84- testConnection (connectByAuthority ("user1" , "" ));
85+ testConnection (connectByProperties ("user1" , "" ), "user1" );
86+ testConnection (connectByAuthority ("user1" , "" ), "user1" );
8587
86- testConnection (connectByProperties ("user1" , null ));
87- testConnection (connectByAuthority ("user1" , null ));
88+ testConnection (connectByProperties ("user1" , null ), "user1" );
89+ testConnection (connectByAuthority ("user1" , null ), "user1" );
8890
89- testConnection (connectByProperties ("user2" , "pwss" ));
90- testConnection (connectByAuthority ("user2" , "pwss" ));
91+ testConnection (connectByProperties ("user2" , "pwss" ), "user2" );
92+ testConnection (connectByAuthority ("user2" , "pwss" ), "user2" );
9193
92- testConnection (connectByProperties ("user3" , "pw :ss;" ));
93- testConnection (connectByAuthority ("user3" , "pw :ss;" ));
94+ testConnection (connectByProperties ("user3" , "pw :ss;" ), "user3" );
95+ testConnection (connectByAuthority ("user3" , "pw :ss;" ), "user3" );
9496 }
9597
9698 @ Test
0 commit comments