mirror of
https://github.com/chatmail/core.git
synced 2026-10-02 03:00:40 +03:00
api!: remove default value for "addr" config
"addr" is already deprecated and its default value was using "configured_addr". We want to get rid of "configured_addr" too, but users should at least not access it through deprecated config.
This commit is contained in:
@@ -132,7 +132,7 @@ class TestOfflineContact:
|
|||||||
|
|
||||||
def test_create_self_contact(self, acfactory):
|
def test_create_self_contact(self, acfactory):
|
||||||
ac1 = acfactory.get_pseudo_configured_account()
|
ac1 = acfactory.get_pseudo_configured_account()
|
||||||
contact1 = ac1.create_contact(ac1.get_config("addr"))
|
contact1 = ac1.create_contact(ac1.get_config("configured_addr"))
|
||||||
assert contact1.id == 1
|
assert contact1.id == 1
|
||||||
|
|
||||||
def test_get_contacts_and_delete(self, acfactory):
|
def test_get_contacts_and_delete(self, acfactory):
|
||||||
@@ -223,7 +223,7 @@ class TestOfflineChat:
|
|||||||
ac2 = acfactory.get_pseudo_configured_account()
|
ac2 = acfactory.get_pseudo_configured_account()
|
||||||
chat = ac1.create_group_chat(name="title1")
|
chat = ac1.create_group_chat(name="title1")
|
||||||
contact = chat.add_contact(ac2)
|
contact = chat.add_contact(ac2)
|
||||||
assert contact.addr == ac2.get_config("addr")
|
assert contact.addr == ac2.get_config("configured_addr")
|
||||||
assert contact.name == ac2.get_config("displayname")
|
assert contact.name == ac2.get_config("displayname")
|
||||||
assert contact.account == ac1
|
assert contact.account == ac1
|
||||||
chat.remove_contact(ac2)
|
chat.remove_contact(ac2)
|
||||||
@@ -456,7 +456,7 @@ class TestOfflineChat:
|
|||||||
contacts = ac2.get_contacts()
|
contacts = ac2.get_contacts()
|
||||||
assert len(contacts) == 1
|
assert len(contacts) == 1
|
||||||
contact2 = contacts[0]
|
contact2 = contacts[0]
|
||||||
assert contact2.addr == ac_contact.get_config("addr")
|
assert contact2.addr == ac_contact.get_config("configured_addr")
|
||||||
chat2 = contact2.create_chat()
|
chat2 = contact2.create_chat()
|
||||||
messages = chat2.get_messages()
|
messages = chat2.get_messages()
|
||||||
assert len(messages) == 2 + E2EE_INFO_MSGS
|
assert len(messages) == 2 + E2EE_INFO_MSGS
|
||||||
@@ -552,7 +552,7 @@ class TestOfflineChat:
|
|||||||
contacts = ac2.get_contacts()
|
contacts = ac2.get_contacts()
|
||||||
assert len(contacts) == 1
|
assert len(contacts) == 1
|
||||||
contact2 = contacts[0]
|
contact2 = contacts[0]
|
||||||
assert contact2.addr == ac_contact.get_config("addr")
|
assert contact2.addr == ac_contact.get_config("configured_addr")
|
||||||
chat2 = contact2.create_chat()
|
chat2 = contact2.create_chat()
|
||||||
messages = chat2.get_messages()
|
messages = chat2.get_messages()
|
||||||
assert len(messages) == 2 + E2EE_INFO_MSGS
|
assert len(messages) == 2 + E2EE_INFO_MSGS
|
||||||
@@ -604,7 +604,7 @@ class TestOfflineChat:
|
|||||||
contacts = ac2.get_contacts()
|
contacts = ac2.get_contacts()
|
||||||
assert len(contacts) == 1
|
assert len(contacts) == 1
|
||||||
contact2 = contacts[0]
|
contact2 = contacts[0]
|
||||||
assert contact2.addr == ac_contact.get_config("addr")
|
assert contact2.addr == ac_contact.get_config("configured_addr")
|
||||||
chat2 = contact2.create_chat()
|
chat2 = contact2.create_chat()
|
||||||
messages = chat2.get_messages()
|
messages = chat2.get_messages()
|
||||||
assert len(messages) == 2 + E2EE_INFO_MSGS
|
assert len(messages) == 2 + E2EE_INFO_MSGS
|
||||||
@@ -621,7 +621,7 @@ class TestOfflineChat:
|
|||||||
contacts = ac2.get_contacts()
|
contacts = ac2.get_contacts()
|
||||||
assert len(contacts) == 1
|
assert len(contacts) == 1
|
||||||
contact2 = contacts[0]
|
contact2 = contacts[0]
|
||||||
assert contact2.addr == ac_contact.get_config("addr")
|
assert contact2.addr == ac_contact.get_config("configured_addr")
|
||||||
chat2 = contact2.create_chat()
|
chat2 = contact2.create_chat()
|
||||||
messages = chat2.get_messages()
|
messages = chat2.get_messages()
|
||||||
assert len(messages) == 2 + E2EE_INFO_MSGS
|
assert len(messages) == 2 + E2EE_INFO_MSGS
|
||||||
|
|||||||
@@ -549,7 +549,6 @@ impl Context {
|
|||||||
// Default values
|
// Default values
|
||||||
let val = match key {
|
let val = match key {
|
||||||
Config::ConfiguredInboxFolder => Some("INBOX".to_string()),
|
Config::ConfiguredInboxFolder => Some("INBOX".to_string()),
|
||||||
Config::Addr => self.get_config_opt(Config::ConfiguredAddr).await?,
|
|
||||||
_ => key.get_str("default").map(|s| s.to_string()),
|
_ => key.get_str("default").map(|s| s.to_string()),
|
||||||
};
|
};
|
||||||
Ok(val)
|
Ok(val)
|
||||||
|
|||||||
@@ -1219,7 +1219,7 @@ async fn test_make_n_import_vcard() -> Result<()> {
|
|||||||
tokio::fs::write(&avatar_path, avatar_bytes).await?;
|
tokio::fs::write(&avatar_path, avatar_bytes).await?;
|
||||||
bob.set_config(Config::Selfavatar, Some(avatar_path.to_str().unwrap()))
|
bob.set_config(Config::Selfavatar, Some(avatar_path.to_str().unwrap()))
|
||||||
.await?;
|
.await?;
|
||||||
let bob_addr = bob.get_config(Config::Addr).await?.unwrap();
|
let bob_addr = bob.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
let bob_biography = bob.get_config(Config::Selfstatus).await?.unwrap();
|
let bob_biography = bob.get_config(Config::Selfstatus).await?.unwrap();
|
||||||
let chat = bob.create_chat(alice).await;
|
let chat = bob.create_chat(alice).await;
|
||||||
let sent_msg = bob.send_text(chat.id, "moin").await;
|
let sent_msg = bob.send_text(chat.id, "moin").await;
|
||||||
@@ -1315,7 +1315,7 @@ async fn test_make_n_import_vcard() -> Result<()> {
|
|||||||
async fn test_import_vcard_key_change() -> Result<()> {
|
async fn test_import_vcard_key_change() -> Result<()> {
|
||||||
let alice = &TestContext::new_alice().await;
|
let alice = &TestContext::new_alice().await;
|
||||||
let bob = &TestContext::new_bob().await;
|
let bob = &TestContext::new_bob().await;
|
||||||
let bob_addr = &bob.get_config(Config::Addr).await?.unwrap();
|
let bob_addr = &bob.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
bob.set_config(Config::Displayname, Some("Bob")).await?;
|
bob.set_config(Config::Displayname, Some("Bob")).await?;
|
||||||
let vcard = make_vcard(bob, &[ContactId::SELF]).await?;
|
let vcard = make_vcard(bob, &[ContactId::SELF]).await?;
|
||||||
alice.evtracker.clear_events();
|
alice.evtracker.clear_events();
|
||||||
|
|||||||
+1
-1
@@ -961,7 +961,7 @@ mod tests {
|
|||||||
|
|
||||||
assert!(context2.is_configured().await?);
|
assert!(context2.is_configured().await?);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
context2.get_config(Config::Addr).await?,
|
context2.get_config(Config::ConfiguredAddr).await?,
|
||||||
Some("alice@example.org".to_string())
|
Some("alice@example.org".to_string())
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+4
-1
@@ -1178,7 +1178,10 @@ impl MimeFactory {
|
|||||||
};
|
};
|
||||||
let self_name = &match self_name {
|
let self_name = &match self_name {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
None => context.get_config(Config::Addr).await?.unwrap_or_default(),
|
None => context
|
||||||
|
.get_config(Config::ConfiguredAddr)
|
||||||
|
.await?
|
||||||
|
.unwrap_or_default(),
|
||||||
};
|
};
|
||||||
stock_str::subject_for_new_contact(context, self_name)
|
stock_str::subject_for_new_contact(context, self_name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -709,9 +709,9 @@ async fn test_remove_member_bcc() -> Result<()> {
|
|||||||
let charlie = &tcm.charlie().await;
|
let charlie = &tcm.charlie().await;
|
||||||
alice.allow_unencrypted().await?;
|
alice.allow_unencrypted().await?;
|
||||||
|
|
||||||
let alice_addr = alice.get_config(Config::Addr).await?.unwrap();
|
let alice_addr = alice.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
let bob_addr = bob.get_config(Config::Addr).await?.unwrap();
|
let bob_addr = bob.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
let charlie_addr = charlie.get_config(Config::Addr).await?.unwrap();
|
let charlie_addr = charlie.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
|
|
||||||
let bob_id = alice.add_or_lookup_address_contact_id(bob).await;
|
let bob_id = alice.add_or_lookup_address_contact_id(bob).await;
|
||||||
let charlie_id = alice.add_or_lookup_address_contact_id(charlie).await;
|
let charlie_id = alice.add_or_lookup_address_contact_id(charlie).await;
|
||||||
@@ -874,7 +874,7 @@ async fn test_new_member_is_first_recipient() -> Result<()> {
|
|||||||
assert!(
|
assert!(
|
||||||
sent_msg
|
sent_msg
|
||||||
.recipients
|
.recipients
|
||||||
.starts_with(&charlie.get_config(Config::Addr).await?.unwrap())
|
.starts_with(&charlie.get_config(Config::ConfiguredAddr).await?.unwrap())
|
||||||
);
|
);
|
||||||
|
|
||||||
remove_contact_from_chat(alice, group, bob_id).await?;
|
remove_contact_from_chat(alice, group, bob_id).await?;
|
||||||
@@ -885,7 +885,7 @@ async fn test_new_member_is_first_recipient() -> Result<()> {
|
|||||||
assert!(
|
assert!(
|
||||||
sent_msg
|
sent_msg
|
||||||
.recipients
|
.recipients
|
||||||
.starts_with(&bob.get_config(Config::Addr).await?.unwrap())
|
.starts_with(&bob.get_config(Config::ConfiguredAddr).await?.unwrap())
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ async fn test_broadcast_security_attacker_signature() -> Result<()> {
|
|||||||
|
|
||||||
let secret = load_broadcast_secret(alice, alice_chat_id).await?.unwrap();
|
let secret = load_broadcast_secret(alice, alice_chat_id).await?.unwrap();
|
||||||
|
|
||||||
let charlie_addr = charlie.get_config(Config::Addr).await?.unwrap();
|
let charlie_addr = charlie.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
|
|
||||||
test_shared_secret_decryption_ext(
|
test_shared_secret_decryption_ext(
|
||||||
bob,
|
bob,
|
||||||
@@ -183,10 +183,7 @@ async fn test_broadcast_security_happy_path() -> Result<()> {
|
|||||||
|
|
||||||
let secret = load_broadcast_secret(alice, alice_chat_id).await?.unwrap();
|
let secret = load_broadcast_secret(alice, alice_chat_id).await?.unwrap();
|
||||||
|
|
||||||
let alice_addr = alice
|
let alice_addr = alice.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
.get_config(crate::config::Config::Addr)
|
|
||||||
.await?
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
test_shared_secret_decryption_ext(bob, &alice_addr, &secret, Some(alice), None).await
|
test_shared_secret_decryption_ext(bob, &alice_addr, &secret, Some(alice), None).await
|
||||||
}
|
}
|
||||||
@@ -205,7 +202,7 @@ async fn test_qr_code_security() -> Result<()> {
|
|||||||
// Start a securejoin process, but don't finish it:
|
// Start a securejoin process, but don't finish it:
|
||||||
join_securejoin(bob, &qr).await?;
|
join_securejoin(bob, &qr).await?;
|
||||||
|
|
||||||
let charlie_addr = charlie.get_config(Config::Addr).await?.unwrap();
|
let charlie_addr = charlie.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
|
|
||||||
let alice_fp = self_fingerprint(alice).await?;
|
let alice_fp = self_fingerprint(alice).await?;
|
||||||
let secret_for_encryption = format!("securejoin/{alice_fp}/{authcode}");
|
let secret_for_encryption = format!("securejoin/{alice_fp}/{authcode}");
|
||||||
|
|||||||
@@ -3847,7 +3847,7 @@ async fn test_unsigned_chat_group_hdr() -> Result<()> {
|
|||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let bob = &tcm.bob().await;
|
let bob = &tcm.bob().await;
|
||||||
let bob_addr = bob.get_config(Config::Addr).await?.unwrap();
|
let bob_addr = bob.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
let bob_id = alice.add_or_lookup_contact_id(bob).await;
|
let bob_id = alice.add_or_lookup_contact_id(bob).await;
|
||||||
let alice_chat_id = create_group(alice, "foos").await?;
|
let alice_chat_id = create_group(alice, "foos").await?;
|
||||||
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
|
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
|
||||||
@@ -4535,7 +4535,7 @@ async fn test_outgoing_msg_forgery() -> Result<()> {
|
|||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let export_dir = tempfile::tempdir().unwrap();
|
let export_dir = tempfile::tempdir().unwrap();
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let alice_addr = &alice.get_config(Config::Addr).await?.unwrap();
|
let alice_addr = &alice.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
imex(alice, ImexMode::ExportSelfKeys, export_dir.path(), None).await?;
|
imex(alice, ImexMode::ExportSelfKeys, export_dir.path(), None).await?;
|
||||||
// We need Bob only to encrypt the forged message to Alice's key, actually Bob doesn't
|
// We need Bob only to encrypt the forged message to Alice's key, actually Bob doesn't
|
||||||
// participate in the scenario.
|
// participate in the scenario.
|
||||||
@@ -5632,7 +5632,7 @@ async fn test_bcc_not_a_group() -> Result<()> {
|
|||||||
async fn test_lookup_key_contact_by_address_self() -> Result<()> {
|
async fn test_lookup_key_contact_by_address_self() -> Result<()> {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let t = &tcm.alice().await;
|
let t = &tcm.alice().await;
|
||||||
let addr = &t.get_config(Config::Addr).await?.unwrap();
|
let addr = &t.get_config(Config::ConfiguredAddr).await?.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lookup_key_contact_by_address(t, addr, None).await?,
|
lookup_key_contact_by_address(t, addr, None).await?,
|
||||||
Some(ContactId::SELF)
|
Some(ContactId::SELF)
|
||||||
@@ -5685,7 +5685,7 @@ async fn test_outgoing_determined_by_signature() -> Result<()> {
|
|||||||
alice_dev2.configure_addr(different_from).await;
|
alice_dev2.configure_addr(different_from).await;
|
||||||
key::store_self_keypair(alice_dev2, &alice_keypair()).await?;
|
key::store_self_keypair(alice_dev2, &alice_keypair()).await?;
|
||||||
assert_ne!(
|
assert_ne!(
|
||||||
alice.get_config(Config::Addr).await?.unwrap(),
|
alice.get_config(Config::ConfiguredAddr).await?.unwrap(),
|
||||||
different_from
|
different_from
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ async fn test_setup_contact_ext(case: SetupContactCase) -> (TestContext, TestCon
|
|||||||
|
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = tcm.alice().await;
|
let alice = tcm.alice().await;
|
||||||
let alice_addr = &alice.get_config(Config::Addr).await.unwrap().unwrap();
|
let alice_addr = &alice
|
||||||
|
.get_config(Config::ConfiguredAddr)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
if case == SetupContactCase::AliceHasName {
|
if case == SetupContactCase::AliceHasName {
|
||||||
alice
|
alice
|
||||||
.set_config(Config::Displayname, Some("Alice"))
|
.set_config(Config::Displayname, Some("Alice"))
|
||||||
|
|||||||
Reference in New Issue
Block a user