mirror of https://github.com/grpc/grpc-java.git
Implement per_rpc_creds test
This commit is contained in:
parent
3c79c52427
commit
1f0cad21e5
|
|
@ -593,9 +593,9 @@ public abstract class AbstractTransportTest {
|
|||
requestHeadersCapture.get().get(GrpcUtil.TIMEOUT_KEY));
|
||||
Assert.assertTrue(
|
||||
"configuredTimeoutMinutes=" + configuredTimeoutMinutes
|
||||
+ ", transferredTimeoutMinutes=" + transferredTimeoutMinutes,
|
||||
+ ", transferredTimeoutMinutes=" + transferredTimeoutMinutes,
|
||||
configuredTimeoutMinutes - transferredTimeoutMinutes >= 0
|
||||
&& configuredTimeoutMinutes - transferredTimeoutMinutes <= 1);
|
||||
&& configuredTimeoutMinutes - transferredTimeoutMinutes <= 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -847,6 +847,15 @@ public abstract class AbstractTransportTest {
|
|||
authScope.contains(response.getOauthScope()));
|
||||
}
|
||||
|
||||
/** Sends a unary rpc with "per rpc" raw oauth2 access token credentials. */
|
||||
public void perRpcCreds(String jsonKey, InputStream credentialsStream, String oauthScope)
|
||||
throws Exception {
|
||||
// In gRpc Java, we don't have per Rpc credentials, user can use an intercepted stub only once
|
||||
// for that purpose.
|
||||
// So, this test is identical to oauth2_auth_token test.
|
||||
oauth2AuthToken(jsonKey, credentialsStream, oauthScope);
|
||||
}
|
||||
|
||||
protected static void assertSuccess(StreamRecorder<?> recorder) {
|
||||
if (recorder.getError() != null) {
|
||||
throw new AssertionError(recorder.getError());
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ public class TestServiceClient {
|
|||
+ "\n service_account_creds: large_unary with service_account auth"
|
||||
+ "\n compute_engine_creds: large_unary with compute engine auth"
|
||||
+ "\n oauth2_auth_token: raw oauth2 access token auth"
|
||||
+ "\n per_rpc_creds: per rpc raw oauth2 access token auth"
|
||||
+ "\n cancel_after_begin: cancel stream after starting it"
|
||||
+ "\n cancel_after_first_response: cancel on first response"
|
||||
+ "\n --use_tls=true|false Whether to use TLS. Default " + c.useTls
|
||||
|
|
@ -233,6 +234,10 @@ public class TestServiceClient {
|
|||
String jsonKey = Files.toString(new File(serviceAccountKeyFile), Charset.forName("UTF-8"));
|
||||
FileInputStream credentialsStream = new FileInputStream(new File(serviceAccountKeyFile));
|
||||
tester.oauth2AuthToken(jsonKey, credentialsStream, oauthScope);
|
||||
} else if ("per_rpc_creds".equals(testCase)) {
|
||||
String jsonKey = Files.toString(new File(serviceAccountKeyFile), Charset.forName("UTF-8"));
|
||||
FileInputStream credentialsStream = new FileInputStream(new File(serviceAccountKeyFile));
|
||||
tester.perRpcCreds(jsonKey, credentialsStream, oauthScope);
|
||||
} else if ("cancel_after_begin".equals(testCase)) {
|
||||
tester.cancelAfterBegin();
|
||||
} else if ("cancel_after_first_response".equals(testCase)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue