diff --git a/crates/integration-tests/source.lua b/crates/integration-tests/source.lua index b7e51ee8..ae3fb1f7 100644 --- a/crates/integration-tests/source.lua +++ b/crates/integration-tests/source.lua @@ -26,6 +26,7 @@ kumo.on('init', function() if WEBHOOK_PORT then kumo.configure_log_hook { name = 'webhook', + headers = { 'Subject', 'X-*' }, } end diff --git a/crates/integration-tests/src/main.rs b/crates/integration-tests/src/main.rs index 540abac6..b3391e97 100644 --- a/crates/integration-tests/src/main.rs +++ b/crates/integration-tests/src/main.rs @@ -13,9 +13,11 @@ mod test { use anyhow::Context; use k9::assert_equal; use kumo_api_types::SuspendV1Response; + use kumo_log_types::RecordType; use kumo_log_types::RecordType::{Bounce, Delivery, Reception, TransientFailure}; use mailparsing::DecodedBody; use rfc5321::*; + use std::collections::BTreeMap; use std::time::Duration; #[tokio::test] @@ -823,6 +825,27 @@ Ok( " ); + let mut logged_headers = vec![]; + for record in daemon.webhook.return_logs() { + if record.kind == RecordType::Reception { + let ordered_headers: BTreeMap<_, _> = record.headers.into_iter().collect(); + logged_headers.push(ordered_headers); + } + } + k9::snapshot!( + logged_headers, + r#" +[ + { + "Subject": String("Hello! This is a test"), + "x-another": String("Another"), + "x-kumoref": String("eyJfQF8iOiJcXF8vIiwicmVjaXBpZW50IjoicmVjaXBAZXhhbXBsZS5jb20ifQ=="), + "x-test1": String("Test1"), + }, +] +"# + ); + let mut messages = daemon.with_maildir.extract_maildir_messages()?; assert_equal!(messages.len(), 1); diff --git a/crates/integration-tests/src/webhook.rs b/crates/integration-tests/src/webhook.rs index d44da973..aca53a2b 100644 --- a/crates/integration-tests/src/webhook.rs +++ b/crates/integration-tests/src/webhook.rs @@ -71,6 +71,10 @@ impl WebHookServer { } Ok(counts) } + + pub fn return_logs(&self) -> Vec { + (*self.records.lock().unwrap()).clone() + } } async fn log_record( diff --git a/crates/kumo-log-types/src/lib.rs b/crates/kumo-log-types/src/lib.rs index bb749780..22673b03 100644 --- a/crates/kumo-log-types/src/lib.rs +++ b/crates/kumo-log-types/src/lib.rs @@ -39,7 +39,7 @@ pub enum RecordType { Any, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct JsonLogRecord { /// What kind of record this is #[serde(rename = "type")]