Skip to content

The agent that grows with you

test(matrix): fold plaintext-room case into the encrypted-drop warn test

kshitijk4poor4e2aad9baa7e
diff --git a/tests/gateway/test_matrix.py b/tests/gateway/test_matrix.py
index a0706727997..7de2fb82131 100644
--- a/tests/gateway/test_matrix.py
+++ b/tests/gateway/test_matrix.py
@@ -1191,17 +1191,21 @@ class TestMatrixSyncLoop:
adapter._client = fake_client
sync_data = {
- "rooms": {"join": {"!enc:example.org": {
- "timeline": {"events": [{"type": "m.room.encrypted", "event_id": "$e1"}]}}}},
+ "rooms": {"join": {
+ "!enc:example.org": {"timeline": {"events": [
+ {"type": "m.room.encrypted", "event_id": "$e1"}]}},
+ "!plain:example.org": {"timeline": {"events": [
+ {"type": "m.room.message", "event_id": "$m1"}]}},
+ }},
"next_batch": "s1",
}
with caplog.at_level(logging.WARNING, logger="plugins.platforms.matrix.adapter"):
await adapter._absorb_sync(fake_client, sync_data)
await adapter._absorb_sync(fake_client, sync_data) # rate-limited: one warning per room
- warnings = [r for r in caplog.records
- if "!enc:example.org" in r.getMessage() and "encrypted" in r.getMessage()]
+ warnings = [r.getMessage() for r in caplog.records if "encrypted" in r.getMessage()]
assert len(warnings) == 1
+ assert "!enc:example.org" in warnings[0] and "MATRIX_E2EE_MODE" in warnings[0]
@pytest.mark.asyncio
async def test_absorb_sync_no_encrypted_warning_when_crypto_attached(self, caplog):
@@ -1223,26 +1227,6 @@ class TestMatrixSyncLoop:
assert not [r for r in caplog.records if "encrypted" in r.getMessage()]
- @pytest.mark.asyncio
- async def test_absorb_sync_no_warning_for_plaintext_events_without_crypto(
- self, caplog
- ):
- """Plain rooms must not trip the encrypted-drop warning."""
- adapter = _make_adapter()
- adapter._closing = False
- fake_client = self._cryptoless_client()
- adapter._client = fake_client
-
- sync_data = {
- "rooms": {"join": {"!plain:example.org": {
- "timeline": {"events": [{"type": "m.room.message", "event_id": "$m1"}]}}}},
- "next_batch": "s1",
- }
- with caplog.at_level(logging.WARNING, logger="plugins.platforms.matrix.adapter"):
- await adapter._absorb_sync(fake_client, sync_data)
-
- assert not [r for r in caplog.records if "encrypted" in r.getMessage()]
-
@pytest.mark.asyncio
async def test_sync_loop_dispatches_registered_room_message_handler(self):
"""Inbound sync data should flow through handle_sync into message handling."""