def test_device_get_by_sender_key(self): store = DeviceStore() for _ in range(10): store.add(faker.olm_device()) device = faker.olm_device() store.add(device) fetched_device = store.device_from_sender_key(device.user_id, device.curve25519) assert fetched_device == device
def test_client_protocol_error(self): client = Client(USER, DEVICE_ID) with pytest.raises(LocalProtocolError): client.olm_account_shared with pytest.raises(LocalProtocolError): client.blacklist_device(faker.olm_device()) with pytest.raises(LocalProtocolError): client.unblacklist_device(faker.olm_device()) with pytest.raises(LocalProtocolError): client.verify_device(faker.olm_device()) with pytest.raises(LocalProtocolError): client.unverify_device(faker.olm_device()) with pytest.raises(LocalProtocolError): client.decrypt_event(None) with pytest.raises(LocalProtocolError): client.decrypt_event(None) with pytest.raises(LocalProtocolError): client.device_store client = HttpClient(HOST, USER, DEVICE_ID) with pytest.raises(LocalProtocolError): client.share_group_session(None) with pytest.raises(LocalProtocolError): client.keys_claim(None) with pytest.raises(LocalProtocolError): client.keys_query(None)
def example_devices(self): devices = defaultdict(dict) for _ in range(10): device = faker.olm_device() devices[device.user_id][device.id] = device bob_device = OlmDevice(BOB_ID, BOB_DEVICE, { "ed25519": BOB_ONETIME, "curve25519": BOB_CURVE }) devices[BOB_ID][BOB_DEVICE] = bob_device return devices
def test_client_unknown_device(self, olm_machine): alice_device = OlmDevice(olm_machine.user_id, olm_machine.device_id, olm_machine.account.identity_keys) bob_device = faker.olm_device() bob_sas = Sas(bob_device.user_id, bob_device.id, bob_device.ed25519, alice_device) start = { "sender": bob_device.user_id, "content": bob_sas.start_verification().content } start_event = KeyVerificationStart.from_dict(start) olm_machine.handle_key_verification(start_event) assert start_event.transaction_id not in olm_machine.key_verifications assert bob_device.user_id in olm_machine.users_for_key_query