swarm-controller: agent permissions and inference take the settings sub-state

This commit is contained in:
atlas 2026-11-30 14:31:22 +01:00 • committed by mara
commit 4a7df3f804

View file

@ -980,8 +980,9 @@ mod tests {
/// 400 before the queue is asked.
#[tokio::test]
async fn the_inference_routes_check_the_name_and_body_before_the_queue() {
use crate::agents::AgentSettingsState;
use crate::inference::{delete_agent_inference, get_agent_inference, put_agent_inference};
use axum::extract::{Path, State};
use axum::extract::{FromRef as _, Path, State};
use axum::http::StatusCode;
fn status<T>(r: Result<T, problem_details::ProblemDetails>) -> Option<StatusCode> {
@ -989,6 +990,7 @@ mod tests {
}
let (state, _sched) = state_with_roster();
let body = |json: &str| axum::Json(serde_json::from_str(json).expect("decodes"));
let settings = AgentSettingsState::from_ref;
for name in ["iris", "Not An Ident"] {
let want = Some(if name == "iris" {
StatusCode::SERVICE_UNAVAILABLE
@ -997,20 +999,24 @@ mod tests {
});
let path = || Path(name.to_owned());
assert_eq!(
status(get_agent_inference(State(state.clone()), path()).await),
status(get_agent_inference(State(settings(&state)), path()).await),
want,
"GET {name}"
);
assert_eq!(
status(
put_agent_inference(State(state.clone()), path(), body(r#"{"model":"opus"}"#))
.await
put_agent_inference(
State(settings(&state)),
path(),
body(r#"{"model":"opus"}"#)
)
.await
),
want,
"PUT {name}"
);
assert_eq!(
status(delete_agent_inference(State(state.clone()), path()).await),
status(delete_agent_inference(State(settings(&state)), path()).await),
want,
"DELETE {name}"
);
@ -1018,8 +1024,12 @@ mod tests {
for bad in [r#"{"model":"opus 4"}"#, r#"{"model":"--print"}"#] {
assert_eq!(
status(
put_agent_inference(State(state.clone()), Path("iris".to_owned()), body(bad))
.await
put_agent_inference(
State(settings(&state)),
Path("iris".to_owned()),
body(bad)
)
.await
),
Some(StatusCode::BAD_REQUEST),
"{bad}"