From f839c8e61d410174522dbf1c72e482051e38e85e Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 7 Feb 2024 12:13:57 +0100 Subject: [PATCH] move the /logs route to the /logs/stream route --- meilisearch/src/routes/logs.rs | 2 +- meilisearch/tests/auth/authorization.rs | 4 ++-- meilisearch/tests/logs/error.rs | 24 ++++++++++++------------ meilisearch/tests/logs/mod.rs | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/meilisearch/src/routes/logs.rs b/meilisearch/src/routes/logs.rs index 48bf181be..7ce7d7ea1 100644 --- a/meilisearch/src/routes/logs.rs +++ b/meilisearch/src/routes/logs.rs @@ -26,7 +26,7 @@ use crate::LogRouteHandle; pub fn configure(cfg: &mut web::ServiceConfig) { cfg.service( - web::resource("") + web::resource("stream") .route(web::post().to(SeqHandler(get_logs))) .route(web::delete().to(SeqHandler(cancel_logs))), ); diff --git a/meilisearch/tests/auth/authorization.rs b/meilisearch/tests/auth/authorization.rs index 88635e62f..d26bb26b8 100644 --- a/meilisearch/tests/auth/authorization.rs +++ b/meilisearch/tests/auth/authorization.rs @@ -59,8 +59,8 @@ pub static AUTHORIZATIONS: Lazy hashset!{"snapshots.create", "snapshots.*", "*"}, ("GET", "/version") => hashset!{"version", "*"}, ("GET", "/metrics") => hashset!{"metrics.get", "metrics.*", "*"}, - ("POST", "/logs") => hashset!{"metrics.get", "metrics.*", "*"}, - ("DELETE", "/logs") => hashset!{"metrics.get", "metrics.*", "*"}, + ("POST", "/logs/stream") => hashset!{"metrics.get", "metrics.*", "*"}, + ("DELETE", "/logs/stream") => hashset!{"metrics.get", "metrics.*", "*"}, ("PATCH", "/keys/mykey/") => hashset!{"keys.update", "*"}, ("GET", "/keys/mykey/") => hashset!{"keys.get", "*"}, ("DELETE", "/keys/mykey/") => hashset!{"keys.delete", "*"}, diff --git a/meilisearch/tests/logs/error.rs b/meilisearch/tests/logs/error.rs index b6c4605ed..c1755c299 100644 --- a/meilisearch/tests/logs/error.rs +++ b/meilisearch/tests/logs/error.rs @@ -4,11 +4,11 @@ use crate::common::Server; use crate::json; #[actix_rt::test] -async fn logs_bad_target() { +async fn logs_stream_bad_target() { let server = Server::new().await; // Wrong type - let (response, code) = server.service.post("/logs", json!({ "target": true })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "target": true })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -20,7 +20,7 @@ async fn logs_bad_target() { "###); // Wrong type - let (response, code) = server.service.post("/logs", json!({ "target": [] })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "target": [] })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -32,7 +32,7 @@ async fn logs_bad_target() { "###); // Our help message - let (response, code) = server.service.post("/logs", json!({ "target": "" })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "target": "" })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -44,7 +44,7 @@ async fn logs_bad_target() { "###); // An error from the target parser - let (response, code) = server.service.post("/logs", json!({ "target": "==" })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "target": "==" })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -57,11 +57,11 @@ async fn logs_bad_target() { } #[actix_rt::test] -async fn logs_bad_mode() { +async fn logs_stream_bad_mode() { let server = Server::new().await; // Wrong type - let (response, code) = server.service.post("/logs", json!({ "mode": true })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "mode": true })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -73,7 +73,7 @@ async fn logs_bad_mode() { "###); // Wrong type - let (response, code) = server.service.post("/logs", json!({ "mode": [] })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "mode": [] })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -85,7 +85,7 @@ async fn logs_bad_mode() { "###); // Wrong value - let (response, code) = server.service.post("/logs", json!({ "mode": "tamo" })).await; + let (response, code) = server.service.post("/logs/stream", json!({ "mode": "tamo" })).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -98,10 +98,10 @@ async fn logs_bad_mode() { } #[actix_rt::test] -async fn logs_without_enabling_the_route() { +async fn logs_stream_without_enabling_the_route() { let server = Server::new().await; - let (response, code) = server.service.post("/logs", json!({})).await; + let (response, code) = server.service.post("/logs/stream", json!({})).await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { @@ -112,7 +112,7 @@ async fn logs_without_enabling_the_route() { } "###); - let (response, code) = server.service.delete("/logs").await; + let (response, code) = server.service.delete("/logs/stream").await; snapshot!(code, @"400 Bad Request"); snapshot!(response, @r###" { diff --git a/meilisearch/tests/logs/mod.rs b/meilisearch/tests/logs/mod.rs index ad1fa4048..f9331166d 100644 --- a/meilisearch/tests/logs/mod.rs +++ b/meilisearch/tests/logs/mod.rs @@ -14,7 +14,7 @@ use crate::common::{default_settings, Server}; use crate::json; #[actix_web::test] -async fn basic_test_log_route() { +async fn basic_test_log_stream_route() { let db_path = tempfile::tempdir().unwrap(); let server = Server::new_with_options(Opt { experimental_enable_logs_route: true, @@ -50,11 +50,11 @@ async fn basic_test_log_route() { let app = Rc::new(app); - // First, we start listening on the `/logs` route + // First, we start listening on the `/logs/stream` route let handle_app = app.clone(); let handle = tokio::task::spawn_local(async move { let req = actix_web::test::TestRequest::post() - .uri("/logs") + .uri("/logs/stream") .insert_header(ContentType::json()) .set_payload( serde_json::to_vec(&json!({ @@ -81,7 +81,7 @@ async fn basic_test_log_route() { "###); server.wait_task(ret.uid()).await; - let req = actix_web::test::TestRequest::delete().uri("/logs"); + let req = actix_web::test::TestRequest::delete().uri("/logs/stream"); let req = req.to_request(); let ret = actix_web::test::call_service(&*app, req).await; let code = ret.status();