Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/api-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ pub fn default_true() -> bool {
true
}

/// Default page size applied when the client does not supply `limit`.
/// Default `limit` when the client does not supply one: **`None`**.
///
/// Deliberately not a hard-coded page size. ADR 0029's precedence chain is
/// "user limit -> per-resource `list_limit` -> global `[DEFAULT] list_limit`
/// -> `max_db_limit`", and `Config::resolve_list_limit` only consults the
/// configured values when the request carries no limit. Returning `Some(20)`
/// here made `requested` always populated, which silently rendered every
/// `list_limit` setting dead config. `None` also matches python keystone,
/// whose `[DEFAULT] list_limit` is unset (no truncation) out of the box.
pub fn default_list_limit() -> Option<u64> {
Some(20)
None
}

/// Shared pagination query parameters, reused by every v3/v4 list endpoint.
Expand Down
23 changes: 22 additions & 1 deletion crates/core/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,27 @@ pub mod tests {
provider_builder: ProviderBuilder,
policy_allow: bool,
policy_allow_see_other_domains: Option<bool>,
) -> ServiceState {
get_mocked_state_with_config(
provider_builder,
policy_allow,
policy_allow_see_other_domains,
Config::default(),
)
.await
}

/// Like [`get_mocked_state`], but with a caller-supplied [`Config`].
///
/// Needed to exercise anything the configuration governs — notably the
/// `list_limit`/`max_db_limit` pagination chain, which `Config::default()`
/// leaves entirely unset and therefore cannot distinguish a resolved
/// limit from the raw request value.
pub async fn get_mocked_state_with_config(
provider_builder: ProviderBuilder,
policy_allow: bool,
policy_allow_see_other_domains: Option<bool>,
config: Config,
) -> ServiceState {
let provider = provider_builder.build().unwrap();

Expand All @@ -213,7 +234,7 @@ pub mod tests {

Arc::new(
Service::new(
ConfigManager::not_watched(Config::default()),
ConfigManager::not_watched(config),
DatabaseConnection::default(),
provider,
Arc::new(policy_enforcer_mock),
Expand Down
Loading
Loading