diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java index 944bd9a627..d600eadf56 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java @@ -1660,6 +1660,26 @@ public abstract class AbstractInteropTest { assertResponse(goldenResponse, response); } + /** Sends an unary rpc with ComputeEngineChannelBuilder. */ + public void computeEngineChannelCredentials( + String defaultServiceAccount, + TestServiceGrpc.TestServiceBlockingStub computeEngineStub) throws Exception { + final SimpleRequest request = SimpleRequest.newBuilder() + .setFillUsername(true) + .setResponseSize(314159) + .setPayload(Payload.newBuilder() + .setBody(ByteString.copyFrom(new byte[271828]))) + .build(); + final SimpleResponse response = computeEngineStub.unaryCall(request); + assertEquals(defaultServiceAccount, response.getUsername()); + final SimpleResponse goldenResponse = SimpleResponse.newBuilder() + .setUsername(defaultServiceAccount) + .setPayload(Payload.newBuilder() + .setBody(ByteString.copyFrom(new byte[314159]))) + .build(); + assertResponse(goldenResponse, response); + } + /** Test JWT-based auth. */ public void jwtTokenCreds(InputStream serviceAccountJson) throws Exception { final SimpleRequest request = SimpleRequest.newBuilder() diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestCases.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestCases.java index c11580ca75..30a5fa4ba4 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestCases.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestCases.java @@ -38,6 +38,7 @@ public enum TestCases { PING_PONG("full-duplex ping-pong streaming"), EMPTY_STREAM("A stream that has zero-messages in both directions"), COMPUTE_ENGINE_CREDS("large_unary with service_account auth"), + COMPUTE_ENGINE_CHANNEL_CREDENTIALS("large unary with compute engine channel builder"), SERVICE_ACCOUNT_CREDS("large_unary with compute engine auth"), JWT_TOKEN_CREDS("JWT-based auth"), OAUTH2_AUTH_TOKEN("raw oauth2 access token auth"), diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java index 6280b4d25e..506e26ab33 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceClient.java @@ -34,6 +34,7 @@ import io.netty.handler.ssl.SslContext; import java.io.File; import java.io.FileInputStream; import java.nio.charset.Charset; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLSocketFactory; /** @@ -278,6 +279,20 @@ public class TestServiceClient { tester.computeEngineCreds(defaultServiceAccount, oauthScope); break; + case COMPUTE_ENGINE_CHANNEL_CREDENTIALS: { + ManagedChannel channel = ComputeEngineChannelBuilder + .forAddress(serverHost, serverPort).build(); + try { + TestServiceGrpc.TestServiceBlockingStub computeEngineStub = + TestServiceGrpc.newBlockingStub(channel); + tester.computeEngineChannelCredentials(defaultServiceAccount, computeEngineStub); + } finally { + channel.shutdownNow(); + channel.awaitTermination(5, TimeUnit.SECONDS); + } + break; + } + case SERVICE_ACCOUNT_CREDS: { String jsonKey = Files.asCharSource(new File(serviceAccountKeyFile), UTF_8).read(); FileInputStream credentialsStream = new FileInputStream(new File(serviceAccountKeyFile)); diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/TestCasesTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/TestCasesTest.java index 53faebb82b..539aca925d 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/TestCasesTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/TestCasesTest.java @@ -47,6 +47,7 @@ public class TestCasesTest { "server_compressed_unary", "client_streaming", "client_compressed_streaming", + "compute_engine_channel_credentials", "server_streaming", "server_compressed_streaming", "ping_pong",