Skip to content

Commit e4b14e2

Browse files
committed
test: Unencrypted group creation (#6927)
1 parent e8f3948 commit e4b14e2

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
@@ -4312,6 +4312,32 @@ async fn test_no_key_contacts_in_adhoc_chats() -> Result<()> {
43124312
Ok(())
43134313
}
43144314

4315+
/// Tests that PGP-contacts cannot be added to an unencrypted (ad hoc) group and the group and
4316+
/// messages report that they are unencrypted.
4317+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
4318+
async fn test_create_unencrypted_group_chat() -> Result<()> {
4319+
let mut tcm = TestContextManager::new();
4320+
let alice = &tcm.alice().await;
4321+
let bob = &tcm.bob().await;
4322+
let charlie = &tcm.charlie().await;
4323+
4324+
let chat_id = create_group_ex(alice, None, "Group chat").await?;
4325+
let pgp_bob_contact_id = alice.add_or_lookup_contact_id(bob).await;
4326+
let email_charlie_contact_id = alice.add_or_lookup_email_contact_id(charlie).await;
4327+
4328+
let res = add_contact_to_chat(alice, chat_id, pgp_bob_contact_id).await;
4329+
assert!(res.is_err());
4330+
4331+
add_contact_to_chat(alice, chat_id, email_charlie_contact_id).await?;
4332+
4333+
let chat = Chat::load_from_db(alice, chat_id).await?;
4334+
assert!(!chat.is_encrypted(alice).await?);
4335+
let sent_msg = alice.send_text(chat_id, "Hello").await;
4336+
let msg = Message::load_from_db(alice, sent_msg.sender_msg_id).await?;
4337+
assert!(!msg.get_showpadlock());
4338+
Ok(())
4339+
}
4340+
43154341
/// Tests that avatar cannot be set in ad hoc groups.
43164342
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
43174343
async fn test_no_avatar_in_adhoc_chats() -> Result<()> {

0 commit comments

Comments
 (0)