Import upstream v0.16.24, stripped
Upstream commit: af37a234981722493b74623a983581691d2b70b6 Enterprise-only files removed or emptied: 63 Enterprise-only snippets removed: 118 in 50 files Dangling module declarations removed: 5 Edits turning enterprise off: 25 Third-party code: 14 files, 0 not in THIRD-PARTY.md Renamed identifiers: 62 in 18 files Verification: clean The same Enterprise footprint as v0.16.23. The build check fails only on tests/src/directory/issuer.rs, unchanged since v0.16.23: it calls a helper from upstream's Enterprise-only OIDC test, and tests issuer-based directory routing, an Enterprise feature. main has never carried it.
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::{
|
||||
jmap::{find_values, replace_blob_ids, replace_boundaries, replace_values},
|
||||
utils::server::TestServer,
|
||||
};
|
||||
use ::email::mailbox::INBOX_ID;
|
||||
use ::email::{mailbox::INBOX_ID, message::metadata::MessageData};
|
||||
use ahash::AHashSet;
|
||||
use jmap_client::{
|
||||
Error, Set,
|
||||
@@ -18,8 +18,12 @@ use jmap_client::{
|
||||
mailbox::Role,
|
||||
};
|
||||
use registry::schema::prelude::ObjectType;
|
||||
use std::{fs, path::PathBuf};
|
||||
use types::id::Id;
|
||||
use std::{fs, path::PathBuf, str::FromStr};
|
||||
use store::{
|
||||
ValueKey,
|
||||
write::{AlignedBytes, Archive},
|
||||
};
|
||||
use types::{collection::Collection, id::Id};
|
||||
|
||||
pub async fn test(test: &TestServer) {
|
||||
println!("Running Email Set tests...");
|
||||
@@ -29,6 +33,7 @@ pub async fn test(test: &TestServer) {
|
||||
|
||||
create(&client, &mailbox_id).await;
|
||||
update(&client, &mailbox_id).await;
|
||||
update_preserves_uids(test, &client, account.id().document_id(), &mailbox_id).await;
|
||||
|
||||
test.destroy_all_mailboxes(account).await;
|
||||
test.account("[email protected]")
|
||||
@@ -296,6 +301,94 @@ async fn update(client: &Client, root_mailbox_id: &str) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
async fn update_preserves_uids(
|
||||
test: &TestServer,
|
||||
client: &Client,
|
||||
account_id: u32,
|
||||
root_mailbox_id: &str,
|
||||
) {
|
||||
let email_id = client
|
||||
.email_query(
|
||||
email::query::Filter::in_mailbox(root_mailbox_id).into(),
|
||||
None::<Vec<_>>,
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.take_ids()
|
||||
.pop()
|
||||
.unwrap();
|
||||
let document_id = Id::from_str(&email_id).unwrap().document_id();
|
||||
let test_mailbox_id = client
|
||||
.mailbox_create("UID Test", None::<String>, Role::None)
|
||||
.await
|
||||
.unwrap()
|
||||
.take_id();
|
||||
let test_mailbox_document_id = Id::from_str(&test_mailbox_id).unwrap().document_id();
|
||||
let uids = message_uids(test, account_id, document_id).await;
|
||||
let inbox_uid = uids[&INBOX_ID];
|
||||
assert_ne!(inbox_uid, 0);
|
||||
|
||||
// Full mailboxIds identical to the current ones plus a keyword change must keep the UID
|
||||
let mut request = client.build();
|
||||
request
|
||||
.set_email()
|
||||
.update(&email_id)
|
||||
.mailbox_ids([root_mailbox_id])
|
||||
.keywords(["uid-test"]);
|
||||
request
|
||||
.send_set_email()
|
||||
.await
|
||||
.unwrap()
|
||||
.updated(&email_id)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
message_uids(test, account_id, document_id).await,
|
||||
[(INBOX_ID, inbox_uid)].into_iter().collect()
|
||||
);
|
||||
|
||||
// Full mailboxIds that keeps a mailbox and adds another must only assign a UID to the new one
|
||||
let mut request = client.build();
|
||||
request
|
||||
.set_email()
|
||||
.update(&email_id)
|
||||
.mailbox_ids([root_mailbox_id, test_mailbox_id.as_str()]);
|
||||
request
|
||||
.send_set_email()
|
||||
.await
|
||||
.unwrap()
|
||||
.updated(&email_id)
|
||||
.unwrap();
|
||||
let uids = message_uids(test, account_id, document_id).await;
|
||||
assert_eq!(uids.len(), 2);
|
||||
assert_eq!(uids[&INBOX_ID], inbox_uid);
|
||||
assert_ne!(uids[&test_mailbox_document_id], 0);
|
||||
|
||||
client.mailbox_destroy(&test_mailbox_id, true).await.unwrap();
|
||||
}
|
||||
|
||||
async fn message_uids(
|
||||
test: &TestServer,
|
||||
account_id: u32,
|
||||
document_id: u32,
|
||||
) -> std::collections::BTreeMap<u32, u32> {
|
||||
test.server
|
||||
.store()
|
||||
.get_value::<Archive<AlignedBytes>>(ValueKey::archive(
|
||||
account_id,
|
||||
Collection::Email,
|
||||
document_id,
|
||||
))
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.deserialize::<MessageData>()
|
||||
.unwrap()
|
||||
.mailboxes
|
||||
.iter()
|
||||
.map(|m| (m.mailbox_id, m.uid))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub async fn assert_email_properties(
|
||||
client: &Client,
|
||||
message_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user