Made ruby per-rpc creds interop use auth plugin API

pull/4625/head
murgatroid99 9 years ago
parent a4d3d2c76b
commit 00450af711
  1. 4
      src/ruby/lib/grpc.rb
  2. 12
      src/ruby/pb/test/client.rb

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ssl_roots_path = File.expand_path('../../../etc/roots.pem', __FILE__)
ssl_roots_path = File.expand_path('../../../../etc/roots.pem', __FILE__)
unless ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH']
ENV['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'] = ssl_roots_path
end

@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -266,16 +266,20 @@ class NamedTests
def per_rpc_creds
auth_creds = Google::Auth.get_application_default(@args.oauth_scope)
update_metadata = proc do |md|
kw = auth_creds.updater_proc.call({})
# TODO(jtattermusch): downcase the metadata keys here to make sure
# TODO(mlumish): downcase the metadata keys here to make sure
# they are not rejected by C core. This is a hotfix that should
# be addressed by introducing auto-downcasing logic.
kw = Hash[ kw.each_pair.map { |k, v| [k.downcase, v] }]
Hash[ kw.each_pair.map { |k, v| [k.downcase, v] }]
end
call_creds = GRPC::Core::CallCredentials.new(update_metadata)
resp = perform_large_unary(fill_username: true,
fill_oauth_scope: true,
**kw)
credentials: call_creds)
json_key = File.read(ENV[AUTH_ENV])
wanted_email = MultiJson.load(json_key)['client_email']
assert("#{__callee__}: bad username") { wanted_email == resp.username }

Loading…
Cancel
Save