diff --git a/meilisearch/tests/auth/authorization.rs b/meilisearch/tests/auth/authorization.rs index e92f41bcf..d226f019a 100644 --- a/meilisearch/tests/auth/authorization.rs +++ b/meilisearch/tests/auth/authorization.rs @@ -75,6 +75,14 @@ static INVALID_RESPONSE: Lazy = Lazy::new(|| { }) }); +static INVALID_METRICS_RESPONSE: Lazy = Lazy::new(|| { + json!({"message": "The provided API key is invalid. The API key for the `/metrics` route must have no limitation on the indexes.", + "code": "invalid_api_key", + "type": "auth", + "link": "https://docs.meilisearch.com/errors#invalid_api_key" + }) +}); + const MASTER_KEY: &str = "MASTER_KEY"; #[actix_rt::test] @@ -202,15 +210,28 @@ async fn access_authorized_restricted_index() { let (response, code) = server.dummy_request(method, route).await; - assert_ne!( - response, - INVALID_RESPONSE.clone(), - "on route: {:?} - {:?} with action: {:?}", - method, - route, - action - ); - assert_ne!(code, 403); + // The metrics route MUST have no limitation on the indexes + if *route == "/metrics" { + assert_eq!( + response, + INVALID_METRICS_RESPONSE.clone(), + "on route: {:?} - {:?} with action: {:?}", + method, + route, + action + ); + assert_eq!(code, 403); + } else { + assert_ne!( + response, + INVALID_RESPONSE.clone(), + "on route: {:?} - {:?} with action: {:?}", + method, + route, + action + ); + assert_ne!(code, 403); + } } } }