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:
        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 setUp(self):
   self.server = implementations.secure_server(
       methods.SERVER_METHODS, 0, resources.private_key(),
       resources.certificate_chain())
   self.server.start()
   port = self.server.port()
   self.stub = implementations.secure_stub(
       methods.CLIENT_METHODS, 'localhost', port,
       resources.test_root_certificates(), None, None,
       server_host_override=_SERVER_HOST_OVERRIDE)
Exemplo n.º 4
0
 def setUp(self):
     self.server = implementations.secure_server(
         methods.SERVICE_NAME, methods.SERVER_METHODS, 0,
         resources.private_key(), resources.certificate_chain())
     self.server.start()
     port = self.server.port()
     self.stub = implementations.secure_stub(
         methods.SERVICE_NAME,
         methods.CLIENT_METHODS,
         'localhost',
         port,
         resources.test_root_certificates(),
         None,
         None,
         server_host_override=_SERVER_HOST_OVERRIDE)
Exemplo n.º 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.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
Exemplo n.º 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()
        # 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
Exemplo n.º 7
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
Exemplo n.º 8
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