Ejemplo n.º 1
0
 def __init__(self, test_name: Text):
     self._server = {}
     self._output_file = {}
     self._channel = {}
     self._metadata_stub = {}
     self._keyset_stub = {}
     self._aead_stub = {}
     self._daead_stub = {}
     self._streaming_aead_stub = {}
     self._hybrid_stub = {}
     self._mac_stub = {}
     self._signature_stub = {}
     self._prf_stub = {}
     self._jwt_stub = {}
     for lang in LANGUAGES:
         port = portpicker.pick_unused_port()
         cmd = _server_cmd(lang, port)
         logging.info('cmd = %s', cmd)
         try:
             output_dir = os.environ['TEST_UNDECLARED_OUTPUTS_DIR']
         except KeyError:
             raise RuntimeError(
                 'Could not start %s server, TEST_UNDECLARED_OUTPUTS_DIR environment'
                 'variable must be set')
         output_file = '%s-%s-%s' % (test_name, lang, 'server.log')
         output_path = os.path.join(output_dir, output_file)
         logging.info('writing server output to %s', output_path)
         try:
             self._output_file[lang] = open(output_path, 'w+')
         except IOError:
             logging.info('unable to open server output file %s',
                          output_path)
             raise RuntimeError('Could not start %s server' % lang)
         self._server[lang] = subprocess.Popen(
             cmd, stdout=self._output_file[lang], stderr=subprocess.STDOUT)
         logging.info('%s server started on port %d with pid: %d.', lang,
                      port, self._server[lang].pid)
         self._channel[lang] = grpc.secure_channel(
             '[::]:%d' % port, grpc.local_channel_credentials())
     for lang in LANGUAGES:
         try:
             grpc.channel_ready_future(
                 self._channel[lang]).result(timeout=30)
         except:
             logging.info('Timeout while connecting to server %s', lang)
             self._server[lang].kill()
             out, err = self._server[lang].communicate()
             raise RuntimeError(
                 'Could not start %s server, output=%s, err=%s' %
                 (lang, out, err))
         self._metadata_stub[lang] = testing_api_pb2_grpc.MetadataStub(
             self._channel[lang])
         self._keyset_stub[lang] = testing_api_pb2_grpc.KeysetStub(
             self._channel[lang])
     for primitive in _PRIMITIVES:
         for lang in SUPPORTED_LANGUAGES_BY_PRIMITIVE[primitive]:
             stub_name = '_%s_stub' % primitive
             getattr(self, stub_name)[lang] = _PRIMITIVE_STUBS[primitive](
                 self._channel[lang])
Ejemplo n.º 2
0
 def setUpClass(cls):
     super().setUpClass()
     port = portpicker.pick_unused_port()
     cls._server = subprocess.Popen([
         _server_path(),
         '-port',
         '%d' % port,
     ],
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
     logging.info('Server started on port %d with pid: %d.', port,
                  cls._server.pid)
     cls._channel = grpc.secure_channel('[::]:%d' % port,
                                        grpc.local_channel_credentials())
     grpc.channel_ready_future(cls._channel).result()
     cls._keyset_stub = testing_api_pb2_grpc.KeysetStub(cls._channel)
     cls._aead_stub = testing_api_pb2_grpc.AeadStub(cls._channel)
Ejemplo n.º 3
0
 def __init__(self):
   self._server = {}
   self._channel = {}
   self._metadata_stub = {}
   self._keyset_stub = {}
   self._aead_stub = {}
   self._daead_stub = {}
   self._hybrid_stub = {}
   self._mac_stub = {}
   self._signature_stub = {}
   for lang in LANGUAGES:
     port = portpicker.pick_unused_port()
     cmd = _server_cmd(lang, port)
     logging.info('cmd = %s', cmd)
     self._server[lang] = subprocess.Popen(
         cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     logging.info('%s server started on port %d with pid: %d.',
                  lang, port, self._server[lang].pid)
     self._channel[lang] = grpc.secure_channel(
         '[::]:%d' % port, grpc.local_channel_credentials())
   for lang in LANGUAGES:
     try:
       grpc.channel_ready_future(self._channel[lang]).result(timeout=30)
     except:
       logging.info('Timeout while connecting to server %s', lang)
       self._server[lang].kill()
       out, err = self._server[lang].communicate()
       raise RuntimeError(
           'Could not start %s server, output=%s, err=%s' % (lang, out, err))
     self._metadata_stub[lang] = testing_api_pb2_grpc.MetadataStub(
         self._channel[lang])
     self._keyset_stub[lang] = testing_api_pb2_grpc.KeysetStub(
         self._channel[lang])
     self._aead_stub[lang] = testing_api_pb2_grpc.AeadStub(
         self._channel[lang])
     self._daead_stub[lang] = testing_api_pb2_grpc.DeterministicAeadStub(
         self._channel[lang])
     self._hybrid_stub[lang] = testing_api_pb2_grpc.HybridStub(
         self._channel[lang])
     self._mac_stub[lang] = testing_api_pb2_grpc.MacStub(
         self._channel[lang])
     self._signature_stub[lang] = testing_api_pb2_grpc.SignatureStub(
         self._channel[lang])
Ejemplo n.º 4
0
 def __init__(self):
     self._server = {}
     self._channel = {}
     self._metadata_stub = {}
     self._keyset_stub = {}
     self._aead_stub = {}
     self._daead_stub = {}
     self._streaming_aead_stub = {}
     self._hybrid_stub = {}
     self._mac_stub = {}
     self._signature_stub = {}
     self._prf_stub = {}
     for lang in LANGUAGES:
         port = portpicker.pick_unused_port()
         cmd = _server_cmd(lang, port)
         logging.info('cmd = %s', cmd)
         self._server[lang] = subprocess.Popen(cmd,
                                               stdout=subprocess.PIPE,
                                               stderr=subprocess.STDOUT)
         logging.info('%s server started on port %d with pid: %d.', lang,
                      port, self._server[lang].pid)
         self._channel[lang] = grpc.secure_channel(
             '[::]:%d' % port, grpc.local_channel_credentials())
     for lang in LANGUAGES:
         try:
             grpc.channel_ready_future(
                 self._channel[lang]).result(timeout=30)
         except:
             logging.info('Timeout while connecting to server %s', lang)
             self._server[lang].kill()
             out, err = self._server[lang].communicate()
             raise RuntimeError(
                 'Could not start %s server, output=%s, err=%s' %
                 (lang, out, err))
         self._metadata_stub[lang] = testing_api_pb2_grpc.MetadataStub(
             self._channel[lang])
         self._keyset_stub[lang] = testing_api_pb2_grpc.KeysetStub(
             self._channel[lang])
     for primitive in _PRIMITIVES:
         for lang in SUPPORTED_LANGUAGES_BY_PRIMITIVE[primitive]:
             stub_name = '_%s_stub' % primitive
             getattr(self, stub_name)[lang] = _PRIMITIVE_STUBS[primitive](
                 self._channel[lang])