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
b44da465
Commit
b44da465
authored
10 years ago
by
Tim Emiola
Browse files
Options
Downloads
Patches
Plain Diff
Updates the interop client to use the new auth library
parent
cc1150f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ruby/bin/interop/interop_client.rb
+8
-23
8 additions, 23 deletions
src/ruby/bin/interop/interop_client.rb
with
8 additions
and
23 deletions
src/ruby/bin/interop/interop_client.rb
+
8
−
23
View file @
b44da465
...
...
@@ -48,6 +48,7 @@ require 'minitest'
require
'minitest/assertions'
require
'grpc'
require
'googleauth'
require
'google/protobuf'
require
'test/cpp/interop/test_services'
...
...
@@ -56,7 +57,7 @@ require 'test/cpp/interop/empty'
require
'signet/ssl_config'
include
GRPC
::
Auth
AUTH_ENV
=
Google
::
Auth
::
ServiceAccountCredentials
::
ENV_VAR
# loads the certificates used to access the test server securely.
def
load_test_certs
...
...
@@ -101,22 +102,14 @@ def create_stub(opts)
}
# Add service account creds if specified
if
%w(all service_account_creds)
.
include?
(
opts
.
test_case
)
wants_creds
=
%w(all compute_engine_creds service_account_creds)
if
wants_creds
.
include?
(
opts
.
test_case
)
unless
opts
.
oauth_scope
.
nil?
fd
=
StringIO
.
new
(
File
.
read
(
opts
.
oauth_key_file
))
logger
.
info
(
"loading oauth certs from
#{
opts
.
oauth_key_file
}
"
)
auth_creds
=
ServiceAccountCredentials
.
new
(
opts
.
oauth_scope
,
fd
)
auth_creds
=
Google
::
Auth
.
get_application_default
(
opts
.
oauth_scope
)
stub_opts
[
:update_metadata
]
=
auth_creds
.
updater_proc
end
end
# Add compute engine creds if specified
if
%w(all compute_engine_creds)
.
include?
(
opts
.
test_case
)
unless
opts
.
oauth_scope
.
nil?
stub_opts
[
:update_metadata
]
=
GCECredentials
.
new
.
update_proc
end
end
logger
.
info
(
"... connecting securely to
#{
address
}
"
)
Grpc
::
Testing
::
TestService
::
Stub
.
new
(
address
,
**
stub_opts
)
else
...
...
@@ -193,11 +186,11 @@ class NamedTests
def
service_account_creds
# ignore this test if the oauth options are not set
if
@args
.
oauth_scope
.
nil?
||
@args
.
oauth_key_file
.
nil?
if
@args
.
oauth_scope
.
nil?
p
'NOT RUN: service_account_creds; no service_account settings'
return
end
json_key
=
File
.
read
(
@args
.
oauth_key_file
)
json_key
=
File
.
read
(
ENV
[
AUTH_ENV
]
)
wanted_email
=
MultiJson
.
load
(
json_key
)[
'client_email'
]
resp
=
perform_large_unary
(
fill_username:
true
,
fill_oauth_scope:
true
)
...
...
@@ -285,7 +278,7 @@ end
# Args is used to hold the command line info.
Args
=
Struct
.
new
(
:default_service_account
,
:host
,
:host_override
,
:oauth_scope
,
:oauth_key_file
,
:port
,
:secure
,
:test_case
,
:oauth_scope
,
:port
,
:secure
,
:test_case
,
:use_test_ca
)
# validates the the command line options, returning them as a Hash.
...
...
@@ -302,10 +295,6 @@ def parse_args
'email address of the default service account'
)
do
|
v
|
args
[
'default_service_account'
]
=
v
end
opts
.
on
(
'--service_account_key_file PATH'
,
'Path to the service account json key file'
)
do
|
v
|
args
[
'oauth_key_file'
]
=
v
end
opts
.
on
(
'--server_host_override HOST_OVERRIDE'
,
'override host via a HTTP header'
)
do
|
v
|
args
[
'host_override'
]
=
v
...
...
@@ -333,10 +322,6 @@ def _check_args(args)
fail
(
OptionParser
::
MissingArgument
,
"please specify --
#{
arg
}
"
)
end
end
if
args
[
'oauth_key_file'
].
nil?
^
args
[
'oauth_scope'
].
nil?
fail
(
OptionParser
::
MissingArgument
,
'please specify both of --service_account_key_file and --oauth_scope'
)
end
args
end
...
...
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