mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
Apply review suggestions
This commit is contained in:
parent
c91ffec72e
commit
b0b7ad7caf
45
Cargo.lock
generated
45
Cargo.lock
generated
@ -1022,36 +1022,17 @@ dependencies = [
|
|||||||
"syn 1.0.107",
|
"syn 1.0.107",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deserr"
|
|
||||||
version = "0.1.2"
|
|
||||||
dependencies = [
|
|
||||||
"deserr-internal 0.1.2",
|
|
||||||
"serde-cs",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deserr"
|
name = "deserr"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86290491a2b5c21a1a5083da8dae831006761258fabd5617309c3eebc5f89468"
|
checksum = "86290491a2b5c21a1a5083da8dae831006761258fabd5617309c3eebc5f89468"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deserr-internal 0.1.4",
|
"deserr-internal",
|
||||||
"serde-cs",
|
"serde-cs",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deserr-internal"
|
|
||||||
version = "0.1.2"
|
|
||||||
dependencies = [
|
|
||||||
"convert_case 0.5.0",
|
|
||||||
"proc-macro2 1.0.49",
|
|
||||||
"quote 1.0.23",
|
|
||||||
"syn 1.0.107",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deserr-internal"
|
name = "deserr-internal"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -2326,7 +2307,7 @@ dependencies = [
|
|||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
"clap 4.0.32",
|
"clap 4.0.32",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"deserr 0.1.2",
|
"deserr",
|
||||||
"dump",
|
"dump",
|
||||||
"either",
|
"either",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
@ -2418,7 +2399,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"convert_case 0.6.0",
|
"convert_case 0.6.0",
|
||||||
"csv",
|
"csv",
|
||||||
"deserr 0.1.2",
|
"deserr",
|
||||||
"either",
|
"either",
|
||||||
"enum-iterator",
|
"enum-iterator",
|
||||||
"file-store",
|
"file-store",
|
||||||
@ -2478,7 +2459,7 @@ dependencies = [
|
|||||||
"concat-arrays",
|
"concat-arrays",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"csv",
|
"csv",
|
||||||
"deserr 0.1.4",
|
"deserr",
|
||||||
"either",
|
"either",
|
||||||
"filter-parser",
|
"filter-parser",
|
||||||
"flatten-serde-json",
|
"flatten-serde-json",
|
||||||
@ -2793,9 +2774,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest"
|
name = "pest"
|
||||||
version = "2.5.2"
|
version = "2.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f6e86fb9e7026527a0d46bc308b841d73170ef8f443e1807f6ef88526a816d4"
|
checksum = "4257b4a04d91f7e9e6290be5d3da4804dd5784fafde3a497d73eb2b4a158c30a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"ucd-trie",
|
"ucd-trie",
|
||||||
@ -2803,9 +2784,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_derive"
|
name = "pest_derive"
|
||||||
version = "2.5.2"
|
version = "2.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96504449aa860c8dcde14f9fba5c58dc6658688ca1fe363589d6327b8662c603"
|
checksum = "241cda393b0cdd65e62e07e12454f1f25d57017dcc514b1514cd3c4645e3a0a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pest",
|
"pest",
|
||||||
"pest_generator",
|
"pest_generator",
|
||||||
@ -2813,9 +2794,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_generator"
|
name = "pest_generator"
|
||||||
version = "2.5.2"
|
version = "2.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "798e0220d1111ae63d66cb66a5dcb3fc2d986d520b98e49e1852bfdb11d7c5e7"
|
checksum = "46b53634d8c8196302953c74d5352f33d0c512a9499bd2ce468fc9f4128fa27c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pest",
|
"pest",
|
||||||
"pest_meta",
|
"pest_meta",
|
||||||
@ -2826,13 +2807,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pest_meta"
|
name = "pest_meta"
|
||||||
version = "2.5.2"
|
version = "2.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "984298b75898e30a843e278a9f2452c31e349a073a0ce6fd950a12a74464e065"
|
checksum = "0ef4f1332a8d4678b41966bb4cc1d0676880e84183a1ecc3f4b69f03e99c7a51"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"pest",
|
"pest",
|
||||||
"sha1",
|
"sha2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -33,8 +33,7 @@ impl AuthController {
|
|||||||
Ok(Self { store: Arc::new(store), master_key: master_key.clone() })
|
Ok(Self { store: Arc::new(store), master_key: master_key.clone() })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_key(&self, value: CreateApiKey) -> Result<Key> {
|
pub fn create_key(&self, create_key: CreateApiKey) -> Result<Key> {
|
||||||
let create_key = value;
|
|
||||||
match self.store.get_api_key(create_key.uid)? {
|
match self.store.get_api_key(create_key.uid)? {
|
||||||
Some(_) => Err(AuthControllerError::ApiKeyAlreadyExists(create_key.uid.to_string())),
|
Some(_) => Err(AuthControllerError::ApiKeyAlreadyExists(create_key.uid.to_string())),
|
||||||
None => self.store.put_api_key(create_key.to_key()),
|
None => self.store.put_api_key(create_key.to_key()),
|
||||||
|
@ -9,7 +9,7 @@ actix-web = { version = "4.2.1", default-features = false }
|
|||||||
anyhow = "1.0.65"
|
anyhow = "1.0.65"
|
||||||
convert_case = "0.6.0"
|
convert_case = "0.6.0"
|
||||||
csv = "1.1.6"
|
csv = "1.1.6"
|
||||||
deserr = { path = "/Users/meilisearch/Documents/deserr", features = ["serde-json"] }
|
deserr = { version = "0.1.4", features = ["serde-json"] }
|
||||||
either = { version = "1.6.1", features = ["serde"] }
|
either = { version = "1.6.1", features = ["serde"] }
|
||||||
enum-iterator = "1.1.3"
|
enum-iterator = "1.1.3"
|
||||||
file-store = { path = "../file-store" }
|
file-store = { path = "../file-store" }
|
||||||
|
@ -118,7 +118,6 @@ impl fmt::Display for ErrorType {
|
|||||||
|
|
||||||
macro_rules! make_error_codes {
|
macro_rules! make_error_codes {
|
||||||
($($code_ident:ident, $err_type:ident, $status:ident);*) => {
|
($($code_ident:ident, $err_type:ident, $status:ident);*) => {
|
||||||
#[repr(u32)]
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Code {
|
pub enum Code {
|
||||||
$($code_ident),*
|
$($code_ident),*
|
||||||
@ -210,7 +209,6 @@ InvalidIndexOffset , invalid , BAD_REQUEST ;
|
|||||||
InvalidIndexPrimaryKey , invalid , BAD_REQUEST ;
|
InvalidIndexPrimaryKey , invalid , BAD_REQUEST ;
|
||||||
InvalidIndexUid , invalid , BAD_REQUEST ;
|
InvalidIndexUid , invalid , BAD_REQUEST ;
|
||||||
InvalidMinWordLengthForTypo , invalid , BAD_REQUEST ;
|
InvalidMinWordLengthForTypo , invalid , BAD_REQUEST ;
|
||||||
InvalidRankingRule , invalid , BAD_REQUEST ;
|
|
||||||
InvalidSearchAttributesToCrop , invalid , BAD_REQUEST ;
|
InvalidSearchAttributesToCrop , invalid , BAD_REQUEST ;
|
||||||
InvalidSearchAttributesToHighlight , invalid , BAD_REQUEST ;
|
InvalidSearchAttributesToHighlight , invalid , BAD_REQUEST ;
|
||||||
InvalidSearchAttributesToRetrieve , invalid , BAD_REQUEST ;
|
InvalidSearchAttributesToRetrieve , invalid , BAD_REQUEST ;
|
||||||
@ -340,7 +338,7 @@ impl ErrorCode for milli::Error {
|
|||||||
UserError::SortRankingRuleMissing => Code::InvalidSearchSort,
|
UserError::SortRankingRuleMissing => Code::InvalidSearchSort,
|
||||||
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
UserError::InvalidFacetsDistribution { .. } => Code::BadRequest,
|
||||||
UserError::InvalidSortableAttribute { .. } => Code::InvalidSearchSort,
|
UserError::InvalidSortableAttribute { .. } => Code::InvalidSearchSort,
|
||||||
UserError::CriterionError(_) => Code::InvalidRankingRule,
|
UserError::CriterionError(_) => Code::InvalidSettingsRankingRules,
|
||||||
UserError::InvalidGeoField { .. } => Code::InvalidDocumentGeoField,
|
UserError::InvalidGeoField { .. } => Code::InvalidDocumentGeoField,
|
||||||
UserError::SortError(_) => Code::InvalidSearchSort,
|
UserError::SortError(_) => Code::InvalidSearchSort,
|
||||||
UserError::InvalidMinTypoWordLenSetting(_, _) => {
|
UserError::InvalidMinTypoWordLenSetting(_, _) => {
|
||||||
|
@ -2,7 +2,7 @@ use std::convert::Infallible;
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use deserr::{DeserializeError, DeserializeFromValue, MergeWithError, ValueKind, ValuePointerRef};
|
use deserr::{DeserializeError, DeserializeFromValue, MergeWithError, ValuePointerRef};
|
||||||
use enum_iterator::Sequence;
|
use enum_iterator::Sequence;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::format_description::well_known::Rfc3339;
|
use time::format_description::well_known::Rfc3339;
|
||||||
@ -17,31 +17,6 @@ use crate::star_or::StarOr;
|
|||||||
|
|
||||||
pub type KeyId = Uuid;
|
pub type KeyId = Uuid;
|
||||||
|
|
||||||
impl<C: Default + ErrorCode> DeserializeFromValue<DeserrError<C>> for Uuid {
|
|
||||||
fn deserialize_from_value<V: deserr::IntoValue>(
|
|
||||||
value: deserr::Value<V>,
|
|
||||||
location: deserr::ValuePointerRef,
|
|
||||||
) -> std::result::Result<Self, DeserrError<C>> {
|
|
||||||
match value {
|
|
||||||
deserr::Value::String(s) => match Uuid::parse_str(&s) {
|
|
||||||
Ok(x) => Ok(x),
|
|
||||||
Err(e) => Err(unwrap_any(DeserrError::<C>::error::<V>(
|
|
||||||
None,
|
|
||||||
deserr::ErrorKind::Unexpected { msg: e.to_string() },
|
|
||||||
location,
|
|
||||||
))),
|
|
||||||
},
|
|
||||||
_ => Err(unwrap_any(DeserrError::<C>::error(
|
|
||||||
None,
|
|
||||||
deserr::ErrorKind::IncorrectValueKind {
|
|
||||||
actual: value,
|
|
||||||
accepted: &[ValueKind::String],
|
|
||||||
},
|
|
||||||
location,
|
|
||||||
))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<C: Default + ErrorCode> MergeWithError<IndexUidFormatError> for DeserrError<C> {
|
impl<C: Default + ErrorCode> MergeWithError<IndexUidFormatError> for DeserrError<C> {
|
||||||
fn merge(
|
fn merge(
|
||||||
_self_: Option<Self>,
|
_self_: Option<Self>,
|
||||||
@ -56,6 +31,10 @@ impl<C: Default + ErrorCode> MergeWithError<IndexUidFormatError> for DeserrError
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_uuid_from_str(s: &str) -> Result<Uuid, TakeErrorMessage<uuid::Error>> {
|
||||||
|
Uuid::parse_str(s).map_err(TakeErrorMessage)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, DeserializeFromValue)]
|
#[derive(Debug, DeserializeFromValue)]
|
||||||
#[deserr(error = DeserrError, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub struct CreateApiKey {
|
pub struct CreateApiKey {
|
||||||
@ -63,12 +42,9 @@ pub struct CreateApiKey {
|
|||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
#[deserr(error = DeserrError<InvalidApiKeyName>)]
|
#[deserr(error = DeserrError<InvalidApiKeyName>)]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
#[deserr(default = Uuid::new_v4(), error = DeserrError<InvalidApiKeyUid>)]
|
#[deserr(default = Uuid::new_v4(), error = DeserrError<InvalidApiKeyUid>, from(&String) = parse_uuid_from_str -> TakeErrorMessage<uuid::Error>)]
|
||||||
pub uid: KeyId,
|
pub uid: KeyId,
|
||||||
// Value at `.name` is invalid. It is a dictionary, but is expected to be an array of strings containing action names.
|
|
||||||
// Value `indeex.create` at `.name[1]` is invalid. It is expected to be one of: ....
|
|
||||||
#[deserr(error = DeserrError<InvalidApiKeyActions>)]
|
#[deserr(error = DeserrError<InvalidApiKeyActions>)]
|
||||||
//, expected = "an array of string containing action names.")]
|
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
#[deserr(error = DeserrError<InvalidApiKeyIndexes>)]
|
#[deserr(error = DeserrError<InvalidApiKeyIndexes>)]
|
||||||
pub indexes: Vec<StarOr<IndexUid>>,
|
pub indexes: Vec<StarOr<IndexUid>>,
|
||||||
|
@ -19,7 +19,7 @@ byte-unit = { version = "4.0.14", default-features = false, features = ["std", "
|
|||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
clap = { version = "4.0.9", features = ["derive", "env"] }
|
clap = { version = "4.0.9", features = ["derive", "env"] }
|
||||||
crossbeam-channel = "0.5.6"
|
crossbeam-channel = "0.5.6"
|
||||||
deserr = { path = "/Users/meilisearch/Documents/deserr", features = ["serde-json"] }
|
deserr = { version = "0.1.4", features = ["serde-json"] }
|
||||||
dump = { path = "../dump" }
|
dump = { path = "../dump" }
|
||||||
either = "1.8.0"
|
either = "1.8.0"
|
||||||
env_logger = "0.9.1"
|
env_logger = "0.9.1"
|
||||||
|
@ -3,7 +3,7 @@ use actix_web::{web, HttpRequest, HttpResponse};
|
|||||||
use deserr::DeserializeFromValue;
|
use deserr::DeserializeFromValue;
|
||||||
use index_scheduler::IndexScheduler;
|
use index_scheduler::IndexScheduler;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use meilisearch_types::error::deserr_codes::*;
|
use meilisearch_types::error::{deserr_codes::*, TakeErrorMessage};
|
||||||
use meilisearch_types::error::{DeserrError, ResponseError};
|
use meilisearch_types::error::{DeserrError, ResponseError};
|
||||||
use meilisearch_types::index_uid::IndexUid;
|
use meilisearch_types::index_uid::IndexUid;
|
||||||
use meilisearch_types::milli::{self, FieldDistribution, Index};
|
use meilisearch_types::milli::{self, FieldDistribution, Index};
|
||||||
@ -12,7 +12,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use super::{ListIndexes, SummarizedTaskView};
|
use self::search::parse_usize_take_error_message;
|
||||||
|
|
||||||
|
use super::{Pagination, SummarizedTaskView, PAGINATION_DEFAULT_LIMIT};
|
||||||
use crate::analytics::Analytics;
|
use crate::analytics::Analytics;
|
||||||
use crate::extractors::authentication::policies::*;
|
use crate::extractors::authentication::policies::*;
|
||||||
use crate::extractors::authentication::{AuthenticationError, GuardedData};
|
use crate::extractors::authentication::{AuthenticationError, GuardedData};
|
||||||
@ -68,6 +70,23 @@ impl IndexView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(DeserializeFromValue, Deserialize, Debug, Clone, Copy)]
|
||||||
|
#[deserr(error = DeserrError, rename_all = camelCase, deny_unknown_fields)]
|
||||||
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
|
pub struct ListIndexes {
|
||||||
|
#[serde(default)]
|
||||||
|
#[deserr(error = DeserrError<InvalidIndexOffset>, default, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
|
pub offset: usize,
|
||||||
|
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
||||||
|
#[deserr(error = DeserrError<InvalidIndexLimit>, default = PAGINATION_DEFAULT_LIMIT(), from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
||||||
|
pub limit: usize,
|
||||||
|
}
|
||||||
|
impl ListIndexes {
|
||||||
|
fn as_pagination(self) -> Pagination {
|
||||||
|
Pagination { offset: self.offset, limit: self.limit }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn list_indexes(
|
pub async fn list_indexes(
|
||||||
index_scheduler: GuardedData<ActionPolicy<{ actions::INDEXES_GET }>, Data<IndexScheduler>>,
|
index_scheduler: GuardedData<ActionPolicy<{ actions::INDEXES_GET }>, Data<IndexScheduler>>,
|
||||||
paginate: QueryParameter<ListIndexes, DeserrError>,
|
paginate: QueryParameter<ListIndexes, DeserrError>,
|
||||||
|
@ -16,7 +16,7 @@ use crate::routes::SummarizedTaskView;
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_setting_route {
|
macro_rules! make_setting_route {
|
||||||
($route:literal, $update_verb:ident, $type:ty, $attr:ident, $camelcase_attr:literal, $analytics_var:ident, $analytics:expr) => {
|
($route:literal, $update_verb:ident, $type:ty, $err_ty:ty, $attr:ident, $camelcase_attr:literal, $analytics_var:ident, $analytics:expr) => {
|
||||||
pub mod $attr {
|
pub mod $attr {
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::{web, HttpRequest, HttpResponse, Resource};
|
use actix_web::{web, HttpRequest, HttpResponse, Resource};
|
||||||
@ -65,7 +65,7 @@ macro_rules! make_setting_route {
|
|||||||
Data<IndexScheduler>,
|
Data<IndexScheduler>,
|
||||||
>,
|
>,
|
||||||
index_uid: actix_web::web::Path<String>,
|
index_uid: actix_web::web::Path<String>,
|
||||||
body: actix_web::web::Json<Option<$type>>,
|
body: $crate::routes::indexes::ValidatedJson<Option<$type>, $err_ty>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
$analytics_var: web::Data<dyn Analytics>,
|
$analytics_var: web::Data<dyn Analytics>,
|
||||||
) -> std::result::Result<HttpResponse, ResponseError> {
|
) -> std::result::Result<HttpResponse, ResponseError> {
|
||||||
@ -130,6 +130,9 @@ make_setting_route!(
|
|||||||
"/filterable-attributes",
|
"/filterable-attributes",
|
||||||
put,
|
put,
|
||||||
std::collections::BTreeSet<String>,
|
std::collections::BTreeSet<String>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsFilterableAttributes,
|
||||||
|
>,
|
||||||
filterable_attributes,
|
filterable_attributes,
|
||||||
"filterableAttributes",
|
"filterableAttributes",
|
||||||
analytics,
|
analytics,
|
||||||
@ -153,6 +156,9 @@ make_setting_route!(
|
|||||||
"/sortable-attributes",
|
"/sortable-attributes",
|
||||||
put,
|
put,
|
||||||
std::collections::BTreeSet<String>,
|
std::collections::BTreeSet<String>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsSortableAttributes,
|
||||||
|
>,
|
||||||
sortable_attributes,
|
sortable_attributes,
|
||||||
"sortableAttributes",
|
"sortableAttributes",
|
||||||
analytics,
|
analytics,
|
||||||
@ -176,6 +182,9 @@ make_setting_route!(
|
|||||||
"/displayed-attributes",
|
"/displayed-attributes",
|
||||||
put,
|
put,
|
||||||
Vec<String>,
|
Vec<String>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsDisplayedAttributes,
|
||||||
|
>,
|
||||||
displayed_attributes,
|
displayed_attributes,
|
||||||
"displayedAttributes",
|
"displayedAttributes",
|
||||||
analytics,
|
analytics,
|
||||||
@ -199,6 +208,9 @@ make_setting_route!(
|
|||||||
"/typo-tolerance",
|
"/typo-tolerance",
|
||||||
patch,
|
patch,
|
||||||
meilisearch_types::settings::TypoSettings,
|
meilisearch_types::settings::TypoSettings,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsTypoTolerance,
|
||||||
|
>,
|
||||||
typo_tolerance,
|
typo_tolerance,
|
||||||
"typoTolerance",
|
"typoTolerance",
|
||||||
analytics,
|
analytics,
|
||||||
@ -241,6 +253,9 @@ make_setting_route!(
|
|||||||
"/searchable-attributes",
|
"/searchable-attributes",
|
||||||
put,
|
put,
|
||||||
Vec<String>,
|
Vec<String>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsSearchableAttributes,
|
||||||
|
>,
|
||||||
searchable_attributes,
|
searchable_attributes,
|
||||||
"searchableAttributes",
|
"searchableAttributes",
|
||||||
analytics,
|
analytics,
|
||||||
@ -264,6 +279,9 @@ make_setting_route!(
|
|||||||
"/stop-words",
|
"/stop-words",
|
||||||
put,
|
put,
|
||||||
std::collections::BTreeSet<String>,
|
std::collections::BTreeSet<String>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsStopWords,
|
||||||
|
>,
|
||||||
stop_words,
|
stop_words,
|
||||||
"stopWords",
|
"stopWords",
|
||||||
analytics,
|
analytics,
|
||||||
@ -286,6 +304,9 @@ make_setting_route!(
|
|||||||
"/synonyms",
|
"/synonyms",
|
||||||
put,
|
put,
|
||||||
std::collections::BTreeMap<String, Vec<String>>,
|
std::collections::BTreeMap<String, Vec<String>>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsSynonyms,
|
||||||
|
>,
|
||||||
synonyms,
|
synonyms,
|
||||||
"synonyms",
|
"synonyms",
|
||||||
analytics,
|
analytics,
|
||||||
@ -308,6 +329,9 @@ make_setting_route!(
|
|||||||
"/distinct-attribute",
|
"/distinct-attribute",
|
||||||
put,
|
put,
|
||||||
String,
|
String,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsDistinctAttribute,
|
||||||
|
>,
|
||||||
distinct_attribute,
|
distinct_attribute,
|
||||||
"distinctAttribute",
|
"distinctAttribute",
|
||||||
analytics,
|
analytics,
|
||||||
@ -329,6 +353,9 @@ make_setting_route!(
|
|||||||
"/ranking-rules",
|
"/ranking-rules",
|
||||||
put,
|
put,
|
||||||
Vec<meilisearch_types::settings::RankingRuleView>,
|
Vec<meilisearch_types::settings::RankingRuleView>,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsRankingRules,
|
||||||
|
>,
|
||||||
ranking_rules,
|
ranking_rules,
|
||||||
"rankingRules",
|
"rankingRules",
|
||||||
analytics,
|
analytics,
|
||||||
@ -357,6 +384,9 @@ make_setting_route!(
|
|||||||
"/faceting",
|
"/faceting",
|
||||||
patch,
|
patch,
|
||||||
meilisearch_types::settings::FacetingSettings,
|
meilisearch_types::settings::FacetingSettings,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsFaceting,
|
||||||
|
>,
|
||||||
faceting,
|
faceting,
|
||||||
"faceting",
|
"faceting",
|
||||||
analytics,
|
analytics,
|
||||||
@ -379,6 +409,9 @@ make_setting_route!(
|
|||||||
"/pagination",
|
"/pagination",
|
||||||
patch,
|
patch,
|
||||||
meilisearch_types::settings::PaginationSettings,
|
meilisearch_types::settings::PaginationSettings,
|
||||||
|
meilisearch_types::error::DeserrError<
|
||||||
|
meilisearch_types::error::deserr_codes::InvalidSettingsPagination,
|
||||||
|
>,
|
||||||
pagination,
|
pagination,
|
||||||
"pagination",
|
"pagination",
|
||||||
analytics,
|
analytics,
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use self::indexes::IndexStats;
|
||||||
|
use crate::analytics::Analytics;
|
||||||
|
use crate::extractors::authentication::policies::*;
|
||||||
|
use crate::extractors::authentication::GuardedData;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::{web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use deserr::DeserializeFromValue;
|
|
||||||
use index_scheduler::{IndexScheduler, Query};
|
use index_scheduler::{IndexScheduler, Query};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use meilisearch_types::error::deserr_codes::*;
|
use meilisearch_types::error::{ResponseError, TakeErrorMessage};
|
||||||
use meilisearch_types::error::{DeserrError, ResponseError, TakeErrorMessage};
|
|
||||||
use meilisearch_types::settings::{Settings, Unchecked};
|
use meilisearch_types::settings::{Settings, Unchecked};
|
||||||
use meilisearch_types::star_or::StarOr;
|
use meilisearch_types::star_or::StarOr;
|
||||||
use meilisearch_types::tasks::{Kind, Status, Task, TaskId};
|
use meilisearch_types::tasks::{Kind, Status, Task, TaskId};
|
||||||
@ -15,12 +17,6 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use self::indexes::search::parse_usize_take_error_message;
|
|
||||||
use self::indexes::IndexStats;
|
|
||||||
use crate::analytics::Analytics;
|
|
||||||
use crate::extractors::authentication::policies::*;
|
|
||||||
use crate::extractors::authentication::GuardedData;
|
|
||||||
|
|
||||||
mod api_key;
|
mod api_key;
|
||||||
mod dump;
|
mod dump;
|
||||||
pub mod indexes;
|
pub mod indexes;
|
||||||
@ -98,23 +94,6 @@ pub struct Pagination {
|
|||||||
pub limit: usize,
|
pub limit: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DeserializeFromValue, Deserialize, Debug, Clone, Copy)]
|
|
||||||
#[deserr(error = DeserrError, rename_all = camelCase, deny_unknown_fields)]
|
|
||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
||||||
pub struct ListIndexes {
|
|
||||||
#[serde(default)]
|
|
||||||
#[deserr(error = DeserrError<InvalidIndexOffset>, default, from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
|
||||||
pub offset: usize,
|
|
||||||
#[serde(default = "PAGINATION_DEFAULT_LIMIT")]
|
|
||||||
#[deserr(error = DeserrError<InvalidIndexLimit>, default = PAGINATION_DEFAULT_LIMIT(), from(&String) = parse_usize_take_error_message -> TakeErrorMessage<std::num::ParseIntError>)]
|
|
||||||
pub limit: usize,
|
|
||||||
}
|
|
||||||
impl ListIndexes {
|
|
||||||
fn as_pagination(self) -> Pagination {
|
|
||||||
Pagination { offset: self.offset, limit: self.limit }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct PaginationView<T> {
|
pub struct PaginationView<T> {
|
||||||
pub results: Vec<T>,
|
pub results: Vec<T>,
|
||||||
|
@ -33,8 +33,8 @@ async fn add_valid_api_key() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": "indexing-key",
|
"name": "indexing-key",
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -92,8 +92,8 @@ async fn add_valid_api_key_expired_at() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -136,8 +136,8 @@ async fn add_valid_api_key_no_description() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -169,8 +169,8 @@ async fn add_valid_api_key_null_description() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -199,8 +199,8 @@ async fn error_add_api_key_no_header() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
||||||
"code": "missing_authorization_header",
|
"code": "missing_authorization_header",
|
||||||
@ -222,8 +222,8 @@ async fn error_add_api_key_bad_key() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"403");
|
meili_snap::snapshot!(code, @"403 Forbidden");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The provided API key is invalid.",
|
"message": "The provided API key is invalid.",
|
||||||
"code": "invalid_api_key",
|
"code": "invalid_api_key",
|
||||||
@ -245,8 +245,8 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: missing field `indexes` at ``",
|
"message": "Json deserialize error: missing field `indexes` at ``",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -262,8 +262,8 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: missing field `actions` at ``",
|
"message": "Json deserialize error: missing field `actions` at ``",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -279,8 +279,8 @@ async fn error_add_api_key_missing_parameter() {
|
|||||||
"actions": ["documents.add"],
|
"actions": ["documents.add"],
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -311,8 +311,8 @@ async fn error_add_api_key_invalid_parameters_description() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.description`.",
|
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.description`.",
|
||||||
"code": "invalid_api_key_description",
|
"code": "invalid_api_key_description",
|
||||||
@ -334,8 +334,8 @@ async fn error_add_api_key_invalid_parameters_name() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.name`.",
|
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.name`.",
|
||||||
"code": "invalid_api_key_name",
|
"code": "invalid_api_key_name",
|
||||||
@ -357,8 +357,8 @@ async fn error_add_api_key_invalid_parameters_indexes() {
|
|||||||
"expiresAt": "2050-11-13T00:00:00Z"
|
"expiresAt": "2050-11-13T00:00:00Z"
|
||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a Sequence at `.indexes`.",
|
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a Sequence at `.indexes`.",
|
||||||
"code": "invalid_api_key_indexes",
|
"code": "invalid_api_key_indexes",
|
||||||
@ -383,8 +383,8 @@ async fn error_add_api_key_invalid_index_uids() {
|
|||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
|
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "`invalid index # / \\name with spaces` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_). at `.indexes[0]`.",
|
"message": "`invalid index # / \\name with spaces` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_). at `.indexes[0]`.",
|
||||||
"code": "invalid_api_key_indexes",
|
"code": "invalid_api_key_indexes",
|
||||||
@ -408,8 +408,8 @@ async fn error_add_api_key_invalid_parameters_actions() {
|
|||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
assert_eq!(400, code, "{:?}", &response);
|
assert_eq!(400, code, "{:?}", &response);
|
||||||
|
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a Sequence at `.actions`.",
|
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a Sequence at `.actions`.",
|
||||||
"code": "invalid_api_key_actions",
|
"code": "invalid_api_key_actions",
|
||||||
@ -428,8 +428,8 @@ async fn error_add_api_key_invalid_parameters_actions() {
|
|||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
|
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: unknown value `doc.add`, expected one of `*`, `search`, `documents.*`, `documents.add`, `documents.get`, `documents.delete`, `indexes.*`, `indexes.create`, `indexes.get`, `indexes.update`, `indexes.delete`, `indexes.swap`, `tasks.*`, `tasks.cancel`, `tasks.delete`, `tasks.get`, `settings.*`, `settings.get`, `settings.update`, `stats.*`, `stats.get`, `metrics.*`, `metrics.get`, `dumps.*`, `dumps.create`, `version`, `keys.create`, `keys.get`, `keys.update`, `keys.delete` at `.actions[0]`.",
|
"message": "Json deserialize error: unknown value `doc.add`, expected one of `*`, `search`, `documents.*`, `documents.add`, `documents.get`, `documents.delete`, `indexes.*`, `indexes.create`, `indexes.get`, `indexes.update`, `indexes.delete`, `indexes.swap`, `tasks.*`, `tasks.cancel`, `tasks.delete`, `tasks.get`, `settings.*`, `settings.get`, `settings.update`, `stats.*`, `stats.get`, `metrics.*`, `metrics.get`, `dumps.*`, `dumps.create`, `version`, `keys.create`, `keys.get`, `keys.update`, `keys.delete` at `.actions[0]`.",
|
||||||
"code": "invalid_api_key_actions",
|
"code": "invalid_api_key_actions",
|
||||||
@ -452,8 +452,8 @@ async fn error_add_api_key_invalid_parameters_expires_at() {
|
|||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
|
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.expiresAt`.",
|
"message": "invalid type: Map `{\"name\":\"products\"}`, expected a String at `.expiresAt`.",
|
||||||
"code": "invalid_api_key_expires_at",
|
"code": "invalid_api_key_expires_at",
|
||||||
@ -476,7 +476,7 @@ async fn error_add_api_key_invalid_parameters_expires_at_in_the_past() {
|
|||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "`2010-11-13T00:00:00Z` is not a valid date. It should follow the RFC 3339 format to represents a date or datetime in the future or specified as a null value. e.g. 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'.\n at `.expiresAt`.",
|
"message": "`2010-11-13T00:00:00Z` is not a valid date. It should follow the RFC 3339 format to represents a date or datetime in the future or specified as a null value. e.g. 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'.\n at `.expiresAt`.",
|
||||||
"code": "invalid_api_key_expires_at",
|
"code": "invalid_api_key_expires_at",
|
||||||
@ -484,7 +484,7 @@ async fn error_add_api_key_invalid_parameters_expires_at_in_the_past() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key-expires-at"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key-expires-at"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -501,7 +501,7 @@ async fn error_add_api_key_invalid_parameters_uid() {
|
|||||||
});
|
});
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid length: expected length 32 for simple format, found 13 at `.uid`.",
|
"message": "invalid length: expected length 32 for simple format, found 13 at `.uid`.",
|
||||||
"code": "invalid_api_key_uid",
|
"code": "invalid_api_key_uid",
|
||||||
@ -509,7 +509,7 @@ async fn error_add_api_key_invalid_parameters_uid() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key-uid"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key-uid"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -525,7 +525,7 @@ async fn error_add_api_key_parameters_uid_already_exist() {
|
|||||||
|
|
||||||
// first creation is valid.
|
// first creation is valid.
|
||||||
let (response, code) = server.add_api_key(content.clone()).await;
|
let (response, code) = server.add_api_key(content.clone()).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -542,11 +542,11 @@ async fn error_add_api_key_parameters_uid_already_exist() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
// uid already exist.
|
// uid already exist.
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "`uid` field value `4bc0887a-0e41-4f3b-935d-0c451dcee9c8` is already an existing API key.",
|
"message": "`uid` field value `4bc0887a-0e41-4f3b-935d-0c451dcee9c8` is already an existing API key.",
|
||||||
"code": "api_key_already_exists",
|
"code": "api_key_already_exists",
|
||||||
@ -554,7 +554,7 @@ async fn error_add_api_key_parameters_uid_already_exist() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#api-key-already-exists"
|
"link": "https://docs.meilisearch.com/errors#api-key-already-exists"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"409");
|
meili_snap::snapshot!(code, @"409 Conflict");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -586,7 +586,7 @@ async fn get_api_key() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -615,13 +615,13 @@ async fn get_api_key() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
|
|
||||||
// get with uid
|
// get with uid
|
||||||
let (response, code) = server.get_api_key(&uid).await;
|
let (response, code) = server.get_api_key(&uid).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -650,10 +650,10 @@ async fn get_api_key() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
// get with key
|
// get with key
|
||||||
let (response, code) = server.get_api_key(&key).await;
|
let (response, code) = server.get_api_key(&key).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -682,7 +682,7 @@ async fn get_api_key() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -692,7 +692,7 @@ async fn error_get_api_key_no_header() {
|
|||||||
let (response, code) = server
|
let (response, code) = server
|
||||||
.get_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.get_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
||||||
"code": "missing_authorization_header",
|
"code": "missing_authorization_header",
|
||||||
@ -700,7 +700,7 @@ async fn error_get_api_key_no_header() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -711,7 +711,7 @@ async fn error_get_api_key_bad_key() {
|
|||||||
let (response, code) = server
|
let (response, code) = server
|
||||||
.get_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.get_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The provided API key is invalid.",
|
"message": "The provided API key is invalid.",
|
||||||
"code": "invalid_api_key",
|
"code": "invalid_api_key",
|
||||||
@ -719,7 +719,7 @@ async fn error_get_api_key_bad_key() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"403");
|
meili_snap::snapshot!(code, @"403 Forbidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -730,7 +730,7 @@ async fn error_get_api_key_not_found() {
|
|||||||
let (response, code) = server
|
let (response, code) = server
|
||||||
.get_api_key("d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.get_api_key("d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
||||||
"code": "api_key_not_found",
|
"code": "api_key_not_found",
|
||||||
@ -738,7 +738,7 @@ async fn error_get_api_key_not_found() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"404");
|
meili_snap::snapshot!(code, @"404 Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -768,7 +768,7 @@ async fn list_api_keys() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -797,10 +797,10 @@ async fn list_api_keys() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let (response, code) = server.list_api_keys().await;
|
let (response, code) = server.list_api_keys().await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".results[].createdAt" => "[ignored]", ".results[].updatedAt" => "[ignored]", ".results[].uid" => "[ignored]", ".results[].key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".results[].createdAt" => "[ignored]", ".results[].updatedAt" => "[ignored]", ".results[].uid" => "[ignored]", ".results[].key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"results": [
|
"results": [
|
||||||
{
|
{
|
||||||
@ -866,7 +866,7 @@ async fn list_api_keys() {
|
|||||||
"total": 3
|
"total": 3
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -874,7 +874,7 @@ async fn error_list_api_keys_no_header() {
|
|||||||
let server = Server::new_auth().await;
|
let server = Server::new_auth().await;
|
||||||
|
|
||||||
let (response, code) = server.list_api_keys().await;
|
let (response, code) = server.list_api_keys().await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
||||||
"code": "missing_authorization_header",
|
"code": "missing_authorization_header",
|
||||||
@ -882,7 +882,7 @@ async fn error_list_api_keys_no_header() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -891,7 +891,7 @@ async fn error_list_api_keys_bad_key() {
|
|||||||
server.use_api_key("d4000bd7225f77d1eb22cc706ed36772bbc36767c016a27f76def7537b68600d");
|
server.use_api_key("d4000bd7225f77d1eb22cc706ed36772bbc36767c016a27f76def7537b68600d");
|
||||||
|
|
||||||
let (response, code) = server.list_api_keys().await;
|
let (response, code) = server.list_api_keys().await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The provided API key is invalid.",
|
"message": "The provided API key is invalid.",
|
||||||
"code": "invalid_api_key",
|
"code": "invalid_api_key",
|
||||||
@ -899,7 +899,7 @@ async fn error_list_api_keys_bad_key() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"403");
|
meili_snap::snapshot!(code, @"403 Forbidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -929,7 +929,7 @@ async fn delete_api_key() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -958,17 +958,17 @@ async fn delete_api_key() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
let (response, code) = server.delete_api_key(&uid).await;
|
let (response, code) = server.delete_api_key(&uid).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @"null");
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @"null");
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"204");
|
meili_snap::snapshot!(code, @"204 No Content");
|
||||||
|
|
||||||
// check if API key no longer exist.
|
// check if API key no longer exist.
|
||||||
let (response, code) = server.get_api_key(&uid).await;
|
let (response, code) = server.get_api_key(&uid).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".message" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".message" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "[ignored]",
|
"message": "[ignored]",
|
||||||
"code": "api_key_not_found",
|
"code": "api_key_not_found",
|
||||||
@ -976,7 +976,7 @@ async fn delete_api_key() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"404");
|
meili_snap::snapshot!(code, @"404 Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -987,7 +987,7 @@ async fn error_delete_api_key_no_header() {
|
|||||||
.delete_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.delete_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
||||||
"code": "missing_authorization_header",
|
"code": "missing_authorization_header",
|
||||||
@ -995,7 +995,7 @@ async fn error_delete_api_key_no_header() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1006,7 +1006,7 @@ async fn error_delete_api_key_bad_key() {
|
|||||||
let (response, code) = server
|
let (response, code) = server
|
||||||
.delete_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.delete_api_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The provided API key is invalid.",
|
"message": "The provided API key is invalid.",
|
||||||
"code": "invalid_api_key",
|
"code": "invalid_api_key",
|
||||||
@ -1014,7 +1014,7 @@ async fn error_delete_api_key_bad_key() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"403");
|
meili_snap::snapshot!(code, @"403 Forbidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1025,7 +1025,7 @@ async fn error_delete_api_key_not_found() {
|
|||||||
let (response, code) = server
|
let (response, code) = server
|
||||||
.delete_api_key("d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
.delete_api_key("d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4")
|
||||||
.await;
|
.await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
||||||
"code": "api_key_not_found",
|
"code": "api_key_not_found",
|
||||||
@ -1033,7 +1033,7 @@ async fn error_delete_api_key_not_found() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"404");
|
meili_snap::snapshot!(code, @"404 Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1059,7 +1059,7 @@ async fn patch_api_key_description() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1085,7 +1085,7 @@ async fn patch_api_key_description() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
@ -1094,7 +1094,7 @@ async fn patch_api_key_description() {
|
|||||||
|
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -1120,13 +1120,13 @@ async fn patch_api_key_description() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
|
|
||||||
// Change the description
|
// Change the description
|
||||||
let content = json!({ "description": "Product API key" });
|
let content = json!({ "description": "Product API key" });
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Product API key",
|
"description": "Product API key",
|
||||||
@ -1152,13 +1152,13 @@ async fn patch_api_key_description() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
|
|
||||||
// Remove the description
|
// Remove the description
|
||||||
let content = json!({ "description": serde_json::Value::Null });
|
let content = json!({ "description": serde_json::Value::Null });
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1184,7 +1184,7 @@ async fn patch_api_key_description() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1210,7 +1210,7 @@ async fn patch_api_key_name() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1236,7 +1236,7 @@ async fn patch_api_key_name() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
let created_at = response["createdAt"].as_str().unwrap();
|
let created_at = response["createdAt"].as_str().unwrap();
|
||||||
@ -1247,7 +1247,7 @@ async fn patch_api_key_name() {
|
|||||||
|
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": "Indexing API key",
|
"name": "Indexing API key",
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1273,7 +1273,7 @@ async fn patch_api_key_name() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
|
|
||||||
assert_ne!(response["updatedAt"].as_str().unwrap(), updated_at);
|
assert_ne!(response["updatedAt"].as_str().unwrap(), updated_at);
|
||||||
assert_eq!(response["createdAt"].as_str().unwrap(), created_at);
|
assert_eq!(response["createdAt"].as_str().unwrap(), created_at);
|
||||||
@ -1282,7 +1282,7 @@ async fn patch_api_key_name() {
|
|||||||
let content = json!({ "name": "Product API key" });
|
let content = json!({ "name": "Product API key" });
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": "Product API key",
|
"name": "Product API key",
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1308,13 +1308,13 @@ async fn patch_api_key_name() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
|
|
||||||
// Remove the name
|
// Remove the name
|
||||||
let content = json!({ "name": serde_json::Value::Null });
|
let content = json!({ "name": serde_json::Value::Null });
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": null,
|
"description": null,
|
||||||
@ -1340,7 +1340,7 @@ async fn patch_api_key_name() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"200");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1367,7 +1367,7 @@ async fn error_patch_api_key_indexes() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -1393,7 +1393,7 @@ async fn error_patch_api_key_indexes() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
@ -1401,7 +1401,7 @@ async fn error_patch_api_key_indexes() {
|
|||||||
|
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: unknown field `indexes`, expected one of `description`, `name` at ``.",
|
"message": "Json deserialize error: unknown field `indexes`, expected one of `description`, `name` at ``.",
|
||||||
"code": "immutable_field",
|
"code": "immutable_field",
|
||||||
@ -1409,7 +1409,7 @@ async fn error_patch_api_key_indexes() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1436,7 +1436,7 @@ async fn error_patch_api_key_actions() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -1462,7 +1462,7 @@ async fn error_patch_api_key_actions() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
@ -1478,7 +1478,7 @@ async fn error_patch_api_key_actions() {
|
|||||||
|
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: unknown field `actions`, expected one of `description`, `name` at ``.",
|
"message": "Json deserialize error: unknown field `actions`, expected one of `description`, `name` at ``.",
|
||||||
"code": "immutable_field",
|
"code": "immutable_field",
|
||||||
@ -1486,7 +1486,7 @@ async fn error_patch_api_key_actions() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1513,7 +1513,7 @@ async fn error_patch_api_key_expiration_date() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -1539,7 +1539,7 @@ async fn error_patch_api_key_expiration_date() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
@ -1547,7 +1547,7 @@ async fn error_patch_api_key_expiration_date() {
|
|||||||
|
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Json deserialize error: unknown field `expiresAt`, expected one of `description`, `name` at ``.",
|
"message": "Json deserialize error: unknown field `expiresAt`, expected one of `description`, `name` at ``.",
|
||||||
"code": "immutable_field",
|
"code": "immutable_field",
|
||||||
@ -1555,7 +1555,7 @@ async fn error_patch_api_key_expiration_date() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
"link": "https://docs.meilisearch.com/errors#immutable-field"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1569,7 +1569,7 @@ async fn error_patch_api_key_no_header() {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
"message": "The Authorization header is missing. It must use the bearer authorization method.",
|
||||||
"code": "missing_authorization_header",
|
"code": "missing_authorization_header",
|
||||||
@ -1577,7 +1577,7 @@ async fn error_patch_api_key_no_header() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
"link": "https://docs.meilisearch.com/errors#missing-authorization-header"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1592,7 +1592,7 @@ async fn error_patch_api_key_bad_key() {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "The provided API key is invalid.",
|
"message": "The provided API key is invalid.",
|
||||||
"code": "invalid_api_key",
|
"code": "invalid_api_key",
|
||||||
@ -1600,7 +1600,7 @@ async fn error_patch_api_key_bad_key() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"403");
|
meili_snap::snapshot!(code, @"403 Forbidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1615,7 +1615,7 @@ async fn error_patch_api_key_not_found() {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
"message": "API key `d0552b41d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4` not found.",
|
||||||
"code": "api_key_not_found",
|
"code": "api_key_not_found",
|
||||||
@ -1623,7 +1623,7 @@ async fn error_patch_api_key_not_found() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
"link": "https://docs.meilisearch.com/errors#api-key-not-found"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"404");
|
meili_snap::snapshot!(code, @"404 Not Found");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1641,7 +1641,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(content).await;
|
let (response, code) = server.add_api_key(content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]", ".uid" => "[ignored]", ".key" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"name": null,
|
"name": null,
|
||||||
"description": "Indexing API key",
|
"description": "Indexing API key",
|
||||||
@ -1658,7 +1658,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
"updatedAt": "[ignored]"
|
"updatedAt": "[ignored]"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"201");
|
meili_snap::snapshot!(code, @"201 Created");
|
||||||
|
|
||||||
let uid = response["uid"].as_str().unwrap();
|
let uid = response["uid"].as_str().unwrap();
|
||||||
|
|
||||||
@ -1668,7 +1668,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Integer `13`, expected a String at `.description`.",
|
"message": "invalid type: Integer `13`, expected a String at `.description`.",
|
||||||
"code": "invalid_api_key_description",
|
"code": "invalid_api_key_description",
|
||||||
@ -1676,7 +1676,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key-description"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key-description"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
|
|
||||||
// invalid name
|
// invalid name
|
||||||
let content = json!({
|
let content = json!({
|
||||||
@ -1684,7 +1684,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key(&uid, content).await;
|
let (response, code) = server.patch_api_key(&uid, content).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "invalid type: Integer `13`, expected a String at `.name`.",
|
"message": "invalid type: Integer `13`, expected a String at `.name`.",
|
||||||
"code": "invalid_api_key_name",
|
"code": "invalid_api_key_name",
|
||||||
@ -1692,7 +1692,7 @@ async fn error_patch_api_key_indexes_invalid_parameters() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#invalid-api-key-name"
|
"link": "https://docs.meilisearch.com/errors#invalid-api-key-name"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
@ -1700,7 +1700,7 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
let mut server = Server::new().await;
|
let mut server = Server::new().await;
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(json!({})).await;
|
let (response, code) = server.add_api_key(json!({})).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1708,10 +1708,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key("content", json!({})).await;
|
let (response, code) = server.patch_api_key("content", json!({})).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1719,10 +1719,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.get_api_key("content").await;
|
let (response, code) = server.get_api_key("content").await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1730,10 +1730,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.list_api_keys().await;
|
let (response, code) = server.list_api_keys().await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1741,12 +1741,12 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
server.use_api_key("MASTER_KEY");
|
server.use_api_key("MASTER_KEY");
|
||||||
|
|
||||||
let (response, code) = server.add_api_key(json!({})).await;
|
let (response, code) = server.add_api_key(json!({})).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1754,10 +1754,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.patch_api_key("content", json!({})).await;
|
let (response, code) = server.patch_api_key("content", json!({})).await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1765,10 +1765,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.get_api_key("content").await;
|
let (response, code) = server.get_api_key("content").await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1776,10 +1776,10 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
|
|
||||||
let (response, code) = server.list_api_keys().await;
|
let (response, code) = server.list_api_keys().await;
|
||||||
meili_snap::insta::assert_json_snapshot!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response, { ".createdAt" => "[ignored]", ".updatedAt" => "[ignored]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
"message": "Meilisearch is running without a master key. To access this API endpoint, you must have set a master key at launch.",
|
||||||
"code": "missing_master_key",
|
"code": "missing_master_key",
|
||||||
@ -1787,5 +1787,5 @@ async fn error_access_api_key_routes_no_master_key_set() {
|
|||||||
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
"link": "https://docs.meilisearch.com/errors#missing-master-key"
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"401");
|
meili_snap::snapshot!(code, @"401 Unauthorized");
|
||||||
}
|
}
|
||||||
|
@ -179,15 +179,15 @@ async fn error_update_setting_unexisting_index_invalid_uid() {
|
|||||||
let server = Server::new().await;
|
let server = Server::new().await;
|
||||||
let index = server.index("test##! ");
|
let index = server.index("test##! ");
|
||||||
let (response, code) = index.update_settings(json!({})).await;
|
let (response, code) = index.update_settings(json!({})).await;
|
||||||
assert_eq!(code, 400);
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
let expected = json!({
|
{
|
||||||
"message": "`test##! ` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
|
"message": "`test##! ` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
|
||||||
"code": "invalid_index_uid",
|
"code": "invalid_index_uid",
|
||||||
"type": "invalid_request",
|
"type": "invalid_request",
|
||||||
"link": "https://docs.meilisearch.com/errors#invalid-index-uid"});
|
"link": "https://docs.meilisearch.com/errors#invalid-index-uid"
|
||||||
|
}
|
||||||
assert_eq!(response, expected);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! test_setting_routes {
|
macro_rules! test_setting_routes {
|
||||||
@ -279,8 +279,8 @@ async fn error_set_invalid_ranking_rules() {
|
|||||||
index.create(None).await;
|
index.create(None).await;
|
||||||
|
|
||||||
let (response, code) = index.update_settings(json!({ "rankingRules": [ "manyTheFish"]})).await;
|
let (response, code) = index.update_settings(json!({ "rankingRules": [ "manyTheFish"]})).await;
|
||||||
meili_snap::insta::assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
meili_snap::insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "`manyTheFish` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. at `.rankingRules[0]`.",
|
"message": "`manyTheFish` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. at `.rankingRules[0]`.",
|
||||||
"code": "invalid_settings_ranking_rules",
|
"code": "invalid_settings_ranking_rules",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use meili_snap::insta::{self, assert_debug_snapshot, assert_json_snapshot};
|
use meili_snap::insta::assert_json_snapshot;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use time::format_description::well_known::Rfc3339;
|
use time::format_description::well_known::Rfc3339;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
@ -179,7 +179,7 @@ async fn get_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.tasks_filter(json!( { "lol": "pied" })).await;
|
let (response, code) = server.tasks_filter(json!( { "lol": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query deserialize error: unknown field `lol`",
|
"message": "Query deserialize error: unknown field `lol`",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -190,7 +190,7 @@ async fn get_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.tasks_filter(json!( { "uids": "pied" })).await;
|
let (response, code) = server.tasks_filter(json!( { "uids": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
||||||
"code": "invalid_task_uids",
|
"code": "invalid_task_uids",
|
||||||
@ -201,7 +201,7 @@ async fn get_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.tasks_filter(json!( { "from": "pied" })).await;
|
let (response, code) = server.tasks_filter(json!( { "from": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query deserialize error: invalid digit found in string",
|
"message": "Query deserialize error: invalid digit found in string",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -212,7 +212,7 @@ async fn get_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.tasks_filter(json!( { "beforeStartedAt": "pied" })).await;
|
let (response, code) = server.tasks_filter(json!( { "beforeStartedAt": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Task `beforeStartedAt` `pied` is invalid. It should follow the YYYY-MM-DD or RFC 3339 date-time format.",
|
"message": "Task `beforeStartedAt` `pied` is invalid. It should follow the YYYY-MM-DD or RFC 3339 date-time format.",
|
||||||
"code": "invalid_task_before_started_at",
|
"code": "invalid_task_before_started_at",
|
||||||
@ -228,7 +228,7 @@ async fn delete_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.delete_tasks(json!(null)).await;
|
let (response, code) = server.delete_tasks(json!(null)).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query parameters to filter the tasks to delete are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
|
"message": "Query parameters to filter the tasks to delete are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
|
||||||
"code": "missing_task_filters",
|
"code": "missing_task_filters",
|
||||||
@ -239,7 +239,7 @@ async fn delete_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.delete_tasks(json!({ "lol": "pied" })).await;
|
let (response, code) = server.delete_tasks(json!({ "lol": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query deserialize error: unknown field `lol`",
|
"message": "Query deserialize error: unknown field `lol`",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -250,7 +250,7 @@ async fn delete_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.delete_tasks(json!({ "uids": "pied" })).await;
|
let (response, code) = server.delete_tasks(json!({ "uids": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
||||||
"code": "invalid_task_uids",
|
"code": "invalid_task_uids",
|
||||||
@ -266,7 +266,7 @@ async fn cancel_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.cancel_tasks(json!(null)).await;
|
let (response, code) = server.cancel_tasks(json!(null)).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query parameters to filter the tasks to cancel are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
|
"message": "Query parameters to filter the tasks to cancel are missing. Available query parameters are: `uids`, `indexUids`, `statuses`, `types`, `beforeEnqueuedAt`, `afterEnqueuedAt`, `beforeStartedAt`, `afterStartedAt`, `beforeFinishedAt`, `afterFinishedAt`.",
|
||||||
"code": "missing_task_filters",
|
"code": "missing_task_filters",
|
||||||
@ -277,7 +277,7 @@ async fn cancel_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.cancel_tasks(json!({ "lol": "pied" })).await;
|
let (response, code) = server.cancel_tasks(json!({ "lol": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Query deserialize error: unknown field `lol`",
|
"message": "Query deserialize error: unknown field `lol`",
|
||||||
"code": "bad_request",
|
"code": "bad_request",
|
||||||
@ -288,7 +288,7 @@ async fn cancel_task_filter_error() {
|
|||||||
|
|
||||||
let (response, code) = server.cancel_tasks(json!({ "uids": "pied" })).await;
|
let (response, code) = server.cancel_tasks(json!({ "uids": "pied" })).await;
|
||||||
assert_eq!(code, 400, "{}", response);
|
assert_eq!(code, 400, "{}", response);
|
||||||
insta::assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
"message": "Task uid `pied` is invalid. It should only contain numeric characters.",
|
||||||
"code": "invalid_task_uids",
|
"code": "invalid_task_uids",
|
||||||
@ -518,8 +518,8 @@ async fn test_summarized_settings_update() {
|
|||||||
let index = server.index("test");
|
let index = server.index("test");
|
||||||
// here we should find my payload even in the failed task.
|
// here we should find my payload even in the failed task.
|
||||||
let (response, code) = index.update_settings(json!({ "rankingRules": ["custom"] })).await;
|
let (response, code) = index.update_settings(json!({ "rankingRules": ["custom"] })).await;
|
||||||
assert_debug_snapshot!(code, @"400");
|
meili_snap::snapshot!(code, @"400 Bad Request");
|
||||||
assert_json_snapshot!(response, @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
|
||||||
{
|
{
|
||||||
"message": "`custom` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. at `.rankingRules[0]`.",
|
"message": "`custom` ranking rule is invalid. Valid ranking rules are words, typo, sort, proximity, attribute, exactness and custom ranking rules. at `.rankingRules[0]`.",
|
||||||
"code": "invalid_settings_ranking_rules",
|
"code": "invalid_settings_ranking_rules",
|
||||||
|
Loading…
Reference in New Issue
Block a user