Ejemplo n.º 1
0
    def setUpClass(cls):
        args = {"NodeName": "DasValidator"}
        poet_enclave.initialize(**args)
        SignupInfo.poet_enclave = poet_enclave

        cls._originator_public_key_hash = create_random_public_key_hash()
        cls._another_public_key_hash = create_random_public_key_hash()
Ejemplo n.º 2
0
    def setUpClass(cls):
        args = {"NodeName": "DasValidator"}
        poet_enclave.initialize(**args)
        SignupInfo.poet_enclave = poet_enclave

        cls._originator_public_key_hash = create_random_public_key_hash()
        cls._another_public_key_hash = create_random_public_key_hash()
Ejemplo n.º 3
0
    def setUpClass(cls):

        enclave_path = \
            os.path.join(
                os.path.abspath(
                    os.path.dirname(
                        os.path.relpath(__file__))),
                '..',
                '..',
                'sawtooth_ias_proxy')
        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': 'dummy_cert.pem'
        }

        cls._temp_dir = tempfile.mkdtemp()

        with mock.patch(
                'sawtooth_poet_sgx.poet_enclave_sgx.poet_enclave.open'):
            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()
Ejemplo n.º 4
0
    def test_verify(self):
        addr = random_name(34)
        signup_info = poet.create_signup_info(
            originator_public_key_hash=self._originator_public_key_hash,
            nonce=poet.NULL_IDENTIFIER)

        wait_cert = self.get_wait_cert(signup_info=signup_info, addr=addr)
        poet.verify_wait_certificate(wait_cert, signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate([], signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate({}, signup_info.poet_public_key)

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(None, signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate("3", signup_info.poet_public_key)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(3, signup_info.poet_public_key)

        # Bad public key types
        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, [])

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, {})

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(wait_cert, None)

        with self.assertRaises(TypeError):
            poet.verify_wait_certificate(wait_cert, 3)

        # A different public key
        other_signup_info = poet.create_signup_info(
            originator_public_key_hash=create_random_public_key_hash(),
            nonce=poet.NULL_IDENTIFIER)

        with self.assertRaises(ValueError):
            poet.verify_wait_certificate(wait_cert,
                                         other_signup_info.poet_public_key)
 def setUpClass(cls):
     cls._originator_public_key_hash = create_random_public_key_hash()
     cls._original_target_wait_time = WaitTimer.target_wait_time
     WaitTimer.target_wait_time = 5.0
Ejemplo n.º 6
0
 def setUpClass(cls):
     cls._originator_public_key_hash = create_random_public_key_hash()
     cls._original_target_wait_time = WaitTimer.target_wait_time
     WaitTimer.target_wait_time = 5.0
 def setUpClass(cls):
     cls._originator_public_key_hash = create_random_public_key_hash()
Ejemplo n.º 8
0
    def setUpClass(cls):
        # Reload the wait timer module to clear any changed global state
        reload(wait_timer)

        cls._originator_public_key_hash = create_random_public_key_hash()
Ejemplo n.º 9
0
    def setUpClass(cls):
        # Reload the wait timer module to clear any changed global state
        reload(wait_timer)

        cls._originator_public_key_hash = create_random_public_key_hash()