From a5d39f7e78bcbc77a294264115c5bf70e69ba598 Mon Sep 17 00:00:00 2001 From: Tim Emiola Date: Fri, 14 Aug 2015 12:22:51 -0700 Subject: Merges timeout interop test change --- src/ruby/bin/interop/interop_client.rb | 51 ++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'src/ruby/bin') diff --git a/src/ruby/bin/interop/interop_client.rb b/src/ruby/bin/interop/interop_client.rb index 9d753a85ab..78ae217fa5 100755 --- a/src/ruby/bin/interop/interop_client.rb +++ b/src/ruby/bin/interop/interop_client.rb @@ -110,6 +110,14 @@ def create_stub(opts) end end + if opts.test_case == 'oauth2_auth_token' + auth_creds = Google::Auth.get_application_default(opts.oauth_scope) + kw = auth_creds.updater_proc.call({}) # gives as an auth token + + # use a metadata update proc that just adds the auth token. + stub_opts[:update_metadata] = proc { |md| md.merge(kw) } + end + if opts.test_case == 'jwt_token_creds' # don't use a scope auth_creds = Google::Auth.get_application_default stub_opts[:update_metadata] = auth_creds.updater_proc @@ -228,6 +236,33 @@ class NamedTests p 'OK: compute_engine_creds' end + def oauth2_auth_token + resp = perform_large_unary(fill_username: true, + fill_oauth_scope: true) + json_key = File.read(ENV[AUTH_ENV]) + wanted_email = MultiJson.load(json_key)['client_email'] + assert_equal(wanted_email, resp.username, + "#{__callee__}: incorrect username") + assert(@args.oauth_scope.include?(resp.oauth_scope), + "#{__callee__}: incorrect oauth_scope") + p "OK: #{__callee__}" + end + + def per_rpc_creds + auth_creds = Google::Auth.get_application_default(@args.oauth_scope) + kw = auth_creds.updater_proc.call({}) + resp = perform_large_unary(fill_username: true, + fill_oauth_scope: true, + **kw) + json_key = File.read(ENV[AUTH_ENV]) + wanted_email = MultiJson.load(json_key)['client_email'] + assert_equal(wanted_email, resp.username, + "#{__callee__}: incorrect username") + assert(@args.oauth_scope.include?(resp.oauth_scope), + "#{__callee__}: incorrect oauth_scope") + p "OK: #{__callee__}" + end + def client_streaming msg_sizes = [27_182, 8, 1828, 45_904] wanted_aggregate_size = 74_922 @@ -276,6 +311,18 @@ class NamedTests p "OK: #{__callee__}" end + def empty_stream + ppp = PingPongPlayer.new([]) + resps = @stub.full_duplex_call(ppp.each_item) + count = 0 + resps.each do + |r| ppp.queue.push(r) + count += 1 + end + assert_equal(0, count, 'too many responses, expect 0') + p 'OK: empty_stream' + end + def cancel_after_begin msg_sizes = [27_182, 8, 1828, 45_904] reqs = msg_sizes.map do |x| @@ -311,7 +358,7 @@ class NamedTests private - def perform_large_unary(fill_username: false, fill_oauth_scope: false) + def perform_large_unary(fill_username: false, fill_oauth_scope: false, **kw) req_size, wanted_response_size = 271_828, 314_159 payload = Payload.new(type: :COMPRESSABLE, body: nulls(req_size)) req = SimpleRequest.new(response_type: :COMPRESSABLE, @@ -319,7 +366,7 @@ class NamedTests payload: payload) req.fill_username = fill_username req.fill_oauth_scope = fill_oauth_scope - resp = @stub.unary_call(req) + resp = @stub.unary_call(req, **kw) assert_equal(:COMPRESSABLE, resp.payload.type, 'large_unary: payload had the wrong type') assert_equal(wanted_response_size, resp.payload.body.length, -- cgit v1.2.3