Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 02a00ac

Browse files
chore: generate libraries at Mon Mar 2 15:00:10 UTC 2026
1 parent 3556d72 commit 02a00ac

3 files changed

Lines changed: 49 additions & 50 deletions

File tree

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/MutableCredentials.java

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.google.auth.Credentials;
1919
import com.google.auth.oauth2.ServiceAccountCredentials;
20-
2120
import java.io.IOException;
2221
import java.net.URI;
2322
import java.util.List;
@@ -31,56 +30,55 @@
3130
* underlying service account credentials for a running Spanner Client.
3231
*
3332
* <p>All operations inherited from {@link Credentials} are forwarded to the current delegate,
34-
* including request metadata retrieval and token refresh. Calling
35-
* {@link #updateCredentials(ServiceAccountCredentials)} replaces the delegate with a newly scoped
33+
* including request metadata retrieval and token refresh. Calling {@link
34+
* #updateCredentials(ServiceAccountCredentials)} replaces the delegate with a newly scoped
3635
* credentials instance created from the same scopes that were provided when this object was
3736
* constructed.
3837
*/
3938
public class MutableCredentials extends Credentials {
40-
ServiceAccountCredentials delegate;
41-
List<String> scopes;
39+
ServiceAccountCredentials delegate;
40+
List<String> scopes;
4241

43-
public MutableCredentials(ServiceAccountCredentials credentials, List<String> scopes) {
44-
this. scopes = scopes;
45-
delegate = (ServiceAccountCredentials) credentials.createScoped(scopes);
46-
}
42+
public MutableCredentials(ServiceAccountCredentials credentials, List<String> scopes) {
43+
this.scopes = scopes;
44+
delegate = (ServiceAccountCredentials) credentials.createScoped(scopes);
45+
}
4746

48-
/**
49-
* Replaces the current delegate with a newly scoped credentials instance.
50-
*
51-
* <p>The provided {@link ServiceAccountCredentials} is scoped using the same scopes that were
52-
* supplied when this {@link MutableCredentials} instance was created.
53-
*
54-
* @param credentials the new base service account credentials to scope and use for client
55-
* authorization.
56-
*/
57-
public void updateCredentials(ServiceAccountCredentials credentials) {
58-
delegate =(ServiceAccountCredentials) credentials.createScoped(scopes);
59-
}
47+
/**
48+
* Replaces the current delegate with a newly scoped credentials instance.
49+
*
50+
* <p>The provided {@link ServiceAccountCredentials} is scoped using the same scopes that were
51+
* supplied when this {@link MutableCredentials} instance was created.
52+
*
53+
* @param credentials the new base service account credentials to scope and use for client
54+
* authorization.
55+
*/
56+
public void updateCredentials(ServiceAccountCredentials credentials) {
57+
delegate = (ServiceAccountCredentials) credentials.createScoped(scopes);
58+
}
6059

61-
@Override
62-
public String getAuthenticationType() {
63-
return delegate.getAuthenticationType();
64-
}
60+
@Override
61+
public String getAuthenticationType() {
62+
return delegate.getAuthenticationType();
63+
}
6564

66-
@Override
67-
public Map<String, List<String>> getRequestMetadata(URI uri) throws IOException {
68-
return delegate.getRequestMetadata(uri);
69-
}
65+
@Override
66+
public Map<String, List<String>> getRequestMetadata(URI uri) throws IOException {
67+
return delegate.getRequestMetadata(uri);
68+
}
7069

71-
@Override
72-
public boolean hasRequestMetadata() {
73-
return delegate.hasRequestMetadata();
74-
}
70+
@Override
71+
public boolean hasRequestMetadata() {
72+
return delegate.hasRequestMetadata();
73+
}
7574

76-
@Override
77-
public boolean hasRequestMetadataOnly() {
78-
return delegate.hasRequestMetadataOnly();
79-
}
75+
@Override
76+
public boolean hasRequestMetadataOnly() {
77+
return delegate.hasRequestMetadataOnly();
78+
}
8079

81-
@Override
82-
public void refresh() throws IOException {
83-
delegate.refresh();
84-
}
80+
@Override
81+
public void refresh() throws IOException {
82+
delegate.refresh();
83+
}
8584
}
86-

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ITMutableCredentialsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testMutableCredentialsUpdateAuthorizationForRunningClient() throws I
5454
credentialsFromFile = GoogleCredentials.fromStream(stream);
5555
}
5656
assumeTrue(
57-
"This test requires service account credentials",
57+
"This test requires service account credentials",
5858
credentialsFromFile instanceof ServiceAccountCredentials);
5959

6060
ServiceAccountCredentials validCredentials = (ServiceAccountCredentials) credentialsFromFile;
@@ -91,4 +91,4 @@ public void testMutableCredentialsUpdateAuthorizationForRunningClient() throws I
9191
closeSpanner();
9292
}
9393
}
94-
}
94+
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/MutableCredentialsTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public class MutableCredentialsTest {
4545
ServiceAccountCredentials updatedScopedCredentials = mock(ServiceAccountCredentials.class);
4646
List<String> scopes = Arrays.asList("scope-a", "scope-b");
4747
Map<String, List<String>> initialMetadata =
48-
Collections.singletonMap("Authorization", Collections.singletonList("v1"));
48+
Collections.singletonMap("Authorization", Collections.singletonList("v1"));
4949
Map<String, List<String>> updatedMetadata =
50-
Collections.singletonMap("Authorization", Collections.singletonList("v2"));
50+
Collections.singletonMap("Authorization", Collections.singletonList("v2"));
5151
String initialAuthType = "auth-1";
5252
String updatedAuthType = "auth-2";
5353

@@ -61,7 +61,9 @@ public void testCreateMutableCredentialsAndUpdate() throws IOException {
6161
assertEquals(initialAuthType, credentials.getAuthenticationType());
6262
assertTrue(credentials.hasRequestMetadata());
6363
assertTrue(credentials.hasRequestMetadataOnly());
64-
assertEquals(initialMetadata, credentials.getRequestMetadata(URI.create("https://spanner.googleapis.com")));
64+
assertEquals(
65+
initialMetadata,
66+
credentials.getRequestMetadata(URI.create("https://spanner.googleapis.com")));
6567

6668
credentials.refresh();
6769

@@ -82,8 +84,7 @@ public void testCreateMutableCredentialsAndUpdate() throws IOException {
8284
private void setupInitialCredentials() throws IOException {
8385
when(initialCredentials.createScoped(scopes)).thenReturn(initialScopedCredentials);
8486
when(initialScopedCredentials.getAuthenticationType()).thenReturn(initialAuthType);
85-
when(initialScopedCredentials.getRequestMetadata(any(URI.class)))
86-
.thenReturn(initialMetadata);
87+
when(initialScopedCredentials.getRequestMetadata(any(URI.class))).thenReturn(initialMetadata);
8788
when(initialScopedCredentials.hasRequestMetadata()).thenReturn(true);
8889
when(initialScopedCredentials.hasRequestMetadataOnly()).thenReturn(true);
8990
}
@@ -95,4 +96,4 @@ private void setupUpdatedCredentials() throws IOException {
9596
when(updatedScopedCredentials.hasRequestMetadata()).thenReturn(false);
9697
when(updatedScopedCredentials.hasRequestMetadataOnly()).thenReturn(false);
9798
}
98-
}
99+
}

0 commit comments

Comments
 (0)