mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
Merge remote-tracking branch 'origin/pr/416' into codex/pr-416-420-integration
# Conflicts: # crates/aether-data/src/lifecycle/bootstrap/postgres.rs # crates/aether-data/src/lifecycle/migrate/tests.rs
This commit is contained in:
@@ -524,4 +524,83 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_covers_admin_route_signatures_from_route_sources() {
|
||||
let route_sources = [
|
||||
("route/admin.rs", include_str!("route/admin.rs")),
|
||||
("route/oauth.rs", include_str!("route/oauth.rs")),
|
||||
(
|
||||
"route/public_support.rs",
|
||||
include_str!("route/public_support.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/basic_families.rs",
|
||||
include_str!("route/admin/basic_families.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/endpoints_families.rs",
|
||||
include_str!("route/admin/endpoints_families.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/model_provider_families.rs",
|
||||
include_str!("route/admin/model_provider_families.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/observability_families.rs",
|
||||
include_str!("route/admin/observability_families.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/operations_families.rs",
|
||||
include_str!("route/admin/operations_families.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/provider_ops_routes.rs",
|
||||
include_str!("route/admin/provider_ops_routes.rs"),
|
||||
),
|
||||
(
|
||||
"route/admin/system_families.rs",
|
||||
include_str!("route/admin/system_families.rs"),
|
||||
),
|
||||
];
|
||||
let mut route_scopes = BTreeSet::new();
|
||||
|
||||
for (file, source) in route_sources {
|
||||
for scope in extract_admin_route_scopes(source) {
|
||||
assert!(
|
||||
is_known_management_token_permission_scope(scope),
|
||||
"missing management token permission scope {scope} referenced by {file}"
|
||||
);
|
||||
route_scopes.insert(scope);
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
!route_scopes.is_empty(),
|
||||
"admin route scope scanner did not find any route signatures"
|
||||
);
|
||||
}
|
||||
|
||||
fn extract_admin_route_scopes(source: &'static str) -> BTreeSet<&'static str> {
|
||||
let mut scopes = BTreeSet::new();
|
||||
let mut remaining = source;
|
||||
|
||||
while let Some(start) = remaining.find("\"admin:") {
|
||||
let signature_start = start + 1;
|
||||
let after_start = &remaining[signature_start..];
|
||||
let Some(end) = after_start.find('"') else {
|
||||
break;
|
||||
};
|
||||
let signature = &after_start[..end];
|
||||
let mut parts = signature.split(':');
|
||||
if parts.next() == Some("admin") {
|
||||
if let (Some(scope), None) = (parts.next(), parts.next()) {
|
||||
scopes.insert(scope);
|
||||
}
|
||||
}
|
||||
remaining = &after_start[end + 1..];
|
||||
}
|
||||
|
||||
scopes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ pub(super) fn classify_oauth_route(
|
||||
"admin_proxy",
|
||||
"provider_oauth_manage",
|
||||
"batch_import_oauth",
|
||||
"admin:provider_oauth",
|
||||
"admin:pool",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
@@ -241,7 +241,7 @@ pub(super) fn classify_oauth_route(
|
||||
"admin_proxy",
|
||||
"provider_oauth_manage",
|
||||
"start_batch_import_oauth_task",
|
||||
"admin:provider_oauth",
|
||||
"admin:pool",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::GET
|
||||
@@ -252,7 +252,7 @@ pub(super) fn classify_oauth_route(
|
||||
"admin_proxy",
|
||||
"provider_oauth_manage",
|
||||
"get_batch_import_task_status",
|
||||
"admin:provider_oauth",
|
||||
"admin:pool",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use http::Uri;
|
||||
|
||||
use crate::control::management_token_required_permission;
|
||||
|
||||
use super::{classify_control_route, headers};
|
||||
|
||||
#[test]
|
||||
@@ -66,7 +68,11 @@ fn classifies_admin_provider_oauth_batch_import_task_status_as_admin_proxy_route
|
||||
);
|
||||
assert_eq!(
|
||||
decision.auth_endpoint_signature.as_deref(),
|
||||
Some("admin:provider_oauth")
|
||||
Some("admin:pool")
|
||||
);
|
||||
assert_eq!(
|
||||
management_token_required_permission(&http::Method::GET, &decision).as_deref(),
|
||||
Some("admin:pool:read")
|
||||
);
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
@@ -74,51 +80,69 @@ fn classifies_admin_provider_oauth_batch_import_task_status_as_admin_proxy_route
|
||||
#[test]
|
||||
fn classifies_admin_provider_oauth_maintenance_routes_as_admin_proxy_route() {
|
||||
let headers = headers(&[]);
|
||||
for (method, path, route_kind) in [
|
||||
for (method, path, route_kind, expected_signature, expected_required_permission) in [
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/keys/key-123/complete",
|
||||
"complete_key_oauth",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/keys/key-123/refresh",
|
||||
"refresh_key_oauth",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/complete",
|
||||
"complete_provider_oauth",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/import-refresh-token",
|
||||
"import_refresh_token",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/batch-import",
|
||||
"batch_import_oauth",
|
||||
"admin:pool",
|
||||
"admin:pool:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/batch-import/tasks",
|
||||
"start_batch_import_oauth_task",
|
||||
"admin:pool",
|
||||
"admin:pool:write",
|
||||
),
|
||||
(
|
||||
http::Method::GET,
|
||||
"/api/admin/provider-oauth/providers/provider-123/batch-import/tasks/task-123",
|
||||
"get_batch_import_task_status",
|
||||
"admin:pool",
|
||||
"admin:pool:read",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/device-authorize",
|
||||
"device_authorize",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
(
|
||||
http::Method::POST,
|
||||
"/api/admin/provider-oauth/providers/provider-123/device-poll",
|
||||
"device_poll",
|
||||
"admin:provider_oauth",
|
||||
"admin:provider_oauth:write",
|
||||
),
|
||||
] {
|
||||
let uri: Uri = path.parse().expect("uri should parse");
|
||||
@@ -133,7 +157,11 @@ fn classifies_admin_provider_oauth_maintenance_routes_as_admin_proxy_route() {
|
||||
assert_eq!(decision.route_kind.as_deref(), Some(route_kind));
|
||||
assert_eq!(
|
||||
decision.auth_endpoint_signature.as_deref(),
|
||||
Some("admin:provider_oauth")
|
||||
Some(expected_signature)
|
||||
);
|
||||
assert_eq!(
|
||||
management_token_required_permission(&method, &decision).as_deref(),
|
||||
Some(expected_required_permission)
|
||||
);
|
||||
assert!(!decision.is_execution_runtime_candidate());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user