Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #6
0
 def setUp(self):
   self.server = implementations.server(
       methods.SERVICE_NAME, methods.SERVER_METHODS, 0,
       private_key=resources.private_key(),
       certificate_chain=resources.certificate_chain())
   self.server.start()
   port = self.server.port()
   self.stub = implementations.stub(
       methods.SERVICE_NAME, methods.CLIENT_METHODS, 'localhost', port,
       secure=True, root_certificates=resources.test_root_certificates(),
       server_host_override=_SERVER_HOST_OVERRIDE)
Пример #7
0
 def setUp(self):
   self.server = test_pb2.beta_create_TestService_server(methods.TestService())
   port = self.server.add_secure_port(
       '[::]:0', implementations.ssl_server_credentials(
           [(resources.private_key(), resources.certificate_chain())]))
   self.server.start()
   self.stub = test_pb2.beta_create_TestService_stub(
       test_utilities.not_really_secure_channel(
           '[::]', port, implementations.ssl_client_credentials(
               resources.test_root_certificates(), None, None),
               _SERVER_HOST_OVERRIDE))
Пример #8
0
 def setUp(self):
     self.server = implementations.server(
         methods.SERVICE_NAME,
         methods.SERVER_METHODS,
         0,
         private_key=resources.private_key(),
         certificate_chain=resources.certificate_chain())
     self.server.start()
     port = self.server.port()
     self.stub = implementations.stub(
         methods.SERVICE_NAME,
         methods.CLIENT_METHODS,
         'localhost',
         port,
         secure=True,
         root_certificates=resources.test_root_certificates(),
         server_host_override=_SERVER_HOST_OVERRIDE)