Skip to content

support altsCallCredentials in GoogleDefaultChannelCredentials #11634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 24, 2024
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
Prev Previous commit
Next Next commit
address comment
  • Loading branch information
rockspore committed Oct 24, 2024
commit f42aad379c1423be1e16492a1f54c061aec511a6
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,22 @@ public Builder altsCallCredentials(CallCredentials callCreds) {
public ChannelCredentials build() {
ChannelCredentials nettyCredentials =
InternalNettyChannelCredentials.create(createClientFactory());
if (callCredentials != null) {
if (altsCallCredentials != null) {
return CompositeChannelCredentials.create(
nettyCredentials, new DualCallCredentials(callCredentials, altsCallCredentials));
CallCredentials tlsCallCreds = callCredentials;
if (tlsCallCreds == null) {
try {
tlsCallCreds = MoreCallCredentials.from(GoogleCredentials.getApplicationDefault());
} catch (IOException e) {
tlsCallCreds =
new FailingCallCredentials(
Status.UNAUTHENTICATED
.withDescription("Failed to get Google default credentials")
.withCause(e));
}
return CompositeChannelCredentials.create(nettyCredentials, callCredentials);
}
CallCredentials callCreds;
try {
callCreds = MoreCallCredentials.from(GoogleCredentials.getApplicationDefault());
if (altsCallCredentials != null) {
callCreds = new DualCallCredentials(callCreds, altsCallCredentials);
}
} catch (IOException e) {
callCreds =
new FailingCallCredentials(
Status.UNAUTHENTICATED
.withDescription("Failed to get Google default credentials")
.withCause(e));
}
CallCredentials callCreds =
altsCallCredentials == null
? tlsCallCreds
: new DualCallCredentials(tlsCallCreds, altsCallCredentials);
return CompositeChannelCredentials.create(nettyCredentials, callCreds);
}

Expand Down
10 changes: 1 addition & 9 deletions alts/src/test/java/io/grpc/alts/DualCallCredentialsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ public class DualCallCredentialsTest {

@Mock CallCredentials altsCallCredentials;

private MethodDescriptor<Void, Void> method =
MethodDescriptor.<Void, Void>newBuilder()
.setType(MethodDescriptor.MethodType.UNKNOWN)
.setFullMethodName("a.service/method")
.setRequestMarshaller(TestMethodDescriptors.voidMarshaller())
.setResponseMarshaller(TestMethodDescriptors.voidMarshaller())
.build();

private static final String AUTHORITY = "testauthority";
private static final SecurityLevel SECURITY_LEVEL = SecurityLevel.PRIVACY_AND_INTEGRITY;

Expand Down Expand Up @@ -96,7 +88,7 @@ private final class RequestInfoImpl extends CallCredentials.RequestInfo {

@Override
public MethodDescriptor<?, ?> getMethodDescriptor() {
return method;
return TestMethodDescriptors.voidMethod();
}

@Override
Expand Down
Loading