def setUpClass(cls): enclave_path = \ os.path.join( os.path.abspath( os.path.dirname( os.path.relpath(__file__))), '..', '..', 'sawtooth_poet_sgx', 'poet_enclave_sgx') cls.proxy_proc = \ subprocess.Popen( args=['python3', 'ias_proxy.py'], cwd=enclave_path) print('Launched proxy server on pid: ' + str(cls.proxy_proc.pid)) # Depending upon timing, the test can try to contact the proxy before # it is ready to accept connections. So, until the proxy is ready # block the tests from progressing. # Note - if IAS proxy port changes, change this also while True: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if sock.connect_ex(('localhost', 8899)) == 0: sock.close() break sock.close() print('IAS proxy not ready to accept connections') time.sleep(1) cls._mock_toml_config = { 'spid': os.environ['POET_ENCLAVE_SPID'], 'ias_url': 'http://localhost:8899', 'spid_cert_file': os.path.join(get_default_path_config().config_dir, 'maiden-lane-poet-linkable-quotes.pem') } cls._temp_dir = tempfile.mkdtemp() with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _: with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \ as mock_toml: mock_toml.loads.return_value = cls._mock_toml_config poet.initialize(config_dir='', data_dir=cls._temp_dir) cls._originator_public_key_hash = create_random_public_key_hash()
def setUpClass(cls): enclave_path = \ os.path.join( os.path.abspath( os.path.dirname( os.path.relpath(__file__))), '..', '..', 'sawtooth_poet_sgx', 'poet_enclave_sgx') cls.proxy_proc = \ subprocess.Popen( args=['python3', 'ias_proxy.py'], cwd=enclave_path) print('Launched proxy server on pid: ' + str(cls.proxy_proc.pid)) # Depending upon timing, the test can try to contact the proxy before # it is ready to accept connections. So, until the proxy is ready # block the tests from progressing. # Note - if IAS proxy port changes, change this also while True: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if sock.connect_ex(('localhost', 8899)) == 0: sock.close() break sock.close() print('IAS proxy not ready to accept connections') time.sleep(1) cls._mock_toml_config = { 'spid': os.environ['POET_ENCLAVE_SPID'], 'ias_url': 'http://localhost:8899', 'spid_cert_file': os.path.join( get_default_path_config().config_dir, 'maiden-lane-poet-linkable-quotes.pem') } cls._temp_dir = tempfile.mkdtemp() with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _: with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \ as mock_toml: mock_toml.loads.return_value = cls._mock_toml_config poet.initialize(config_dir='', data_dir=cls._temp_dir) cls._originator_public_key_hash = create_random_public_key_hash()
def setUpClass(cls): cls._mock_toml_config = { 'spid': os.environ['POET_ENCLAVE_SPID'], 'ias_url': 'https://test-as.sgx.trustedservices.intel.com:443', 'spid_cert_file': os.path.join( get_default_path_config().config_dir, 'maiden-lane-poet-linkable-quotes.pem') } cls._temp_dir = tempfile.mkdtemp() with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open') as _: with mock.patch( 'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.toml') \ as mock_toml: mock_toml.loads.return_value = cls._mock_toml_config poet.initialize(config_dir='', data_dir=cls._temp_dir) cls._originator_public_key_hash = create_random_public_key_hash()