Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
b322d4a8
Commit
b322d4a8
authored
9 years ago
by
Abhishek Kumar
Browse files
Options
Downloads
Plain Diff
Merge pull request #2427 from yang-g/per_call_oauth_creds_impl
Per call oauth creds impl
parents
736689db
ba5f9808
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/cpp/interop/client.cc
+6
-1
6 additions, 1 deletion
test/cpp/interop/client.cc
test/cpp/interop/interop_client.cc
+28
-0
28 additions, 0 deletions
test/cpp/interop/interop_client.cc
test/cpp/interop/interop_client.h
+3
-0
3 additions, 0 deletions
test/cpp/interop/interop_client.h
with
37 additions
and
1 deletion
test/cpp/interop/client.cc
+
6
−
1
View file @
b322d4a8
...
@@ -69,6 +69,7 @@ DEFINE_string(test_case, "large_unary",
...
@@ -69,6 +69,7 @@ DEFINE_string(test_case, "large_unary",
"compute_engine_creds: large_unary with compute engine auth; "
"compute_engine_creds: large_unary with compute engine auth; "
"jwt_token_creds: large_unary with JWT token auth; "
"jwt_token_creds: large_unary with JWT token auth; "
"oauth2_auth_token: raw oauth2 access token auth; "
"oauth2_auth_token: raw oauth2 access token auth; "
"per_rpc_creds: raw oauth2 access token on a single rpc; "
"all : all of above."
);
"all : all of above."
);
DEFINE_string
(
default_service_account
,
""
,
DEFINE_string
(
default_service_account
,
""
,
"Email of GCE default service account"
);
"Email of GCE default service account"
);
...
@@ -117,6 +118,9 @@ int main(int argc, char** argv) {
...
@@ -117,6 +118,9 @@ int main(int argc, char** argv) {
}
else
if
(
FLAGS_test_case
==
"oauth2_auth_token"
)
{
}
else
if
(
FLAGS_test_case
==
"oauth2_auth_token"
)
{
grpc
::
string
json_key
=
GetServiceAccountJsonKey
();
grpc
::
string
json_key
=
GetServiceAccountJsonKey
();
client
.
DoOauth2AuthToken
(
json_key
,
FLAGS_oauth_scope
);
client
.
DoOauth2AuthToken
(
json_key
,
FLAGS_oauth_scope
);
}
else
if
(
FLAGS_test_case
==
"per_rpc_creds"
)
{
grpc
::
string
json_key
=
GetServiceAccountJsonKey
();
client
.
DoPerRpcCreds
(
json_key
,
FLAGS_oauth_scope
);
}
else
if
(
FLAGS_test_case
==
"all"
)
{
}
else
if
(
FLAGS_test_case
==
"all"
)
{
client
.
DoEmpty
();
client
.
DoEmpty
();
client
.
DoLargeUnary
();
client
.
DoLargeUnary
();
...
@@ -133,6 +137,7 @@ int main(int argc, char** argv) {
...
@@ -133,6 +137,7 @@ int main(int argc, char** argv) {
client
.
DoServiceAccountCreds
(
json_key
,
FLAGS_oauth_scope
);
client
.
DoServiceAccountCreds
(
json_key
,
FLAGS_oauth_scope
);
client
.
DoJwtTokenCreds
(
json_key
);
client
.
DoJwtTokenCreds
(
json_key
);
client
.
DoOauth2AuthToken
(
json_key
,
FLAGS_oauth_scope
);
client
.
DoOauth2AuthToken
(
json_key
,
FLAGS_oauth_scope
);
client
.
DoPerRpcCreds
(
json_key
,
FLAGS_oauth_scope
);
}
}
// compute_engine_creds only runs in GCE.
// compute_engine_creds only runs in GCE.
}
else
{
}
else
{
...
@@ -142,7 +147,7 @@ int main(int argc, char** argv) {
...
@@ -142,7 +147,7 @@ int main(int argc, char** argv) {
"large_unary|client_streaming|server_streaming|half_duplex|ping_pong|"
"large_unary|client_streaming|server_streaming|half_duplex|ping_pong|"
"cancel_after_begin|cancel_after_first_response|"
"cancel_after_begin|cancel_after_first_response|"
"timeout_on_sleeping_server|service_account_creds|compute_engine_creds|"
"timeout_on_sleeping_server|service_account_creds|compute_engine_creds|"
"jwt_token_creds|oauth2_auth_token"
,
"jwt_token_creds|oauth2_auth_token
|per_rpc_creds
"
,
FLAGS_test_case
.
c_str
());
FLAGS_test_case
.
c_str
());
ret
=
1
;
ret
=
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
test/cpp/interop/interop_client.cc
+
28
−
0
View file @
b322d4a8
...
@@ -41,8 +41,10 @@
...
@@ -41,8 +41,10 @@
#include
<grpc/support/log.h>
#include
<grpc/support/log.h>
#include
<grpc++/channel_interface.h>
#include
<grpc++/channel_interface.h>
#include
<grpc++/client_context.h>
#include
<grpc++/client_context.h>
#include
<grpc++/credentials.h>
#include
<grpc++/status.h>
#include
<grpc++/status.h>
#include
<grpc++/stream.h>
#include
<grpc++/stream.h>
#include
"test/cpp/interop/client_helper.h"
#include
"test/proto/test.grpc.pb.h"
#include
"test/proto/test.grpc.pb.h"
#include
"test/proto/empty.grpc.pb.h"
#include
"test/proto/empty.grpc.pb.h"
#include
"test/proto/messages.grpc.pb.h"
#include
"test/proto/messages.grpc.pb.h"
...
@@ -166,6 +168,32 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username,
...
@@ -166,6 +168,32 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username,
gpr_log
(
GPR_INFO
,
"Unary with oauth2 access token credentials done."
);
gpr_log
(
GPR_INFO
,
"Unary with oauth2 access token credentials done."
);
}
}
void
InteropClient
::
DoPerRpcCreds
(
const
grpc
::
string
&
username
,
const
grpc
::
string
&
oauth_scope
)
{
gpr_log
(
GPR_INFO
,
"Sending a unary rpc with per-rpc raw oauth2 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
);
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."
);
}
void
InteropClient
::
DoJwtTokenCreds
(
const
grpc
::
string
&
username
)
{
void
InteropClient
::
DoJwtTokenCreds
(
const
grpc
::
string
&
username
)
{
gpr_log
(
GPR_INFO
,
"Sending a large unary rpc with JWT token credentials ..."
);
gpr_log
(
GPR_INFO
,
"Sending a large unary rpc with JWT token credentials ..."
);
SimpleRequest
request
;
SimpleRequest
request
;
...
...
This diff is collapsed.
Click to expand it.
test/cpp/interop/interop_client.h
+
3
−
0
View file @
b322d4a8
...
@@ -71,6 +71,9 @@ class InteropClient {
...
@@ -71,6 +71,9 @@ class InteropClient {
// username is a string containing the user email
// username is a string containing the user email
void
DoOauth2AuthToken
(
const
grpc
::
string
&
username
,
void
DoOauth2AuthToken
(
const
grpc
::
string
&
username
,
const
grpc
::
string
&
oauth_scope
);
const
grpc
::
string
&
oauth_scope
);
// username is a string containing the user email
void
DoPerRpcCreds
(
const
grpc
::
string
&
username
,
const
grpc
::
string
&
oauth_scope
);
private
:
private
:
void
PerformLargeUnary
(
SimpleRequest
*
request
,
SimpleResponse
*
response
);
void
PerformLargeUnary
(
SimpleRequest
*
request
,
SimpleResponse
*
response
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment