From ea9556b1b9b6ecb89ff12374299e201386484588 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 17 Nov 2023 15:01:56 +0000 Subject: [PATCH] test: port test_aeap_flow_verified to JSON-RPC --- deltachat-rpc-client/tests/test_securejoin.py | 42 +++++++++++++++++++ python/tests/test_1_online.py | 41 ------------------ 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/deltachat-rpc-client/tests/test_securejoin.py b/deltachat-rpc-client/tests/test_securejoin.py index 65796db1d..82f96ca43 100644 --- a/deltachat-rpc-client/tests/test_securejoin.py +++ b/deltachat-rpc-client/tests/test_securejoin.py @@ -387,3 +387,45 @@ def test_qr_new_group_unblocked(acfactory): ac2_msg = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot() assert ac2_msg.text == "Hello!" assert ac2_msg.chat.get_basic_snapshot().is_contact_request + + +def test_aeap_flow_verified(acfactory): + """Test that a new address is added to a contact when it changes its address.""" + ac1, ac2, ac1new = acfactory.get_online_accounts(3) + + logging.info("ac1: create verified-group QR, ac2 scans and joins") + chat = ac1.create_group("hello", protect=True) + assert chat.get_basic_snapshot().is_protected + qr_code, _svg = chat.get_qr_code() + logging.info("ac2: start QR-code based join-group protocol") + ac2.secure_join(qr_code) + ac1.wait_for_securejoin_inviter_success() + + logging.info("sending first message") + msg_out = chat.send_text("old address").get_snapshot() + + logging.info("receiving first message") + ac2.wait_for_incoming_msg_event() # member added message + msg_in_1 = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id).get_snapshot() + assert msg_in_1.text == msg_out.text + + logging.info("changing email account") + ac1.set_config("addr", ac1new.get_config("addr")) + ac1.set_config("mail_pw", ac1new.get_config("mail_pw")) + ac1.stop_io() + ac1.configure() + ac1.start_io() + + logging.info("sending second message") + msg_out = chat.send_text("changed address").get_snapshot() + + logging.info("receiving second message") + msg_in_2 = ac2.get_message_by_id(ac2.wait_for_incoming_msg_event().msg_id) + msg_in_2_snapshot = msg_in_2.get_snapshot() + assert msg_in_2_snapshot.text == msg_out.text + assert msg_in_2_snapshot.chat.id == msg_in_1.chat.id + assert msg_in_2.get_sender_contact().get_snapshot().address == ac1new.get_config("addr") + assert len(msg_in_2_snapshot.chat.get_contacts()) == 2 + assert ac1new.get_config("addr") in [ + contact.get_snapshot().address for contact in msg_in_2_snapshot.chat.get_contacts() + ] diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 3c77535d9..608f2b06d 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -2405,47 +2405,6 @@ def test_delete_deltachat_folder(acfactory): assert "DeltaChat" in ac1.direct_imap.list_folders() -def test_aeap_flow_verified(acfactory, lp): - """Test that a new address is added to a contact when it changes its address.""" - ac1, ac2, ac1new = acfactory.get_online_accounts(3) - - lp.sec("ac1: create verified-group QR, ac2 scans and joins") - chat = ac1.create_group_chat("hello", verified=True) - assert chat.is_protected() - qr = chat.get_join_qr() - lp.sec("ac2: start QR-code based join-group protocol") - chat2 = ac2.qr_join_chat(qr) - assert chat2.id >= 10 - ac1._evtracker.wait_securejoin_inviter_progress(1000) - - lp.sec("sending first message") - msg_out = chat.send_text("old address") - - lp.sec("receiving first message") - ac2._evtracker.wait_next_incoming_message() # member added message - msg_in_1 = ac2._evtracker.wait_next_incoming_message() - assert msg_in_1.text == msg_out.text - - lp.sec("changing email account") - ac1.set_config("addr", ac1new.get_config("addr")) - ac1.set_config("mail_pw", ac1new.get_config("mail_pw")) - ac1.stop_io() - configtracker = ac1.configure() - configtracker.wait_finish() - ac1.start_io() - - lp.sec("sending second message") - msg_out = chat.send_text("changed address") - - lp.sec("receiving second message") - msg_in_2 = ac2._evtracker.wait_next_incoming_message() - assert msg_in_2.text == msg_out.text - assert msg_in_2.chat.id == msg_in_1.chat.id - assert msg_in_2.get_sender_contact().addr == ac1new.get_config("addr") - assert len(msg_in_2.chat.get_contacts()) == 2 - assert ac1new.get_config("addr") in [contact.addr for contact in msg_in_2.chat.get_contacts()] - - def test_archived_muted_chat(acfactory, lp): """If an archived and muted chat receives a new message, DC_EVENT_MSGS_CHANGED for DC_CHAT_ID_ARCHIVED_LINK must be generated if the chat had only seen messages previously.