Improved tracing (part 4)
This commit is contained in:
@@ -31,7 +31,6 @@ use common::{
|
||||
server::{ServerProtocol, Servers},
|
||||
tracers::Tracer,
|
||||
},
|
||||
webhooks::manager::spawn_webhook_manager,
|
||||
Core, Ipc, IPC_CHANNEL_BUFFER,
|
||||
};
|
||||
|
||||
@@ -309,15 +308,9 @@ async fn init_imap_tests(store_id: &str, delete_if_exists: bool) -> IMAPTest {
|
||||
// Parse acceptors
|
||||
servers.parse_tcp_acceptors(&mut config, shared_core.clone());
|
||||
|
||||
// Spawn webhook manager
|
||||
let webhook_tx = spawn_webhook_manager(shared_core.clone());
|
||||
|
||||
// Setup IPC channels
|
||||
let (delivery_tx, delivery_rx) = mpsc::channel(IPC_CHANNEL_BUFFER);
|
||||
let ipc = Ipc {
|
||||
delivery_tx,
|
||||
webhook_tx,
|
||||
};
|
||||
let ipc = Ipc { delivery_tx };
|
||||
|
||||
// Init servers
|
||||
let smtp = SMTP::init(&mut config, shared_core.clone(), ipc).await;
|
||||
|
||||
@@ -154,7 +154,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
);
|
||||
assert_forbidden(
|
||||
john_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.email_get(
|
||||
email_ids.get("sales").unwrap().first().unwrap(),
|
||||
[Property::Subject].into(),
|
||||
@@ -163,7 +163,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
);
|
||||
assert_forbidden(
|
||||
john_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.mailbox_get(&inbox_id, None::<Vec<_>>)
|
||||
.await,
|
||||
);
|
||||
@@ -238,7 +238,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
.unwrap()
|
||||
.take_blob_id();
|
||||
john_client
|
||||
.set_default_account_id(&john_id.to_string())
|
||||
.set_default_account_id(john_id.to_string())
|
||||
.blob_copy(jane_id.to_string(), &blob_id)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -253,7 +253,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
.take_blob_id();
|
||||
assert_forbidden(
|
||||
john_client
|
||||
.set_default_account_id(&john_id.to_string())
|
||||
.set_default_account_id(john_id.to_string())
|
||||
.blob_copy(jane_id.to_string(), &blob_id)
|
||||
.await,
|
||||
);
|
||||
@@ -284,7 +284,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
|
||||
// Try to add items using import and copy
|
||||
let blob_id = john_client
|
||||
.set_default_account_id(&john_id.to_string())
|
||||
.set_default_account_id(john_id.to_string())
|
||||
.upload(
|
||||
Some(&john_id.to_string()),
|
||||
concat!(
|
||||
@@ -703,7 +703,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
|
||||
// Insert a message in Sales's inbox
|
||||
let blob_id = john_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.upload(
|
||||
Some(&sales_id.to_string()),
|
||||
concat!(
|
||||
@@ -737,7 +737,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
// Both Jane and John should be able to see this message, but not Bill
|
||||
assert_eq!(
|
||||
john_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.email_get(&email_id, [Property::Subject].into(),)
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -748,7 +748,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
);
|
||||
assert_eq!(
|
||||
jane_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.email_get(&email_id, [Property::Subject].into(),)
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -759,7 +759,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
);
|
||||
assert_forbidden(
|
||||
bill_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.email_get(&email_id, [Property::Subject].into())
|
||||
.await,
|
||||
);
|
||||
@@ -772,14 +772,14 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
server.inner.sessions.clear();
|
||||
assert_forbidden(
|
||||
john_client
|
||||
.set_default_account_id(&sales_id.to_string())
|
||||
.set_default_account_id(sales_id.to_string())
|
||||
.email_get(&email_id, [Property::Subject].into())
|
||||
.await,
|
||||
);
|
||||
|
||||
// Destroy test account data
|
||||
for id in [john_id, bill_id, jane_id, sales_id] {
|
||||
params.client.set_default_account_id(&id.to_string());
|
||||
params.client.set_default_account_id(id.to_string());
|
||||
destroy_all_mailboxes(params).await;
|
||||
}
|
||||
assert_is_empty(server).await;
|
||||
|
||||
@@ -112,9 +112,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
assert_state(&mut event_rx, &account_id, &[TypeState::Mailbox]).await;
|
||||
|
||||
// Destroy Inbox
|
||||
params
|
||||
.client
|
||||
.set_default_account_id(&account_id.to_string());
|
||||
params.client.set_default_account_id(account_id.to_string());
|
||||
params
|
||||
.client
|
||||
.mailbox_destroy(&Id::from(INBOX_ID).to_string(), true)
|
||||
|
||||
@@ -16,7 +16,6 @@ use common::{
|
||||
tracers::Tracer,
|
||||
},
|
||||
manager::config::{ConfigManager, Patterns},
|
||||
webhooks::manager::spawn_webhook_manager,
|
||||
Core, Ipc, IPC_CHANNEL_BUFFER,
|
||||
};
|
||||
use hyper::{header::AUTHORIZATION, Method};
|
||||
@@ -477,15 +476,9 @@ async fn init_jmap_tests(store_id: &str, delete_if_exists: bool) -> JMAPTest {
|
||||
// Parse acceptors
|
||||
servers.parse_tcp_acceptors(&mut config, shared_core.clone());
|
||||
|
||||
// Spawn webhook manager
|
||||
let webhook_tx = spawn_webhook_manager(shared_core.clone());
|
||||
|
||||
// Setup IPC channels
|
||||
let (delivery_tx, delivery_rx) = mpsc::channel(IPC_CHANNEL_BUFFER);
|
||||
let ipc = Ipc {
|
||||
delivery_tx,
|
||||
webhook_tx,
|
||||
};
|
||||
let ipc = Ipc { delivery_tx };
|
||||
|
||||
// Init servers
|
||||
let smtp = SMTP::init(&mut config, shared_core.clone(), ipc).await;
|
||||
|
||||
@@ -13,10 +13,7 @@ use std::{
|
||||
};
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use common::{
|
||||
manager::webadmin::Resource,
|
||||
webhooks::{WebhookEvent, WebhookEvents},
|
||||
};
|
||||
use common::manager::webadmin::Resource;
|
||||
use hyper::{body, server::conn::http1, service::service_fn};
|
||||
use hyper_util::rt::TokioIo;
|
||||
use jmap::api::http::{fetch_body, ToHttpResponse};
|
||||
@@ -29,7 +26,7 @@ use super::JMAPTest;
|
||||
|
||||
pub struct MockWebhookEndpoint {
|
||||
pub tx: watch::Sender<bool>,
|
||||
pub events: Mutex<Vec<WebhookEvent>>,
|
||||
pub events: Mutex<Vec<serde_json::Value>>,
|
||||
pub reject: AtomicBool,
|
||||
}
|
||||
|
||||
@@ -120,7 +117,11 @@ pub fn spawn_mock_webhook_endpoint() -> Arc<MockWebhookEndpoint> {
|
||||
hmac::verify(&key, &body, &tag).expect("Invalid signature");
|
||||
|
||||
// Deserialize JSON
|
||||
let request = serde_json::from_slice::<WebhookEvents>(&body)
|
||||
#[derive(serde::Deserialize)]
|
||||
struct WebhookRequest {
|
||||
events: Vec<serde_json::Value>,
|
||||
}
|
||||
let request = serde_json::from_slice::<WebhookRequest>(&body)
|
||||
.expect("Failed to parse JSON");
|
||||
|
||||
if !endpoint.reject.load(Ordering::Relaxed) {
|
||||
|
||||
@@ -262,7 +262,7 @@ fn parse_throttles() {
|
||||
throttle,
|
||||
vec![
|
||||
Throttle {
|
||||
id: "0".to_string(),
|
||||
id: "0000".to_string(),
|
||||
expr: Expression {
|
||||
items: vec![
|
||||
ExpressionItem::Variable(8),
|
||||
@@ -279,7 +279,7 @@ fn parse_throttles() {
|
||||
.into()
|
||||
},
|
||||
Throttle {
|
||||
id: "1".to_string(),
|
||||
id: "0001".to_string(),
|
||||
expr: Expression::default(),
|
||||
keys: THROTTLE_SENDER_DOMAIN,
|
||||
concurrency: 10000.into(),
|
||||
|
||||
@@ -130,7 +130,7 @@ pub async fn test(db: Store) {
|
||||
batch.ops.push(Operation::Bitmap {
|
||||
class: BitmapClass::Text {
|
||||
field,
|
||||
token: BitmapHash::new(&random_bytes(field as usize + 2)),
|
||||
token: BitmapHash::new(random_bytes(field as usize + 2)),
|
||||
},
|
||||
set: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user