Skip to content

Commit ff1fb0f

Browse files
authored
Merge branch 'main' into feat/deleteSourceObjects-compose-10602500430278326901
2 parents 0776e8a + 0bca75c commit ff1fb0f

77 files changed

Lines changed: 2353 additions & 564 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/generated_files_sync.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ jobs:
175175
|grep --invert-match samples \
176176
|grep --invert-match benchmark \
177177
|grep --invert-match grafeas \
178+
|grep --invert-match '/tools/' \
178179
|grep --invert-match 'cloud-build.*v2' \
179180
|grep --invert-match 'google/monitoring/v3/DroppedLabelsOuterClass.java' \
180181
|grep --invert-match 'google/cloud/policytroubleshooter/v1/Explanations.java')

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ nosetests.xml
5858
.settings
5959
.DS_Store
6060
.classpath
61+
.vscode
6162

6263
# API key file containing value of GOOGLE_API_KEY for integration tests
6364
api_key
@@ -79,4 +80,4 @@ monorepo
7980
*.tfstate.*.backup
8081
*.tfstate.lock.info
8182

82-
.jqwik-database
83+
.jqwik-database
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.61.0" # {x-version-update:google-cloud-shared-dependencies:current}
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "graalvm-single"
12+
}
13+
14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "gcloud-devel"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "gcloud-devel"
23+
}
24+
25+
env_vars: {
26+
key: "GOOGLE_APPLICATION_CREDENTIALS"
27+
value: "secret_manager/java-it-service-account"
28+
}
29+
30+
env_vars: {
31+
key: "SECRET_MANAGER_KEYS"
32+
value: "java-it-service-account"
33+
}
34+
35+
env_vars: {
36+
key: "IT_SERVICE_ACCOUNT_EMAIL"
37+
value: "it-service-account@gcloud-devel.iam.gserviceaccount.com"
38+
}
39+
env_vars: {
40+
key: "BUILD_SUBDIR"
41+
value: "java-pubsub"
42+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "integration-single"
12+
}
13+
14+
# TODO: remove this after we've migrated all tests and scripts
15+
env_vars: {
16+
key: "GCLOUD_PROJECT"
17+
value: "gcloud-devel"
18+
}
19+
20+
env_vars: {
21+
key: "GOOGLE_CLOUD_PROJECT"
22+
value: "gcloud-devel"
23+
}
24+
25+
env_vars: {
26+
key: "GOOGLE_APPLICATION_CREDENTIALS"
27+
value: "secret_manager/java-it-service-account"
28+
}
29+
30+
env_vars: {
31+
key: "SECRET_MANAGER_KEYS"
32+
value: "java-it-service-account"
33+
}
34+
35+
36+
env_vars: {
37+
key: "BUILD_SUBDIR"
38+
value: "java-pubsub"
39+
}

google-cloud-pom-parent/pom.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,6 @@
108108
<goals>
109109
<goal>enforce</goal>
110110
</goals>
111-
<configuration>
112-
<rules>
113-
<requireUpperBoundDeps>
114-
<excludes>
115-
<exclude>io.opentelemetry:opentelemetry-api</exclude>
116-
<exclude>io.opentelemetry:opentelemetry-sdk-metrics</exclude>
117-
<exclude>io.opentelemetry:opentelemetry-sdk-logs</exclude>
118-
<exclude>io.opentelemetry:opentelemetry-context</exclude>
119-
<exclude>io.opentelemetry:opentelemetry-sdk-trace</exclude>
120-
<exclude>io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi</exclude>
121-
<exclude>io.opentelemetry:opentelemetry-sdk-common</exclude>
122-
<exclude>io.opentelemetry:opentelemetry-sdk</exclude>
123-
</excludes>
124-
</requireUpperBoundDeps>
125-
</rules>
126-
</configuration>
127111
</execution>
128112
</executions>
129113
</plugin>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
drivers/**
22
target-it/**
33
*logs*/**
4-
**/ITBigQueryJDBCLocalTest.java
4+
**/ITBigQueryJDBCLocalTest.java
5+
6+
tools/**/*.class
7+
tools/**/*.jfr

java-bigquery/google-cloud-bigquery-jdbc/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@
307307
<artifactId>mockito-core</artifactId>
308308
<scope>test</scope>
309309
</dependency>
310+
<dependency>
311+
<groupId>org.mockito</groupId>
312+
<artifactId>mockito-inline</artifactId>
313+
<scope>test</scope>
314+
</dependency>
310315
<dependency>
311316
<groupId>org.mockito</groupId>
312317
<artifactId>mockito-junit-jupiter</artifactId>

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
143143
String partnerToken;
144144
DatabaseMetaData databaseMetaData;
145145
Boolean reqGoogleDriveScope;
146+
private boolean isReadOnlyTokenUsed = false;
146147

147148
BigQueryConnection(String url) throws IOException {
148149
this(url, DataSource.fromUrl(url));
@@ -172,6 +173,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
172173
this.jobTimeoutInSeconds = ds.getJobTimeout();
173174
this.authProperties =
174175
BigQueryJdbcOAuthUtility.parseOAuthProperties(ds, this.connectionClassName);
176+
this.isReadOnlyTokenUsed = checkIsReadOnlyTokenUsed(this.authProperties);
175177
this.catalog = ds.getProjectId();
176178
this.universeDomain = ds.getUniverseDomain();
177179

@@ -1193,4 +1195,18 @@ public CallableStatement prepareCall(
11931195
}
11941196
return prepareCall(sql);
11951197
}
1198+
1199+
public boolean isReadOnlyTokenUsed() {
1200+
return this.isReadOnlyTokenUsed;
1201+
}
1202+
1203+
private boolean checkIsReadOnlyTokenUsed(Map<String, String> authProps) {
1204+
String readonlyValue =
1205+
authProps.get(BigQueryJdbcUrlUtility.OAUTH_ACCESS_TOKEN_READONLY_PROPERTY_NAME);
1206+
if (readonlyValue != null) {
1207+
return BigQueryJdbcUrlUtility.convertIntToBoolean(
1208+
readonlyValue, BigQueryJdbcUrlUtility.OAUTH_ACCESS_TOKEN_READONLY_PROPERTY_NAME);
1209+
}
1210+
return false;
1211+
}
11961212
}

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ static Map<String, String> parseOAuthProperties(DataSource ds, String callerClas
170170
}
171171
oauthProperties.put(
172172
BigQueryJdbcUrlUtility.OAUTH_ACCESS_TOKEN_PROPERTY_NAME, ds.getOAuthAccessToken());
173+
oauthProperties.put(
174+
BigQueryJdbcUrlUtility.OAUTH_ACCESS_TOKEN_READONLY_PROPERTY_NAME,
175+
String.valueOf(ds.getOAuthAccessTokenReadonly()));
173176
LOG.fine("OAuthAccessToken provided.");
174177
break;
175178
case APPLICATION_DEFAULT_CREDENTIALS:
@@ -230,26 +233,22 @@ static Map<String, String> parseOAuthProperties(DataSource ds, String callerClas
230233
break;
231234
}
232235

233-
if (authType == AuthType.GOOGLE_SERVICE_ACCOUNT
234-
|| authType == AuthType.GOOGLE_USER_ACCOUNT
235-
|| authType == AuthType.PRE_GENERATED_TOKEN) {
236-
oauthProperties.put(
237-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_EMAIL_PROPERTY_NAME,
238-
ds.getOAuthSAImpersonationEmail());
239-
oauthProperties.put(
240-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_CHAIN_PROPERTY_NAME,
241-
ds.getOAuthSAImpersonationChain());
242-
oauthProperties.put(
243-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_SCOPES_PROPERTY_NAME,
244-
ds.getOAuthSAImpersonationScopes() != null
245-
? ds.getOAuthSAImpersonationScopes()
246-
: BIGQUERY_SCOPE);
247-
oauthProperties.put(
248-
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_PROPERTY_NAME,
249-
ds.getOAuthSAImpersonationTokenLifetime() != null
250-
? ds.getOAuthSAImpersonationTokenLifetime()
251-
: BigQueryJdbcUrlUtility.DEFAULT_OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_VALUE);
252-
}
236+
oauthProperties.put(
237+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_EMAIL_PROPERTY_NAME,
238+
ds.getOAuthSAImpersonationEmail());
239+
oauthProperties.put(
240+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_CHAIN_PROPERTY_NAME,
241+
ds.getOAuthSAImpersonationChain());
242+
oauthProperties.put(
243+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_SCOPES_PROPERTY_NAME,
244+
ds.getOAuthSAImpersonationScopes() != null
245+
? ds.getOAuthSAImpersonationScopes()
246+
: BIGQUERY_SCOPE);
247+
oauthProperties.put(
248+
BigQueryJdbcUrlUtility.OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_PROPERTY_NAME,
249+
ds.getOAuthSAImpersonationTokenLifetime() != null
250+
? ds.getOAuthSAImpersonationTokenLifetime()
251+
: BigQueryJdbcUrlUtility.DEFAULT_OAUTH_SA_IMPERSONATION_TOKEN_LIFETIME_VALUE);
253252
return oauthProperties;
254253
}
255254

@@ -284,12 +283,9 @@ static GoogleCredentials getCredentials(
284283
getPreGeneratedTokensCredentials(authProperties, overrideProperties, callerClassName);
285284
break;
286285
case APPLICATION_DEFAULT_CREDENTIALS:
287-
// This auth method doesn't support service account impersonation
288-
289286
credentials = getApplicationDefaultCredentials(callerClassName);
290287
break;
291288
case EXTERNAL_ACCOUNT_AUTH:
292-
// This auth method doesn't support service account impersonation
293289
credentials = getExternalAccountAuthCredentials(authProperties, callerClassName);
294290
break;
295291
default:

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ protected boolean removeEldestEntry(Map.Entry<String, Map<String, String>> eldes
9898
static final String BIGQUERY_ENDPOINT_OVERRIDE_PROPERTY_NAME = "BIGQUERY";
9999
static final String STS_ENDPOINT_OVERRIDE_PROPERTY_NAME = "STS";
100100
static final String OAUTH_ACCESS_TOKEN_PROPERTY_NAME = "OAuthAccessToken";
101+
static final String OAUTH_ACCESS_TOKEN_READONLY_PROPERTY_NAME = "OAuthAccessTokenReadonly";
101102
static final String OAUTH_REFRESH_TOKEN_PROPERTY_NAME = "OAuthRefreshToken";
102103
static final String OAUTH_CLIENT_ID_PROPERTY_NAME = "OAuthClientId";
103104
static final String OAUTH_CLIENT_SECRET_PROPERTY_NAME = "OAuthClientSecret";
@@ -248,6 +249,11 @@ protected boolean removeEldestEntry(Map.Entry<String, Map<String, String>> eldes
248249
"The pre-generated access token to be used with BigQuery for"
249250
+ " authentication.")
250251
.build(),
252+
BigQueryConnectionProperty.newBuilder()
253+
.setName(OAUTH_ACCESS_TOKEN_READONLY_PROPERTY_NAME)
254+
.setDescription(
255+
"Set to true if the pre-generated access token has a read-only scope.")
256+
.build(),
251257
BigQueryConnectionProperty.newBuilder()
252258
.setName(OAUTH_CLIENT_ID_PROPERTY_NAME)
253259
.setDescription(

0 commit comments

Comments
 (0)