fix the auth tests

This commit is contained in:
Tamo 2023-02-23 17:27:42 +01:00
parent dc533584c6
commit 7ae10abb6b

View File

@ -75,6 +75,14 @@ static INVALID_RESPONSE: Lazy<Value> = Lazy::new(|| {
}) })
}); });
static INVALID_METRICS_RESPONSE: Lazy<Value> = 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"; const MASTER_KEY: &str = "MASTER_KEY";
#[actix_rt::test] #[actix_rt::test]
@ -202,6 +210,18 @@ async fn access_authorized_restricted_index() {
let (response, code) = server.dummy_request(method, route).await; let (response, code) = server.dummy_request(method, route).await;
// 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!( assert_ne!(
response, response,
INVALID_RESPONSE.clone(), INVALID_RESPONSE.clone(),
@ -213,6 +233,7 @@ async fn access_authorized_restricted_index() {
assert_ne!(code, 403); assert_ne!(code, 403);
} }
} }
}
} }
#[actix_rt::test] #[actix_rt::test]