Exemple #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
Exemple #2
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
Exemple #3
0
def _stub(args):
  if args.use_tls:
    if args.use_test_ca:
      root_certificates = resources.test_root_certificates()
    else:
      root_certificates = resources.prod_root_certificates()

    stub = implementations.secure_stub(
        methods.CLIENT_METHODS, args.server_host, args.server_port,
        root_certificates, None, None,
        server_host_override=args.server_host_override)
  else:
    stub = implementations.insecure_stub(
        methods.CLIENT_METHODS, args.server_host, args.server_port)
  return stub
Exemple #4
0
def _stub(args):
    if args.use_tls:
        if args.use_test_ca:
            root_certificates = resources.test_root_certificates()
        else:
            root_certificates = resources.prod_root_certificates()
        # TODO(nathaniel): server host override.

        stub = implementations.secure_stub(methods.CLIENT_METHODS,
                                           args.server_host, args.server_port,
                                           root_certificates, None, None)
    else:
        stub = implementations.insecure_stub(methods.CLIENT_METHODS,
                                             args.server_host,
                                             args.server_port)
    return stub
Exemple #5
0
def _stub(args):
  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, 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
Exemple #6
0
def _stub(args):
    if args.use_tls:
        if args.use_test_ca:
            root_certificates = resources.test_root_certificates()
        else:
            root_certificates = resources.prod_root_certificates()

        stub = implementations.secure_stub(
            methods.SERVICE_NAME,
            methods.CLIENT_METHODS,
            args.server_host,
            args.server_port,
            root_certificates,
            None,
            None,
            server_host_override=args.server_host_override)
    else:
        stub = implementations.insecure_stub(methods.SERVICE_NAME,
                                             methods.CLIENT_METHODS,
                                             args.server_host,
                                             args.server_port)
    return stub