Automatic creation of JMAP identities
This commit is contained in:
@@ -394,7 +394,7 @@ async fn internal_directory() {
|
||||
PrincipalUpdate::set(PrincipalField::Quota, PrincipalValue::Integer(1024)),
|
||||
PrincipalUpdate::set(
|
||||
PrincipalField::Type,
|
||||
PrincipalValue::Type(Type::Superuser)
|
||||
PrincipalValue::String("superuser".to_string())
|
||||
),
|
||||
PrincipalUpdate::remove_item(
|
||||
PrincipalField::Emails,
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use directory::backend::internal::manage::ManageDirectory;
|
||||
use jmap_proto::types::{collection::Collection, id::Id};
|
||||
use jmap::mailbox::{INBOX_ID, TRASH_ID};
|
||||
use jmap_proto::types::{collection::Collection, id::Id, property::Property};
|
||||
|
||||
use tokio::{
|
||||
io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines, ReadHalf, WriteHalf},
|
||||
@@ -105,6 +106,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
"From: bill@example.com\r\n",
|
||||
"To: jdoe@example.com\r\n",
|
||||
"Subject: TPS Report\r\n",
|
||||
"X-Spam-Status: No\r\n",
|
||||
"\r\n",
|
||||
"I'm going to need those TPS reports ASAP. ",
|
||||
"So, if you could do that, that'd be great."
|
||||
@@ -112,20 +114,35 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
)
|
||||
.await;
|
||||
|
||||
let john_id = Id::from_bytes(account_id_1.as_bytes())
|
||||
.unwrap()
|
||||
.document_id();
|
||||
assert_eq!(
|
||||
server
|
||||
.get_document_ids(
|
||||
Id::from_bytes(account_id_1.as_bytes())
|
||||
.unwrap()
|
||||
.document_id(),
|
||||
Collection::Email
|
||||
)
|
||||
.get_document_ids(john_id, Collection::Email)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
server
|
||||
.get_tag(john_id, Collection::Email, Property::MailboxIds, INBOX_ID)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
server
|
||||
.get_tag(john_id, Collection::Email, Property::MailboxIds, TRASH_ID)
|
||||
.await
|
||||
.unwrap()
|
||||
.map_or(0, |bm| bm.len()),
|
||||
0
|
||||
);
|
||||
|
||||
// Delivering to individuals' aliases
|
||||
lmtp.ingest(
|
||||
@@ -135,6 +152,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
"From: bill@example.com\r\n",
|
||||
"To: john.doe@example.com\r\n",
|
||||
"Subject: Fwd: TPS Report\r\n",
|
||||
"X-Spam-Status: Yes, score=13.9\r\n",
|
||||
"\r\n",
|
||||
"--- Forwarded Message ---\r\n\r\n ",
|
||||
"I'm going to need those TPS reports ASAP. ",
|
||||
@@ -145,18 +163,31 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
|
||||
assert_eq!(
|
||||
server
|
||||
.get_document_ids(
|
||||
Id::from_bytes(account_id_1.as_bytes())
|
||||
.unwrap()
|
||||
.document_id(),
|
||||
Collection::Email
|
||||
)
|
||||
.get_document_ids(john_id, Collection::Email)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.len(),
|
||||
2
|
||||
);
|
||||
assert_eq!(
|
||||
server
|
||||
.get_tag(john_id, Collection::Email, Property::MailboxIds, INBOX_ID)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
server
|
||||
.get_tag(john_id, Collection::Email, Property::MailboxIds, TRASH_ID)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
|
||||
// EXPN and VRFY
|
||||
lmtp.expn("members@example.com", 2)
|
||||
|
||||
@@ -97,6 +97,10 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
.directory
|
||||
.create_test_user_with_email("jdoe@example.com", "12345", "John Doe")
|
||||
.await;
|
||||
params
|
||||
.directory
|
||||
.link_test_address("jdoe@example.com", "john.doe@example.com", "alias")
|
||||
.await;
|
||||
let account_id = Id::from(
|
||||
server
|
||||
.store
|
||||
@@ -106,6 +110,17 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
)
|
||||
.to_string();
|
||||
|
||||
// Test automatic identity creation
|
||||
for (identity_id, email) in [(0u64, "jdoe@example.com"), (1u64, "john.doe@example.com")] {
|
||||
let identity = client
|
||||
.identity_get(&Id::from(identity_id).to_string(), None)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(identity.email().unwrap(), email);
|
||||
assert_eq!(identity.name().unwrap(), format!("John Doe <{email}>"));
|
||||
}
|
||||
|
||||
// Create an identity without using a valid address should fail
|
||||
match client
|
||||
.set_default_account_id(&account_id)
|
||||
@@ -119,7 +134,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
|
||||
// Create an identity
|
||||
let identity_id = client
|
||||
.identity_create("John Doe", "jdoe@example.com")
|
||||
.identity_create("John Doe (manually created)", "jdoe@example.com")
|
||||
.await
|
||||
.unwrap()
|
||||
.take_id();
|
||||
@@ -473,7 +488,13 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
smtp_settings.lock().do_stop = true;
|
||||
|
||||
// Destroy the created mailbox, identity and all submissions
|
||||
client.identity_destroy(&identity_id).await.unwrap();
|
||||
for identity_id in [
|
||||
identity_id,
|
||||
Id::from(0u64).to_string(),
|
||||
Id::from(1u64).to_string(),
|
||||
] {
|
||||
client.identity_destroy(&identity_id).await.unwrap();
|
||||
}
|
||||
for id in client
|
||||
.email_submission_query(None::<Filter>, None::<Vec<_>>)
|
||||
.await
|
||||
|
||||
@@ -177,6 +177,9 @@ data = "{STORE}"
|
||||
fts = "{STORE}"
|
||||
blob = "{STORE}"
|
||||
|
||||
[jmap.spam]
|
||||
header = "X-Spam-Status: Yes"
|
||||
|
||||
[jmap.protocol.get]
|
||||
max-objects = 100000
|
||||
|
||||
@@ -295,18 +298,18 @@ pub async fn jmap_tests() {
|
||||
email_query_changes::test(&mut params).await;
|
||||
email_copy::test(&mut params).await;
|
||||
thread_get::test(&mut params).await;*/
|
||||
thread_merge::test(&mut params).await;
|
||||
/*mailbox::test(&mut params).await;
|
||||
delivery::test(&mut params).await;
|
||||
auth_acl::test(&mut params).await;
|
||||
//thread_merge::test(&mut params).await;
|
||||
//mailbox::test(&mut params).await;
|
||||
//delivery::test(&mut params).await;
|
||||
/*auth_acl::test(&mut params).await;
|
||||
auth_limits::test(&mut params).await;
|
||||
auth_oauth::test(&mut params).await;
|
||||
event_source::test(&mut params).await;
|
||||
push_subscription::test(&mut params).await;
|
||||
sieve_script::test(&mut params).await;
|
||||
vacation_response::test(&mut params).await;
|
||||
vacation_response::test(&mut params).await;*/
|
||||
email_submission::test(&mut params).await;
|
||||
websocket::test(&mut params).await;
|
||||
/*websocket::test(&mut params).await;
|
||||
quota::test(&mut params).await;
|
||||
crypto::test(&mut params).await;
|
||||
blob::test(&mut params).await;*/
|
||||
|
||||
Reference in New Issue
Block a user