mirror of https://github.com/grpc/grpc-java.git
interop-testing: Add GoogleDefaultCreds test case for java
This commit is contained in:
parent
ef6b6169f8
commit
574c053ebb
|
|
@ -1712,6 +1712,27 @@ public abstract class AbstractInteropTest {
|
|||
oauth2AuthToken(jsonKey, credentialsStream, oauthScope);
|
||||
}
|
||||
|
||||
/** Sends an unary rpc with "google default credentials". */
|
||||
public void googleDefaultCredentials(
|
||||
String defaultServiceAccount,
|
||||
TestServiceGrpc.TestServiceBlockingStub googleDefaultStub) throws Exception {
|
||||
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||
.setFillUsername(true)
|
||||
.setResponseSize(314159)
|
||||
.setPayload(Payload.newBuilder()
|
||||
.setBody(ByteString.copyFrom(new byte[271828])))
|
||||
.build();
|
||||
final SimpleResponse response = googleDefaultStub.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);
|
||||
}
|
||||
|
||||
protected static void assertSuccess(StreamRecorder<?> recorder) {
|
||||
if (recorder.getError() != null) {
|
||||
throw new AssertionError(recorder.getError());
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ public enum TestCases {
|
|||
JWT_TOKEN_CREDS("JWT-based auth"),
|
||||
OAUTH2_AUTH_TOKEN("raw oauth2 access token auth"),
|
||||
PER_RPC_CREDS("per rpc raw oauth2 access token auth"),
|
||||
GOOGLE_DEFAULT_CREDENTIALS(
|
||||
"google default credentials, i.e. GoogleManagedChannel based auth"),
|
||||
CUSTOM_METADATA("unary and full duplex calls with metadata"),
|
||||
STATUS_CODE_AND_MESSAGE("request error code and message"),
|
||||
SPECIAL_STATUS_MESSAGE("special characters in status message"),
|
||||
|
|
|
|||
|
|
@ -304,6 +304,19 @@ public class TestServiceClient {
|
|||
break;
|
||||
}
|
||||
|
||||
case GOOGLE_DEFAULT_CREDENTIALS: {
|
||||
ManagedChannel channel = GoogleDefaultChannelBuilder.forAddress(
|
||||
serverHost, serverPort).build();
|
||||
try {
|
||||
TestServiceGrpc.TestServiceBlockingStub googleDefaultStub =
|
||||
TestServiceGrpc.newBlockingStub(channel);
|
||||
tester.googleDefaultCredentials(defaultServiceAccount, googleDefaultStub);
|
||||
} finally {
|
||||
channel.shutdownNow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CUSTOM_METADATA: {
|
||||
tester.customMetadata();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class TestCasesTest {
|
|||
"jwt_token_creds",
|
||||
"oauth2_auth_token",
|
||||
"per_rpc_creds",
|
||||
"google_default_credentials",
|
||||
"custom_metadata",
|
||||
"status_code_and_message",
|
||||
"special_status_message",
|
||||
|
|
|
|||
Loading…
Reference in New Issue