Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud.bigquery.jdbc.it;


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep
Files.write(tempFile.toPath(), authJson.toString().getBytes());

String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
getBaseConnectionUrl() + ""
Comment thread
logachev marked this conversation as resolved.
Outdated
+ "ProjectId="
+ authJson.get("project_id").getAsString()
+ ";OAuthType=0;"
Expand All @@ -105,7 +106,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep
@Test
public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
getBaseConnectionUrl() + ""
+ "ProjectId="
+ PROJECT_ID
+ ";OAuthType=0;";
Expand All @@ -127,7 +128,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsPath()
Files.write(tempFile.toPath(), authJson.toString().getBytes());

String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
getBaseConnectionUrl() + ""
+ "ProjectId="
+ authJson.get("project_id").getAsString()
+ ";OAuthType=0;"
Expand All @@ -144,7 +145,7 @@ public void testValidServiceAccountAuthenticationViaEmailAndPkcs8Key()
final JsonObject authJson = getAuthJson();

String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
getBaseConnectionUrl() + ""
+ "ProjectId="
+ authJson.get("project_id").getAsString()
+ ";OAuthType=0;"
Expand All @@ -162,7 +163,7 @@ public void testValidServiceAccountAuthenticationOAuthPvtKeyAsJson()
final JsonObject authJson = getAuthJson();

String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;"
getBaseConnectionUrl() + ""
+ "ProjectId="
+ authJson.get("project_id").getAsString()
+ ";OAuthType=0;"
Expand Down Expand Up @@ -192,7 +193,7 @@ public void testValidServiceAccountAuthenticationP12() throws SQLException, IOEx
@Disabled
public void testValidGoogleUserAccountAuthentication() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
getBaseConnectionUrl() + "PROJECTID="
+ PROJECT_ID
+ ";OAuthType=1;OAuthClientId=client_id;OAuthClientSecret=client_secret;";

Expand All @@ -213,7 +214,7 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException {
@Disabled
public void testValidExternalAccountAuthentication() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
getBaseConnectionUrl() + "PROJECTID="
+ PROJECT_ID
+ ";OAUTHTYPE=4;"
+ "BYOID_AudienceUri=//iam.googleapis.com/projects/<project>/locations/<location>/workloadIdentityPools/<pool>/providers/<provider>;"
Expand All @@ -237,7 +238,7 @@ public void testValidExternalAccountAuthentication() throws SQLException {
@Disabled
public void testValidExternalAccountAuthenticationFromFile() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
getBaseConnectionUrl() + "PROJECTID="
+ PROJECT_ID
+ ";OAUTHTYPE=4;"
+ "OAuthPvtKeyPath=/path/to/file;";
Expand All @@ -259,7 +260,7 @@ public void testValidExternalAccountAuthenticationFromFile() throws SQLException
@Disabled
public void testValidExternalAccountAuthenticationRawJson() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
getBaseConnectionUrl() + "PROJECTID="
+ PROJECT_ID
+ ";OAUTHTYPE=4;OAuthPvtKey={\n"
+ " \"universe_domain\": \"googleapis.com\",\n"
Expand Down Expand Up @@ -303,7 +304,7 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean
String accessToken = credentials.getAccessToken().getTokenValue();

String connectionUri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId="
getBaseConnectionUrl() + "ProjectId="
+ authJson.get("project_id").getAsString()
+ ";OAuthType=2"
+ ";OAuthAccessToken="
Expand All @@ -319,7 +320,7 @@ public void testValidPreGeneratedAccessTokenAuthentication(String scope, boolean
@Disabled
public void testValidRefreshTokenAuthentication() throws SQLException {
String connection_uri =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;PROJECTID="
getBaseConnectionUrl() + "PROJECTID="
+ PROJECT_ID
+ ";OAUTHTYPE=2;OAuthRefreshToken=refresh_token;"
+ ";OAuthClientId=client;OAuthClientSecret=secret;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.cloud.bigquery.jdbc.it;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.cloud.bigquery.jdbc.utils.TestUtilities;

import com.google.cloud.ServiceOptions;
import com.google.cloud.bigquery.BigQuery;
Expand Down Expand Up @@ -177,10 +178,15 @@ private static void registerShutdownHook(final String dataset) {
}

public static final String DEFAULT_CATALOG = ServiceOptions.getDefaultProjectId();
public static String connectionUrl =
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId="
+ DEFAULT_CATALOG
+ ";OAuthType=3;Timeout=3600;";

public static String getBaseConnectionUrl() {
return TestUtilities.getBaseConnectionUrl();
}

public static String connectionUrl = getBaseConnectionUrl()
+ "ProjectId="
+ DEFAULT_CATALOG
+ ";OAuthType=3;Timeout=3600;";

public static final String createDatasetQuery =
"CREATE SCHEMA IF NOT EXISTS `%s.%s` OPTIONS(default_table_expiration_days = 5)";
Expand Down
Loading
Loading