mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
fix the auth tests
This commit is contained in:
parent
dc533584c6
commit
7ae10abb6b
@ -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,15 +210,28 @@ async fn access_authorized_restricted_index() {
|
|||||||
|
|
||||||
let (response, code) = server.dummy_request(method, route).await;
|
let (response, code) = server.dummy_request(method, route).await;
|
||||||
|
|
||||||
assert_ne!(
|
// The metrics route MUST have no limitation on the indexes
|
||||||
response,
|
if *route == "/metrics" {
|
||||||
INVALID_RESPONSE.clone(),
|
assert_eq!(
|
||||||
"on route: {:?} - {:?} with action: {:?}",
|
response,
|
||||||
method,
|
INVALID_METRICS_RESPONSE.clone(),
|
||||||
route,
|
"on route: {:?} - {:?} with action: {:?}",
|
||||||
action
|
method,
|
||||||
);
|
route,
|
||||||
assert_ne!(code, 403);
|
action
|
||||||
|
);
|
||||||
|
assert_eq!(code, 403);
|
||||||
|
} else {
|
||||||
|
assert_ne!(
|
||||||
|
response,
|
||||||
|
INVALID_RESPONSE.clone(),
|
||||||
|
"on route: {:?} - {:?} with action: {:?}",
|
||||||
|
method,
|
||||||
|
route,
|
||||||
|
action
|
||||||
|
);
|
||||||
|
assert_ne!(code, 403);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user