aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar David G. Quintas <dgq@google.com>2015-09-08 15:06:02 -0700
committerGravatar David G. Quintas <dgq@google.com>2015-09-08 15:06:02 -0700
commit8df85003f8a6d202c0b0f4506ced9e4f4204f30d (patch)
treefd04eb8181e692f46a49f71ddd80881cd1f9e97a /test
parent391a6c77867e7c918124ad023a83d15c2ab18353 (diff)
parent8e1e22784dd15e70cbe95825765423afb264fab3 (diff)
Merge pull request #3218 from yang-g/interop
Interop test update
Diffstat (limited to 'test')
-rw-r--r--test/cpp/interop/client.cc10
-rw-r--r--test/cpp/interop/interop_client.cc21
-rw-r--r--test/cpp/interop/interop_client.h5
3 files changed, 16 insertions, 20 deletions
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 20fe1c515f..ba44a918db 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -120,11 +120,10 @@ int main(int argc, char** argv) {
grpc::string json_key = GetServiceAccountJsonKey();
client.DoJwtTokenCreds(json_key);
} else if (FLAGS_test_case == "oauth2_auth_token") {
- grpc::string json_key = GetServiceAccountJsonKey();
- client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope);
+ client.DoOauth2AuthToken(FLAGS_default_service_account, FLAGS_oauth_scope);
} else if (FLAGS_test_case == "per_rpc_creds") {
grpc::string json_key = GetServiceAccountJsonKey();
- client.DoPerRpcCreds(json_key, FLAGS_oauth_scope);
+ client.DoPerRpcCreds(json_key);
} else if (FLAGS_test_case == "status_code_and_message") {
client.DoStatusWithMessage();
} else if (FLAGS_test_case == "all") {
@@ -143,8 +142,9 @@ int main(int argc, char** argv) {
if (FLAGS_enable_ssl) {
grpc::string json_key = GetServiceAccountJsonKey();
client.DoJwtTokenCreds(json_key);
- client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope);
- client.DoPerRpcCreds(json_key, FLAGS_oauth_scope);
+ client.DoOauth2AuthToken(
+ FLAGS_default_service_account, FLAGS_oauth_scope);
+ client.DoPerRpcCreds(json_key);
}
// compute_engine_creds only runs in GCE.
} else {
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 48ccf06da9..8124cae67a 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -196,36 +196,33 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username,
AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(!response.username().empty());
GPR_ASSERT(!response.oauth_scope().empty());
- GPR_ASSERT(username.find(response.username()) != grpc::string::npos);
+ GPR_ASSERT(username == response.username());
const char* oauth_scope_str = response.oauth_scope().c_str();
GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos);
gpr_log(GPR_INFO, "Unary with oauth2 access token credentials done.");
}
-void InteropClient::DoPerRpcCreds(const grpc::string& username,
- const grpc::string& oauth_scope) {
+void InteropClient::DoPerRpcCreds(const grpc::string& json_key) {
gpr_log(GPR_INFO,
- "Sending a unary rpc with per-rpc raw oauth2 access token ...");
+ "Sending a unary rpc with per-rpc JWT access token ...");
SimpleRequest request;
SimpleResponse response;
request.set_fill_username(true);
- request.set_fill_oauth_scope(true);
std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_));
ClientContext context;
- grpc::string access_token = GetOauth2AccessToken();
- std::shared_ptr<Credentials> creds = AccessTokenCredentials(access_token);
+ std::chrono::seconds token_lifetime = std::chrono::hours(1);
+ std::shared_ptr<Credentials> creds =
+ ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count());
+
context.set_credentials(creds);
Status s = stub->UnaryCall(&context, request, &response);
AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(!response.username().empty());
- GPR_ASSERT(!response.oauth_scope().empty());
- GPR_ASSERT(username.find(response.username()) != grpc::string::npos);
- const char* oauth_scope_str = response.oauth_scope().c_str();
- GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos);
- gpr_log(GPR_INFO, "Unary with per-rpc oauth2 access token done.");
+ GPR_ASSERT(json_key.find(response.username()) != grpc::string::npos);
+ gpr_log(GPR_INFO, "Unary with per-rpc JWT access token done.");
}
void InteropClient::DoJwtTokenCreds(const grpc::string& username) {
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h
index 5a085c4c02..7bcb58571e 100644
--- a/test/cpp/interop/interop_client.h
+++ b/test/cpp/interop/interop_client.h
@@ -68,12 +68,11 @@ class InteropClient {
void DoJwtTokenCreds(const grpc::string& username);
void DoComputeEngineCreds(const grpc::string& default_service_account,
const grpc::string& oauth_scope);
- // username is a string containing the user email
+ // username the GCE default service account email
void DoOauth2AuthToken(const grpc::string& username,
const grpc::string& oauth_scope);
// username is a string containing the user email
- void DoPerRpcCreds(const grpc::string& username,
- const grpc::string& oauth_scope);
+ void DoPerRpcCreds(const grpc::string& json_key);
private:
void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response);