Exemplo n.º 1
0
def _stub(args):
    if args.oauth_scope:
        metadata_transformer = lambda x: [('Authorization', 'Bearer %s' %
                                           _oauth_access_token(args))]
    else:
        metadata_transformer = lambda x: []
    if args.use_tls:
        if args.use_test_ca:
            root_certificates = resources.test_root_certificates()
        else:
            root_certificates = resources.prod_root_certificates()

        stub = implementations.stub(
            methods.SERVICE_NAME,
            methods.CLIENT_METHODS,
            args.server_host,
            args.server_port,
            metadata_transformer=metadata_transformer,
            secure=True,
            root_certificates=root_certificates,
            server_host_override=args.server_host_override)
    else:
        stub = implementations.stub(methods.SERVICE_NAME,
                                    methods.CLIENT_METHODS,
                                    args.server_host,
                                    args.server_port,
                                    secure=False)
    return stub
Exemplo n.º 2
0
def _stub(args):
  if args.oauth_scope:
    if args.test_case == 'oauth2_auth_token':
      access_token = _oauth_access_token(args)
      metadata_transformer = lambda x: [
          ('Authorization', 'Bearer %s' % access_token)]
    else:
      metadata_transformer = lambda x: [
          ('Authorization', 'Bearer %s' % _oauth_access_token(args))]
  else:
    metadata_transformer = lambda x: []
  if args.use_tls:
    if args.use_test_ca:
      root_certificates = resources.test_root_certificates()
    else:
      root_certificates = resources.prod_root_certificates()

    stub = implementations.stub(
        methods.SERVICE_NAME, methods.CLIENT_METHODS, args.server_host,
        args.server_port, metadata_transformer=metadata_transformer,
        secure=True, root_certificates=root_certificates,
        server_host_override=args.server_host_override)
  else:
    stub = implementations.stub(
        methods.SERVICE_NAME, methods.CLIENT_METHODS, args.server_host,
        args.server_port, secure=False)
  return stub
Exemplo n.º 3
0
def _stub(args):
    if args.oauth_scope:
        if args.test_case == 'oauth2_auth_token':
            # TODO(jtattermusch): This testcase sets the auth metadata key-value
            # manually, which also means that the user would need to do the same
            # thing every time he/she would like to use and out of band oauth token.
            # The transformer function that produces the metadata key-value from
            # the access token should be provided by gRPC auth library.
            access_token = _oauth_access_token(args)
            metadata_transformer = lambda x: [('authorization', 'Bearer %s' %
                                               access_token)]
        else:
            metadata_transformer = lambda x: [('authorization', 'Bearer %s' %
                                               _oauth_access_token(args))]
    else:
        metadata_transformer = lambda x: []
    if args.use_tls:
        if args.use_test_ca:
            root_certificates = resources.test_root_certificates()
        else:
            root_certificates = resources.prod_root_certificates()

        channel = test_utilities.not_really_secure_channel(
            args.server_host, args.server_port,
            implementations.ssl_client_credentials(root_certificates, None,
                                                   None),
            args.server_host_override)
        stub = test_pb2.beta_create_TestService_stub(
            channel, metadata_transformer=metadata_transformer)
    else:
        channel = implementations.insecure_channel(args.server_host,
                                                   args.server_port)
        stub = test_pb2.beta_create_TestService_stub(channel)
    return stub
Exemplo n.º 4
0
def _stub(args):
  if args.oauth_scope:
    if args.test_case == 'oauth2_auth_token':
      # TODO(jtattermusch): This testcase sets the auth metadata key-value
      # manually, which also means that the user would need to do the same
      # thing every time he/she would like to use and out of band oauth token.
      # The transformer function that produces the metadata key-value from
      # the access token should be provided by gRPC auth library.
      access_token = _oauth_access_token(args)
      metadata_transformer = lambda x: [
          ('authorization', 'Bearer %s' % access_token)]
    else:
      metadata_transformer = lambda x: [
          ('authorization', 'Bearer %s' % _oauth_access_token(args))]
  else:
    metadata_transformer = lambda x: []
  if args.use_tls:
    if args.use_test_ca:
      root_certificates = resources.test_root_certificates()
    else:
      root_certificates = resources.prod_root_certificates()

    channel = test_utilities.not_really_secure_channel(
        args.server_host, args.server_port,
        implementations.ssl_client_credentials(root_certificates, None, None),
        args.server_host_override)
    stub = test_pb2.beta_create_TestService_stub(
        channel, metadata_transformer=metadata_transformer)
  else:
    channel = implementations.insecure_channel(
        args.server_host, args.server_port)
    stub = test_pb2.beta_create_TestService_stub(channel)
  return stub
Exemplo n.º 5
0
def _stub(args):
  if args.oauth_scope:
    if args.test_case == 'oauth2_auth_token':
      # TODO(jtattermusch): This testcase sets the auth metadata key-value
      # manually, which also means that the user would need to do the same
      # thing every time he/she would like to use and out of band oauth token.
      # The transformer function that produces the metadata key-value from
      # the access token should be provided by gRPC auth library.
      access_token = _oauth_access_token(args)
      metadata_transformer = lambda x: [
          ('authorization', 'Bearer %s' % access_token)]
    else:
      metadata_transformer = lambda x: [
          ('authorization', 'Bearer %s' % _oauth_access_token(args))]
  else:
    metadata_transformer = lambda x: []
  if args.use_tls:
    if args.use_test_ca:
      root_certificates = resources.test_root_certificates()
    else:
      root_certificates = resources.prod_root_certificates()

    stub = implementations.stub(
        methods.SERVICE_NAME, methods.CLIENT_METHODS, args.server_host,
        args.server_port, metadata_transformer=metadata_transformer,
        secure=True, root_certificates=root_certificates,
        server_host_override=args.server_host_override)
  else:
    stub = implementations.stub(
        methods.SERVICE_NAME, methods.CLIENT_METHODS, args.server_host,
        args.server_port, secure=False)
  return stub