@@ -90,7 +90,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep
9090 Files .write (tempFile .toPath (), authJson .toString ().getBytes ());
9191
9292 String connection_uri =
93- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
93+ getBaseConnectionUrl ()
9494 + "ProjectId="
9595 + authJson .get ("project_id" ).getAsString ()
9696 + ";OAuthType=0;"
@@ -104,11 +104,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep
104104
105105 @ Test
106106 public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath () throws SQLException {
107- String connection_uri =
108- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
109- + "ProjectId="
110- + PROJECT_ID
111- + ";OAuthType=0;" ;
107+ String connection_uri = getBaseConnectionUrl () + "ProjectId=" + PROJECT_ID + ";OAuthType=0;" ;
112108
113109 try {
114110 DriverManager .getConnection (connection_uri );
@@ -127,7 +123,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsPath()
127123 Files .write (tempFile .toPath (), authJson .toString ().getBytes ());
128124
129125 String connection_uri =
130- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
126+ getBaseConnectionUrl ()
131127 + "ProjectId="
132128 + authJson .get ("project_id" ).getAsString ()
133129 + ";OAuthType=0;"
@@ -144,7 +140,7 @@ public void testValidServiceAccountAuthenticationViaEmailAndPkcs8Key()
144140 final JsonObject authJson = getAuthJson ();
145141
146142 String connection_uri =
147- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
143+ getBaseConnectionUrl ()
148144 + "ProjectId="
149145 + authJson .get ("project_id" ).getAsString ()
150146 + ";OAuthType=0;"
@@ -162,7 +158,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsJson()
162158 final JsonObject authJson = getAuthJson ();
163159
164160 String connection_uri =
165- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
161+ getBaseConnectionUrl ()
166162 + "ProjectId="
167163 + authJson .get ("project_id" ).getAsString ()
168164 + ";OAuthType=0;"
@@ -192,9 +188,12 @@ public void testValidServiceAccountAuthenticationP12() throws SQLException, IOEx
192188 @ Disabled
193189 public void testValidGoogleUserAccountAuthentication () throws SQLException {
194190 String connection_uri =
195- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
191+ getBaseConnectionUrl ()
192+ + "PROJECTID="
196193 + PROJECT_ID
197- + ";OAuthType=1;OAuthClientId=client_id;OAuthClientSecret=client_secret;" ;
194+ + ";OAuthType=1;"
195+ + "OAuthClientId=client_id;"
196+ + "OAuthClientSecret=client_secret;" ;
198197
199198 Connection connection = DriverManager .getConnection (connection_uri );
200199 assertNotNull (connection );
@@ -213,12 +212,15 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException {
213212 @ Disabled
214213 public void testValidExternalAccountAuthentication () throws SQLException {
215214 String connection_uri =
216- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
215+ getBaseConnectionUrl ()
216+ + "PROJECTID="
217217 + PROJECT_ID
218218 + ";OAUTHTYPE=4;"
219219 + "BYOID_AudienceUri=//iam.googleapis.com/projects/<project>/locations/<location>/workloadIdentityPools/<pool>/providers/<provider>;"
220- + "BYOID_SubjectTokenType=<type>;BYOID_CredentialSource={\" file\" :\" /path/to/file\" };"
221- + "BYOID_SA_Impersonation_Uri=<sa>;BYOID_TokenUri=<uri>;" ;
220+ + "BYOID_SubjectTokenType=<type>;"
221+ + "BYOID_CredentialSource={\" file\" :\" /path/to/file\" };"
222+ + "BYOID_SA_Impersonation_Uri=<sa>;"
223+ + "BYOID_TokenUri=<uri>;" ;
222224
223225 Connection connection = DriverManager .getConnection (connection_uri );
224226 assertNotNull (connection );
@@ -237,7 +239,8 @@ public void testValidExternalAccountAuthentication() throws SQLException {
237239 @ Disabled
238240 public void testValidExternalAccountAuthenticationFromFile () throws SQLException {
239241 String connection_uri =
240- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
242+ getBaseConnectionUrl ()
243+ + "PROJECTID="
241244 + PROJECT_ID
242245 + ";OAUTHTYPE=4;"
243246 + "OAuthPvtKeyPath=/path/to/file;" ;
@@ -259,9 +262,11 @@ public void testValidExternalAccountAuthenticationFromFile() throws SQLException
259262 @ Disabled
260263 public void testValidExternalAccountAuthenticationRawJson () throws SQLException {
261264 String connection_uri =
262- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
265+ getBaseConnectionUrl ()
266+ + "PROJECTID="
263267 + PROJECT_ID
264- + ";OAUTHTYPE=4;OAuthPvtKey={\n "
268+ + ";OAUTHTYPE=4;"
269+ + "OAuthPvtKey={\n "
265270 + " \" universe_domain\" : \" googleapis.com\" ,\n "
266271 + " \" type\" : \" external_account\" ,\n "
267272 + " \" audience\" :"
@@ -303,7 +308,8 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean
303308 String accessToken = credentials .getAccessToken ().getTokenValue ();
304309
305310 String connectionUri =
306- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId="
311+ getBaseConnectionUrl ()
312+ + "ProjectId="
307313 + authJson .get ("project_id" ).getAsString ()
308314 + ";OAuthType=2"
309315 + ";OAuthAccessToken="
@@ -319,10 +325,13 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean
319325 @ Disabled
320326 public void testValidRefreshTokenAuthentication () throws SQLException {
321327 String connection_uri =
322- "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
328+ getBaseConnectionUrl ()
329+ + "PROJECTID="
323330 + PROJECT_ID
324- + ";OAUTHTYPE=2;OAuthRefreshToken=refresh_token;"
325- + ";OAuthClientId=client;OAuthClientSecret=secret;" ;
331+ + ";OAUTHTYPE=2;"
332+ + "OAuthRefreshToken=refresh_token;"
333+ + ";OAuthClientId=client;"
334+ + "OAuthClientSecret=secret;" ;
326335
327336 Connection connection = DriverManager .getConnection (connection_uri );
328337 assertNotNull (connection );
0 commit comments