Skip to content

Commit 752f45f

Browse files
committed
test: Unencrypted group creation (#6927)
1 parent 0299543 commit 752f45f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/chat/chat_tests.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,6 +4698,32 @@ async fn test_no_key_contacts_in_adhoc_chats() -> Result<()> {
46984698
Ok(())
46994699
}
47004700

4701+
/// Tests that key-contacts cannot be added to an unencrypted (ad hoc) group and the group and
4702+
/// messages report that they are unencrypted.
4703+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
4704+
async fn test_create_unencrypted_group_chat() -> Result<()> {
4705+
let mut tcm = TestContextManager::new();
4706+
let alice = &tcm.alice().await;
4707+
let bob = &tcm.bob().await;
4708+
let charlie = &tcm.charlie().await;
4709+
4710+
let chat_id = create_group_ex(alice, None, "Group chat").await?;
4711+
let bob_key_contact_id = alice.add_or_lookup_contact_id(bob).await;
4712+
let charlie_address_contact_id = alice.add_or_lookup_address_contact_id(charlie).await;
4713+
4714+
let res = add_contact_to_chat(alice, chat_id, bob_key_contact_id).await;
4715+
assert!(res.is_err());
4716+
4717+
add_contact_to_chat(alice, chat_id, charlie_address_contact_id).await?;
4718+
4719+
let chat = Chat::load_from_db(alice, chat_id).await?;
4720+
assert!(!chat.is_encrypted(alice).await?);
4721+
let sent_msg = alice.send_text(chat_id, "Hello").await;
4722+
let msg = Message::load_from_db(alice, sent_msg.sender_msg_id).await?;
4723+
assert!(!msg.get_showpadlock());
4724+
Ok(())
4725+
}
4726+
47014727
/// Tests that avatar cannot be set in ad hoc groups.
47024728
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
47034729
async fn test_no_avatar_in_adhoc_chats() -> Result<()> {

0 commit comments

Comments
 (0)