mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-06 09:27:46 +08:00
feat(models): add external catalog proxy selection
This commit is contained in:
@@ -22,6 +22,24 @@ pub(super) fn classify_admin_model_provider_family_route(
|
||||
"admin:models",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET && normalized_path == "/api/admin/models/external/config"
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"model_external_manage",
|
||||
"external_config_get",
|
||||
"admin:models",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::PUT && normalized_path == "/api/admin/models/external/config"
|
||||
{
|
||||
Some(classified(
|
||||
"admin_proxy",
|
||||
"model_external_manage",
|
||||
"external_config_set",
|
||||
"admin:models",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::DELETE
|
||||
&& normalized_path == "/api/admin/models/external/cache"
|
||||
{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use http::Uri;
|
||||
|
||||
use crate::control::GatewayPublicRequestContext;
|
||||
use crate::handlers::shared::local_proxy_route_requires_buffered_body;
|
||||
|
||||
use super::{classify_control_route, headers};
|
||||
|
||||
#[test]
|
||||
@@ -488,6 +491,53 @@ fn classifies_admin_external_models_as_admin_proxy_route() {
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_admin_external_models_config_routes_as_admin_proxy_routes() {
|
||||
let headers = headers(&[]);
|
||||
let uri: Uri = "/api/admin/models/external/config"
|
||||
.parse()
|
||||
.expect("uri should parse");
|
||||
|
||||
for (method, route_kind) in [
|
||||
(http::Method::GET, "external_config_get"),
|
||||
(http::Method::PUT, "external_config_set"),
|
||||
] {
|
||||
let decision = classify_control_route(&method, &uri, &headers)
|
||||
.unwrap_or_else(|| panic!("{method} route should classify"));
|
||||
|
||||
assert_eq!(decision.route_class.as_deref(), Some("admin_proxy"));
|
||||
assert_eq!(
|
||||
decision.route_family.as_deref(),
|
||||
Some("model_external_manage")
|
||||
);
|
||||
assert_eq!(decision.route_kind.as_deref(), Some(route_kind));
|
||||
assert_eq!(
|
||||
decision.auth_endpoint_signature.as_deref(),
|
||||
Some("admin:models")
|
||||
);
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_external_models_config_update_buffers_request_body() {
|
||||
let headers = headers(&[]);
|
||||
let uri: Uri = "/api/admin/models/external/config"
|
||||
.parse()
|
||||
.expect("uri should parse");
|
||||
let decision =
|
||||
classify_control_route(&http::Method::PUT, &uri, &headers).expect("route should classify");
|
||||
let context = GatewayPublicRequestContext::from_request_parts(
|
||||
"trace-admin-external-models-config",
|
||||
&http::Method::PUT,
|
||||
&uri,
|
||||
&headers,
|
||||
Some(decision),
|
||||
);
|
||||
|
||||
assert!(local_proxy_route_requires_buffered_body(&context));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classifies_admin_clear_external_models_cache_as_admin_proxy_route() {
|
||||
let headers = headers(&[]);
|
||||
|
||||
Reference in New Issue
Block a user