diff --git a/crates/dump/src/reader/mod.rs b/crates/dump/src/reader/mod.rs index a34365905..85e5df432 100644 --- a/crates/dump/src/reader/mod.rs +++ b/crates/dump/src/reader/mod.rs @@ -449,7 +449,7 @@ pub(crate) mod test { let dump = DumpReader::open(dump).unwrap(); // top level infos - insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-30 14:06:57.240882 +00:00:00"); + insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-31 7:28:28.091553 +00:00:00"); insta::assert_debug_snapshot!(dump.instance_uid().unwrap(), @r" Some( cb887dcc-34b3-48d1-addd-9815ae721a81, @@ -462,6 +462,12 @@ pub(crate) mod test { insta::assert_json_snapshot!(webhooks, @r#" { "webhooks": { + "_cli": { + "url": "https://defined-in-dump.com/", + "headers": { + "Authorization": "Bearer defined in dump" + } + }, "exampleName": { "url": "https://example.com/hook", "headers": { diff --git a/crates/dump/tests/assets/v6-with-webhooks.dump b/crates/dump/tests/assets/v6-with-webhooks.dump index 89b1f61be..83989f25c 100644 Binary files a/crates/dump/tests/assets/v6-with-webhooks.dump and b/crates/dump/tests/assets/v6-with-webhooks.dump differ diff --git a/crates/meilisearch/tests/tasks/webhook.rs b/crates/meilisearch/tests/tasks/webhook.rs index c271446d8..12a8228fa 100644 --- a/crates/meilisearch/tests/tasks/webhook.rs +++ b/crates/meilisearch/tests/tasks/webhook.rs @@ -2,6 +2,7 @@ //! post requests. The webhook handle starts a server and forwards all the //! received requests into a channel for you to handle. +use std::path::PathBuf; use std::sync::Arc; use actix_http::body::MessageBody; @@ -68,7 +69,7 @@ async fn create_webhook_server() -> WebhookHandle { } #[actix_web::test] -async fn test_cli_webhook() { +async fn cli_only() { let WebhookHandle { server_handle, url, mut receiver } = create_webhook_server().await; let db_path = tempfile::tempdir().unwrap(); @@ -144,6 +145,49 @@ async fn test_cli_webhook() { server_handle.abort(); } + +#[actix_web::test] +async fn cli_with_dumps() { + let db_path = tempfile::tempdir().unwrap(); + let server = Server::new_with_options(Opt { + task_webhook_url: Some(Url::parse("http://defined-in-test-cli.com").unwrap()), + task_webhook_authorization_header: Some(String::from("Bearer a-secret-token-defined-in-test-cli")), + import_dump: Some(PathBuf::from("../dump/tests/assets/v6-with-webhooks.dump")), + ..default_settings(db_path.path()) + }) + .await + .unwrap(); + + let (webhooks, code) = server.get_webhooks().await; + snapshot!(code, @"200 OK"); + snapshot!(webhooks, @r#" + { + "webhooks": { + "_cli": { + "url": "http://defined-in-test-cli.com/", + "headers": { + "Authorization": "Bearer a-secret-token-defined-in-test-cli" + } + }, + "exampleName": { + "url": "https://example.com/hook", + "headers": { + "authorization": "TOKEN" + } + }, + "otherName": { + "url": "https://example.com/authorization-less", + "headers": {} + }, + "third": { + "url": "https://third.com", + "headers": {} + } + } + } + "#); +} + #[actix_web::test] async fn reserved_names() { let server = Server::new().await;