Ejemplo n.º 1
0
    def test_olm_event(self):
        parsed_dict = TestClass._load_response("tests/data/events/olm.json")
        event = ToDeviceEvent.parse_event(parsed_dict)

        assert isinstance(event, OlmEvent)

        parsed_dict["content"]["algorithm"] = "m.megolm.unknown"
        event = ToDeviceEvent.parse_event(parsed_dict)

        assert not event
Ejemplo n.º 2
0
    def test_room_key_request(self):
        parsed_dict = TestClass._load_response(
            "tests/data/events/room_key_request.json")
        event = ToDeviceEvent.parse_event(parsed_dict)

        assert isinstance(event, RoomKeyRequest)
        assert event.room_id is not None

        parsed_dict = TestClass._load_response(
            "tests/data/events/room_key_request_cancel.json")
        event = ToDeviceEvent.parse_event(parsed_dict)

        assert isinstance(event, RoomKeyRequestCancellation)
Ejemplo n.º 3
0
 def test_key_verification_events(self):
     for event_type, event_file in [
         (KeyVerificationStart, "key_start.json"),
         (KeyVerificationAccept, "key_accept.json"),
         (KeyVerificationKey, "key_key.json"),
         (KeyVerificationMac, "key_mac.json"),
         (KeyVerificationCancel, "key_cancel.json"),
     ]:
         parsed_dict = TestClass._load_response(
             "tests/data/events/{}".format(event_file))
         event = ToDeviceEvent.parse_event(parsed_dict)
         assert isinstance(event, event_type)
Ejemplo n.º 4
0
 def test_invalid_key_verification(self):
     for _, event_file in [
         (KeyVerificationStart, "key_start.json"),
         (KeyVerificationAccept, "key_accept.json"),
         (KeyVerificationKey, "key_key.json"),
         (KeyVerificationMac, "key_mac.json"),
         (KeyVerificationCancel, "key_cancel.json"),
     ]:
         parsed_dict = TestClass._load_response(
             "tests/data/events/{}".format(event_file))
         parsed_dict["content"].pop("transaction_id")
         event = ToDeviceEvent.parse_event(parsed_dict)
         assert isinstance(event, UnknownBadEvent)
Ejemplo n.º 5
0
 def test_olm_event(self):
     parsed_dict = TestClass._load_response(
         "tests/data/events/olm_event.json")
     event = ToDeviceEvent.parse_event(parsed_dict)
     assert isinstance(event, OlmEvent)