Пример #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
Пример #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)
Пример #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)
Пример #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)
Пример #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)