refactor: 移除 Python upstream 依赖,清理全部 legacy/Python 兼容层

- 移除 upstream_base_url 参数及 AETHER_GATEWAY_UPSTREAM 环境变量,gateway 不再需要指向 Python 宿主
- 删除所有 LEGACY_*/PYTHON_* 常量、路由组、header 定义及 sunset/phaseout 机制
- 将 legacy_gateway_bridge 重命名为 internal_gateway,executor 相关命名统一为 execution_runtime
- dev.sh 新增 Postgres/Redis 预检查,移除 upstream 相关启动参数和提示
- 新增 ai_public 路由处理器
- 全量适配 handler、test、state、control 等模块的命名和接口变更
This commit is contained in:
fawney19
2026-04-04 01:40:24 +08:00
parent 1d9c77522a
commit cbc811f6ce
484 changed files with 11046 additions and 3925 deletions

View File

@@ -400,7 +400,11 @@ pub(super) fn current_unix_secs() -> u64 {
#[cfg(test)]
mod tests {
use super::*;
use super::{
build_auth_context_cache_key, extract_request_credentials, GatewayCredentialCarrier,
GatewayPrimaryCredential, GatewayTrustedAdminHeaders, GatewayTrustedAuthHeaders,
};
use axum::http::{self, Uri};
fn uri(path: &str) -> Uri {
path.parse().expect("uri should parse")

View File

@@ -34,7 +34,7 @@ pub(super) fn derive_principal_candidate(
#[cfg(test)]
mod tests {
use super::*;
use super::{derive_principal_candidate, GatewayPrincipalCandidate};
use crate::gateway::control::auth::types::{
GatewayCredentialBundle, GatewayCredentialCarrier, GatewayExtractedCredentials,
GatewayPrimaryCredential, GatewayTrustedAuthHeaders,

View File

@@ -106,14 +106,14 @@ pub(in super::super) async fn resolve_control_decision_auth(
return Ok(ControlDecisionAuthResolution::Resolved(decision));
}
if skips_legacy_python_auth_context(&decision) {
if allows_missing_data_backed_auth_context(&decision) {
return Ok(ControlDecisionAuthResolution::Resolved(decision));
}
Ok(ControlDecisionAuthResolution::Resolved(decision))
}
fn skips_legacy_python_auth_context(decision: &GatewayControlDecision) -> bool {
fn allows_missing_data_backed_auth_context(decision: &GatewayControlDecision) -> bool {
matches!(
decision.route_kind.as_deref(),
Some("chat" | "cli" | "compact")
@@ -593,7 +593,7 @@ mod tests {
sample_snapshot("key-1", "user-1"),
)]));
let data = GatewayDataState::with_auth_api_key_repository_for_tests(repository.clone());
let state = AppState::new("http://127.0.0.1:9")
let state = AppState::new()
.expect("state should build")
.with_data_state_for_tests(data);

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
#[path = "admin/basic_families.rs"]
mod basic_families;

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_basic_family_route(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_endpoints_family_route(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_model_provider_family_route(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_observability_family_route(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_operations_family_route(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_provider_ops_routes(
method: &http::Method,

View File

@@ -1,4 +1,6 @@
use super::*;
use axum::http;
use super::{classified, ClassifiedRoute};
pub(super) fn classify_admin_system_family_route(
method: &http::Method,

View File

@@ -18,11 +18,11 @@ pub(super) fn classify_internal_route(
"/api/internal/gateway/finalize-sync" => "finalize_sync",
"/api/internal/gateway/execute-sync" => "execute_sync",
"/api/internal/gateway/execute-stream" => "execute_stream",
_ => "legacy_gateway",
_ => "unhandled",
};
Some(classified(
"internal_proxy",
"gateway_legacy",
"internal_gateway",
route_kind,
"",
false,

View File

@@ -4,82 +4,7 @@ pub(super) fn classify_oauth_route(
method: &http::Method,
normalized_path: &str,
) -> Option<ClassifiedRoute> {
if method == http::Method::GET && normalized_path == "/api/oauth/providers" {
Some(classified(
"public_support",
"oauth_public_legacy",
"providers",
"",
false,
))
} else if method == http::Method::GET && normalized_path.starts_with("/api/oauth/") {
if normalized_path.ends_with("/authorize") {
Some(classified(
"public_support",
"oauth_public_legacy",
"authorize",
"",
false,
))
} else if normalized_path.ends_with("/callback") {
Some(classified(
"public_support",
"oauth_public_legacy",
"callback",
"",
false,
))
} else {
None
}
} else if method == http::Method::GET && normalized_path == "/api/user/oauth/bindable-providers"
{
Some(classified(
"public_support",
"oauth_user_legacy",
"bindable_providers",
"",
false,
))
} else if method == http::Method::GET && normalized_path == "/api/user/oauth/links" {
Some(classified(
"public_support",
"oauth_user_legacy",
"links",
"",
false,
))
} else if method == http::Method::POST
&& normalized_path.starts_with("/api/user/oauth/")
&& normalized_path.ends_with("/bind-token")
{
Some(classified(
"public_support",
"oauth_user_legacy",
"bind_token",
"",
false,
))
} else if method == http::Method::GET
&& normalized_path.starts_with("/api/user/oauth/")
&& normalized_path.ends_with("/bind")
{
Some(classified(
"public_support",
"oauth_user_legacy",
"bind",
"",
false,
))
} else if method == http::Method::DELETE && normalized_path.starts_with("/api/user/oauth/") {
Some(classified(
"public_support",
"oauth_user_legacy",
"unbind",
"",
false,
))
} else if method == http::Method::GET && normalized_path == "/api/admin/oauth/supported-types" {
if method == http::Method::GET && normalized_path == "/api/admin/oauth/supported-types" {
Some(classified(
"admin_proxy",
"oauth_manage",

View File

@@ -1,5 +1,24 @@
use super::{classified, is_gemini_models_route, is_gemini_operation_route, ClassifiedRoute};
fn has_single_segment_after_prefix(path: &str, prefix: &str) -> bool {
let trimmed = path.trim_end_matches('/');
let Some(segment) = trimmed.strip_prefix(prefix) else {
return false;
};
!segment.is_empty() && !segment.contains('/')
}
fn has_single_nested_suffix_after_prefix(path: &str, prefix: &str, suffix: &str) -> bool {
let trimmed = path.trim_end_matches('/');
let Some(rest) = trimmed.strip_prefix(prefix) else {
return false;
};
let Some((segment, actual_suffix)) = rest.split_once('/') else {
return false;
};
!segment.is_empty() && !segment.contains('/') && actual_suffix == suffix
}
pub(super) fn classify_public_support_route(
method: &http::Method,
normalized_path: &str,
@@ -118,6 +137,7 @@ pub(super) fn classify_public_support_route(
&& normalized_path != "/api/announcements/users/me/unread-count"
&& normalized_path != "/api/announcements/users/me/unread-count/"
&& !normalized_path.ends_with("/read-status")
&& has_single_segment_after_prefix(normalized_path, "/api/announcements/")
{
Some(classified(
"public_support",
@@ -199,7 +219,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"auth_legacy",
"auth",
route_kind,
"user:auth",
false,
@@ -222,7 +242,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"dashboard_legacy",
"dashboard",
route_kind,
"user:dashboard",
false,
@@ -240,7 +260,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"monitoring_user_legacy",
"monitoring_user",
route_kind,
"user:monitoring",
false,
@@ -254,7 +274,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"announcement_user_legacy",
"announcement_user",
"unread_count",
"user:announcements",
false,
@@ -267,7 +287,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"announcement_user_legacy",
"announcement_user",
"read_all",
"user:announcements",
false,
@@ -275,10 +295,15 @@ pub(super) fn classify_public_support_route(
} else if method == http::Method::PATCH
&& normalized_path.starts_with("/api/announcements/")
&& (normalized_path.ends_with("/read-status") || normalized_path.ends_with("/read-status/"))
&& has_single_nested_suffix_after_prefix(
normalized_path,
"/api/announcements/",
"read-status",
)
{
Some(classified(
"public_support",
"announcement_user_legacy",
"announcement_user",
"read_status",
"user:announcements",
false,
@@ -305,23 +330,27 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"wallet_legacy",
"wallet",
route_kind,
"user:wallet",
false,
))
} else if method == http::Method::GET && normalized_path.starts_with("/api/wallet/recharge/") {
} else if method == http::Method::GET
&& has_single_segment_after_prefix(normalized_path, "/api/wallet/recharge/")
{
Some(classified(
"public_support",
"wallet_legacy",
"wallet",
"recharge_detail",
"user:wallet",
false,
))
} else if method == http::Method::GET && normalized_path.starts_with("/api/wallet/refunds/") {
} else if method == http::Method::GET
&& has_single_segment_after_prefix(normalized_path, "/api/wallet/refunds/")
{
Some(classified(
"public_support",
"wallet_legacy",
"wallet",
"refund_detail",
"user:wallet",
false,
@@ -339,16 +368,17 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"wallet_legacy",
"wallet",
route_kind,
"user:wallet",
false,
))
} else if method == http::Method::POST && normalized_path.starts_with("/api/payment/callback/")
} else if method == http::Method::POST
&& has_single_segment_after_prefix(normalized_path, "/api/payment/callback/")
{
Some(classified(
"public_support",
"payment_callback_legacy",
"payment_callback",
"callback",
"public:payment",
false,
@@ -387,7 +417,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
@@ -400,7 +430,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"management_tokens_list",
"user:self",
false,
@@ -419,7 +449,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
@@ -432,7 +462,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"management_tokens_create",
"user:self",
false,
@@ -443,7 +473,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"management_token_regenerate",
"user:self",
false,
@@ -451,7 +481,7 @@ pub(super) fn classify_public_support_route(
} else if method == http::Method::PATCH && normalized_path == "/api/users/me/password" {
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"password",
"user:self",
false,
@@ -462,7 +492,7 @@ pub(super) fn classify_public_support_route(
{
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"management_token_toggle",
"user:self",
false,
@@ -470,13 +500,13 @@ pub(super) fn classify_public_support_route(
} else if method == http::Method::DELETE && normalized_path == "/api/users/me/sessions/others" {
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
"sessions_others_delete",
"user:self",
false,
))
} else if matches!(method, &http::Method::PATCH | &http::Method::DELETE)
&& normalized_path.starts_with("/api/users/me/sessions/")
&& has_single_segment_after_prefix(normalized_path, "/api/users/me/sessions/")
{
let route_kind = if method == http::Method::PATCH {
"session_update"
@@ -485,7 +515,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
@@ -500,14 +530,21 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
))
} else if method == http::Method::PUT
&& (normalized_path.ends_with("/providers") || normalized_path.ends_with("/capabilities"))
&& normalized_path.starts_with("/api/users/me/api-keys/")
&& (has_single_nested_suffix_after_prefix(
normalized_path,
"/api/users/me/api-keys/",
"providers",
) || has_single_nested_suffix_after_prefix(
normalized_path,
"/api/users/me/api-keys/",
"capabilities",
))
{
let route_kind = if normalized_path.ends_with("/providers") {
"api_key_providers_update"
@@ -516,7 +553,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
@@ -524,7 +561,7 @@ pub(super) fn classify_public_support_route(
} else if matches!(
method,
&http::Method::GET | &http::Method::PUT | &http::Method::PATCH | &http::Method::DELETE
) && normalized_path.starts_with("/api/users/me/api-keys/")
) && has_single_segment_after_prefix(normalized_path, "/api/users/me/api-keys/")
{
let route_kind = match *method {
http::Method::GET => "api_key_detail",
@@ -535,7 +572,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,
@@ -543,7 +580,7 @@ pub(super) fn classify_public_support_route(
} else if matches!(
method,
&http::Method::GET | &http::Method::PUT | &http::Method::DELETE
) && normalized_path.starts_with("/api/me/management-tokens/")
) && has_single_segment_after_prefix(normalized_path, "/api/me/management-tokens/")
{
let route_kind = match *method {
http::Method::GET => "management_token_detail",
@@ -553,7 +590,7 @@ pub(super) fn classify_public_support_route(
};
Some(classified(
"public_support",
"users_me_legacy",
"users_me",
route_kind,
"user:self",
false,

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_adaptive_keys_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_api_keys_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_billing_presets_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_endpoint_health_api_formats_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_endpoint_health_summary_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_monitoring_audit_logs_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_provider_oauth_start_key_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_payments_list_orders_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_pool_overview_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_provider_ops_architectures_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_provider_query_models_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_provider_strategy_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_create_provider_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_proxy_nodes_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_security_blacklist_add_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_stats_provider_quota_usage_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_usage_stats_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_users_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_video_tasks_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_admin_wallets_list_as_admin_proxy_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_claude_count_tokens_as_non_execution_runtime_public_route() {

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_internal_tunnel_heartbeat_as_internal_proxy_route() {
@@ -29,7 +31,7 @@ fn classifies_internal_gateway_resolve_as_internal_proxy_route() {
classify_control_route(&http::Method::POST, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("internal_proxy"));
assert_eq!(decision.route_family.as_deref(), Some("gateway_legacy"));
assert_eq!(decision.route_family.as_deref(), Some("internal_gateway"));
assert_eq!(decision.route_kind.as_deref(), Some("resolve"));
assert_eq!(decision.auth_endpoint_signature.as_deref(), Some(""));
assert!(!decision.is_execution_runtime_candidate());

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, GatewayPublicRequestContext};
fn headers(items: &[(&str, &str)]) -> http::HeaderMap {
let mut headers = http::HeaderMap::new();

View File

@@ -1,4 +1,6 @@
use super::*;
use http::Uri;
use super::{classify_control_route, headers};
#[test]
fn classifies_models_list_as_public_support_route() {
@@ -174,14 +176,14 @@ fn classifies_public_announcement_detail_as_public_support_route() {
}
#[test]
fn classifies_dashboard_stats_as_public_support_legacy_route() {
fn classifies_dashboard_stats_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/dashboard/stats".parse().expect("uri should parse");
let decision =
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("dashboard_legacy"));
assert_eq!(decision.route_family.as_deref(), Some("dashboard"));
assert_eq!(decision.route_kind.as_deref(), Some("stats"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -191,7 +193,7 @@ fn classifies_dashboard_stats_as_public_support_legacy_route() {
}
#[test]
fn classifies_user_monitoring_audit_logs_as_public_support_legacy_route() {
fn classifies_user_monitoring_audit_logs_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/monitoring/my-audit-logs"
.parse()
@@ -200,10 +202,7 @@ fn classifies_user_monitoring_audit_logs_as_public_support_legacy_route() {
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("monitoring_user_legacy")
);
assert_eq!(decision.route_family.as_deref(), Some("monitoring_user"));
assert_eq!(decision.route_kind.as_deref(), Some("audit_logs"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -213,7 +212,7 @@ fn classifies_user_monitoring_audit_logs_as_public_support_legacy_route() {
}
#[test]
fn classifies_announcement_unread_count_as_public_support_legacy_route() {
fn classifies_announcement_unread_count_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/announcements/users/me/unread-count"
.parse()
@@ -222,10 +221,7 @@ fn classifies_announcement_unread_count_as_public_support_legacy_route() {
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("announcement_user_legacy")
);
assert_eq!(decision.route_family.as_deref(), Some("announcement_user"));
assert_eq!(decision.route_kind.as_deref(), Some("unread_count"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -235,7 +231,7 @@ fn classifies_announcement_unread_count_as_public_support_legacy_route() {
}
#[test]
fn classifies_announcement_read_status_as_public_support_legacy_route() {
fn classifies_announcement_read_status_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/announcements/announcement-1/read-status"
.parse()
@@ -244,10 +240,7 @@ fn classifies_announcement_read_status_as_public_support_legacy_route() {
.expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("announcement_user_legacy")
);
assert_eq!(decision.route_family.as_deref(), Some("announcement_user"));
assert_eq!(decision.route_kind.as_deref(), Some("read_status"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -257,7 +250,7 @@ fn classifies_announcement_read_status_as_public_support_legacy_route() {
}
#[test]
fn classifies_announcement_read_all_as_public_support_legacy_route() {
fn classifies_announcement_read_all_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/announcements/read-all"
.parse()
@@ -266,10 +259,7 @@ fn classifies_announcement_read_all_as_public_support_legacy_route() {
classify_control_route(&http::Method::POST, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("announcement_user_legacy")
);
assert_eq!(decision.route_family.as_deref(), Some("announcement_user"));
assert_eq!(decision.route_kind.as_deref(), Some("read_all"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -279,7 +269,7 @@ fn classifies_announcement_read_all_as_public_support_legacy_route() {
}
#[test]
fn classifies_wallet_legacy_routes_as_public_support_legacy_route() {
fn classifies_wallet_routes_as_public_support_route() {
let headers = headers(&[]);
for (method, uri, route_kind) in [
(http::Method::GET, "/api/wallet/balance", "balance"),
@@ -322,7 +312,7 @@ fn classifies_wallet_legacy_routes_as_public_support_legacy_route() {
classify_control_route(&method, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("wallet_legacy"));
assert_eq!(decision.route_family.as_deref(), Some("wallet"));
assert_eq!(decision.route_kind.as_deref(), Some(route_kind));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -333,7 +323,7 @@ fn classifies_wallet_legacy_routes_as_public_support_legacy_route() {
}
#[test]
fn classifies_users_me_legacy_routes_as_public_support_legacy_route() {
fn classifies_users_me_routes_as_public_support_route() {
let headers = headers(&[]);
for (method, uri, route_kind) in [
(http::Method::GET, "/api/users/me", "detail"),
@@ -436,7 +426,7 @@ fn classifies_users_me_legacy_routes_as_public_support_legacy_route() {
classify_control_route(&method, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("users_me_legacy"));
assert_eq!(decision.route_family.as_deref(), Some("users_me"));
assert_eq!(decision.route_kind.as_deref(), Some(route_kind));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -447,7 +437,7 @@ fn classifies_users_me_legacy_routes_as_public_support_legacy_route() {
}
#[test]
fn classifies_payment_callback_as_public_support_legacy_route() {
fn classifies_payment_callback_as_public_support_route() {
let headers = headers(&[]);
let uri: Uri = "/api/payment/callback/alipay"
.parse()
@@ -456,10 +446,7 @@ fn classifies_payment_callback_as_public_support_legacy_route() {
classify_control_route(&http::Method::POST, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("payment_callback_legacy")
);
assert_eq!(decision.route_family.as_deref(), Some("payment_callback"));
assert_eq!(decision.route_kind.as_deref(), Some("callback"));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -620,7 +607,7 @@ fn classifies_auth_settings_as_public_support_route() {
}
#[test]
fn classifies_auth_legacy_routes_as_public_support_route() {
fn classifies_auth_routes_as_public_support_route() {
for (method, path, route_kind) in [
(http::Method::POST, "/api/auth/login", "login"),
(http::Method::POST, "/api/auth/refresh", "refresh"),
@@ -645,7 +632,7 @@ fn classifies_auth_legacy_routes_as_public_support_route() {
classify_control_route(&method, &uri, &headers).expect("route should classify");
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("auth_legacy"));
assert_eq!(decision.route_family.as_deref(), Some("auth"));
assert_eq!(decision.route_kind.as_deref(), Some(route_kind));
assert_eq!(
decision.auth_endpoint_signature.as_deref(),
@@ -656,71 +643,45 @@ fn classifies_auth_legacy_routes_as_public_support_route() {
}
#[test]
fn classifies_oauth_public_providers_as_public_support_route() {
fn does_not_classify_oauth_public_providers_route() {
let headers = headers(&[]);
let uri: Uri = "/api/oauth/providers".parse().expect("uri should parse");
let decision =
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
let decision = classify_control_route(&http::Method::GET, &uri, &headers);
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("oauth_public_legacy")
);
assert_eq!(decision.route_kind.as_deref(), Some("providers"));
assert_eq!(decision.auth_endpoint_signature.as_deref(), Some(""));
assert!(!decision.is_execution_runtime_candidate());
assert!(decision.is_none());
}
#[test]
fn classifies_oauth_public_authorize_as_public_support_route() {
fn does_not_classify_oauth_public_authorize_route() {
let headers = headers(&[]);
let uri: Uri = "/api/oauth/linuxdo/authorize?client_device_id=device-1"
.parse()
.expect("uri should parse");
let decision =
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
let decision = classify_control_route(&http::Method::GET, &uri, &headers);
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(
decision.route_family.as_deref(),
Some("oauth_public_legacy")
);
assert_eq!(decision.route_kind.as_deref(), Some("authorize"));
assert_eq!(decision.auth_endpoint_signature.as_deref(), Some(""));
assert!(!decision.is_execution_runtime_candidate());
assert!(decision.is_none());
}
#[test]
fn classifies_oauth_user_bindable_providers_as_public_support_route() {
fn does_not_classify_oauth_user_bindable_providers_route() {
let headers = headers(&[]);
let uri: Uri = "/api/user/oauth/bindable-providers"
.parse()
.expect("uri should parse");
let decision =
classify_control_route(&http::Method::GET, &uri, &headers).expect("route should classify");
let decision = classify_control_route(&http::Method::GET, &uri, &headers);
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("oauth_user_legacy"));
assert_eq!(decision.route_kind.as_deref(), Some("bindable_providers"));
assert_eq!(decision.auth_endpoint_signature.as_deref(), Some(""));
assert!(!decision.is_execution_runtime_candidate());
assert!(decision.is_none());
}
#[test]
fn classifies_oauth_user_bind_token_as_public_support_route() {
fn does_not_classify_oauth_user_bind_token_route() {
let headers = headers(&[]);
let uri: Uri = "/api/user/oauth/linuxdo/bind-token"
.parse()
.expect("uri should parse");
let decision =
classify_control_route(&http::Method::POST, &uri, &headers).expect("route should classify");
let decision = classify_control_route(&http::Method::POST, &uri, &headers);
assert_eq!(decision.route_class.as_deref(), Some("public_support"));
assert_eq!(decision.route_family.as_deref(), Some("oauth_user_legacy"));
assert_eq!(decision.route_kind.as_deref(), Some("bind_token"));
assert_eq!(decision.auth_endpoint_signature.as_deref(), Some(""));
assert!(!decision.is_execution_runtime_candidate());
assert!(decision.is_none());
}
#[test]