async def test_generate(self, cli, tmpdir): private_key_file = tmpdir.join('tmp_private_key') public_key_file = tmpdir.join('tmp_public_key') await cli('generate', str(private_key_file), str(public_key_file)) private_key = Key.decode(private_key_file.read().strip(), Key.Type.private) public_key = Key.decode(public_key_file.read().strip(), Key.Type.public) assert private_key assert public_key
def msgapi_plugin(): private = 'private:dd9413d597092b004fedc4895db978425efa328ba1f1ec6729e46e09231b8a7e' public = Key.encode( Key.derive_public(Key.decode(private, Key.Type.private))) msgapi = { 'msgapi': { 'cli_path': os.path.join( os.path.dirname(__file__), '../threema/gateway/bin/gateway_client.py', ), 'cert_path': os.path.join(_res_path, 'cert.pem'), 'base_url': 'https://msgapi.threema.ch', 'ip': '127.0.0.1', 'id': '*MOCKING', 'secret': 'mock', 'private': private, 'public': public, 'nocredit_id': 'NOCREDIT', 'noexist_id': '*NOEXIST', } } return msgapi
def __init__(self): self.threema_jpg = os.path.join(_res_path, 'threema.jpg') self.threema_mp4 = os.path.join(_res_path, 'threema.mp4') key = b'4a6a1b34dcef15d43cb74de2fd36091be99fbbaf126d099d47d83d919712c72b' self.echoecho_key = key self.echoecho_encoded_key = 'public:' + key.decode('ascii') decoded_private_key = Key.decode(pytest.msgapi.private, Key.Type.private) self.mocking_key = Key.derive_public(decoded_private_key).hex_pk() self.blobs = {} self.latest_blob_ids = [] self.routes = [ web.get('/pubkeys/{key}', self.pubkeys), web.get('/lookup/phone/{phone}', self.lookup_phone), web.get('/lookup/phone_hash/{phone_hash}', self.lookup_phone_hash), web.get('/lookup/email/{email}', self.lookup_email), web.get('/lookup/email_hash/{email_hash}', self.lookup_email_hash), web.get('/capabilities/{id}', self.capabilities), web.get('/credits', self.credits), web.post('/send_simple', self.send_simple), web.post('/send_e2e', self.send_e2e), web.post('/upload_blob', self.upload_blob), web.get('/blobs/{blob_id}', self.download_blob), ]
def key(self, key): if isinstance(key, str): key = Key.decode(key, Key.Type.public) self._key = key