@@ -77,4 +77,81 @@ public void testHiveConnectionParameters() throws SQLException, ZooKeeperHiveCli
77
77
JdbcConnectionParams nonPortParams = Utils .parseURL ("jdbc:hive2://hello.host/default" );
78
78
Assert .assertEquals (Integer .parseInt (Utils .DEFAULT_PORT ), nonPortParams .getPort ());
79
79
}
80
+
81
+ @ Test
82
+ public void testPasswordExtractionFromUrl () throws SQLException , ZooKeeperHiveClientException {
83
+ // Test with password in the URL
84
+ JdbcConnectionParams params = Utils .parseURL (
85
+ "jdbc:hive2://hello.host:10002/default;password=mySecretPassword;transportMode=http" );
86
+
87
+ Assert .assertEquals ("mySecretPassword" ,
88
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
89
+
90
+ // Test with password in different case (uppercase)
91
+ params = Utils .parseURL (
92
+ "jdbc:hive2://hello.host:10002/default;PASSWORD=upperCasePassword;httpPath=cliservice" );
93
+
94
+ Assert .assertEquals ("upperCasePassword" ,
95
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
96
+
97
+ // Test with password at the beginning of parameters
98
+ params = Utils .parseURL (
99
+ "jdbc:hive2://hello.host:10002/default;password=firstParam;httpPath=cliservice" );
100
+
101
+ Assert .assertEquals ("firstParam" ,
102
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
103
+
104
+ // Test with password at the end of parameters
105
+ params = Utils .parseURL (
106
+ "jdbc:hive2://hello.host:10002/default;transportMode=http;password=lastParam" );
107
+
108
+ Assert .assertEquals ("lastParam" ,
109
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
110
+ }
111
+
112
+ @ Test
113
+ public void testPasswordWithSpecialCharacters () throws SQLException , ZooKeeperHiveClientException {
114
+ // Test with password containing special characters
115
+ JdbcConnectionParams params = Utils .parseURL (
116
+ "jdbc:hive2://hello.host:10002/default;password=Pass@123!#$;httpPath=cliservice" );
117
+
118
+ Assert .assertEquals ("Pass@123!#$" ,
119
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
120
+
121
+ // Test with password containing equals sign
122
+ params = Utils .parseURL (
123
+ "jdbc:hive2://hello.host:10002/default;password=user=admin123;transportMode=http" );
124
+
125
+ Assert .assertEquals ("user=admin123" ,
126
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
127
+ }
128
+
129
+ @ Test
130
+ public void testNoPasswordInUrl () throws SQLException , ZooKeeperHiveClientException {
131
+ // Test URL without password parameter
132
+ JdbcConnectionParams params = Utils .parseURL (
133
+ "jdbc:hive2://hello.host:10002/default;transportMode=http;httpPath=cliservice" );
134
+
135
+ Assert .assertNull (params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
136
+ }
137
+
138
+ @ Test
139
+ public void testEmptyPassword () throws SQLException , ZooKeeperHiveClientException {
140
+ // Test with empty password
141
+ JdbcConnectionParams params = Utils .parseURL (
142
+ "jdbc:hive2://hello.host:10002/default;password=;transportMode=http" );
143
+
144
+ Assert .assertEquals ("" ,
145
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
146
+ }
147
+
148
+ @ Test
149
+ public void testPasswordWithSemicolon () throws SQLException , ZooKeeperHiveClientException {
150
+ // Test URL with semicolon in password (this should extract up to the semicolon)
151
+ JdbcConnectionParams params = Utils .parseURL (
152
+ "jdbc:hive2://hello.host:10002/default;password=part1;part2;transportMode=http" );
153
+
154
+ Assert .assertEquals ("part1" ,
155
+ params .getSessionVars ().get (JdbcConnectionParams .AUTH_PASSWD ));
156
+ }
80
157
}
0 commit comments