mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-09 12:40:20 +08:00
fix(auth): 授权 Responses Compact 伴随端点
This commit is contained in:
@@ -170,7 +170,11 @@ pub fn api_format_permission_covers(allowed_value: &str, requested_api_format: &
|
||||
!allowed_value.is_empty()
|
||||
&& !requested_api_format.is_empty()
|
||||
&& (allowed_value == requested_api_format
|
||||
|| allowed_value == "openai:responses" && requested_api_format == "openai:search")
|
||||
|| allowed_value == "openai:responses"
|
||||
&& matches!(
|
||||
requested_api_format.as_str(),
|
||||
"openai:responses:compact" | "openai:search"
|
||||
))
|
||||
}
|
||||
|
||||
pub fn intersect_api_format_allowed_lists(left: &[String], right: &[String]) -> Vec<String> {
|
||||
@@ -269,11 +273,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn responses_permission_covers_only_its_search_companion() {
|
||||
fn responses_permission_covers_its_companion_endpoints() {
|
||||
assert!(api_format_permission_covers(
|
||||
"OPENAI:RESPONSES",
|
||||
"openai:search"
|
||||
));
|
||||
assert!(api_format_permission_covers(
|
||||
"OPENAI:RESPONSES",
|
||||
"openai:responses:compact"
|
||||
));
|
||||
assert!(api_format_permission_covers(
|
||||
"openai:search",
|
||||
"openai:search"
|
||||
@@ -282,6 +290,10 @@ mod tests {
|
||||
"openai:search",
|
||||
"openai:responses"
|
||||
));
|
||||
assert!(!api_format_permission_covers(
|
||||
"openai:responses:compact",
|
||||
"openai:responses"
|
||||
));
|
||||
assert!(!api_format_permission_covers(
|
||||
"openai:responses",
|
||||
"openai:chat"
|
||||
@@ -290,6 +302,13 @@ mod tests {
|
||||
api_format_permission_storage_aliases("openai:search"),
|
||||
vec!["openai:search".to_string(), "openai:responses".to_string()]
|
||||
);
|
||||
assert_eq!(
|
||||
api_format_permission_storage_aliases("openai:responses:compact"),
|
||||
vec![
|
||||
"openai:responses:compact".to_string(),
|
||||
"openai:responses".to_string(),
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
api_format_permission_storage_aliases("openai:responses"),
|
||||
vec!["openai:responses".to_string()]
|
||||
@@ -350,6 +369,13 @@ mod tests {
|
||||
),
|
||||
vec!["openai:search".to_string()]
|
||||
);
|
||||
assert_eq!(
|
||||
intersect_api_format_allowed_lists(
|
||||
&["openai:responses".to_string()],
|
||||
&["openai:responses:compact".to_string()],
|
||||
),
|
||||
vec!["openai:responses:compact".to_string()]
|
||||
);
|
||||
assert_eq!(
|
||||
intersect_api_format_allowed_lists(
|
||||
&["openai:search".to_string()],
|
||||
|
||||
@@ -827,7 +827,7 @@ mod tests {
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn api_format_policy_intersection_preserves_search_companion_scope() {
|
||||
fn api_format_policy_intersection_preserves_companion_scope() {
|
||||
assert_eq!(
|
||||
aether_ai_formats::intersect_api_format_allowed_lists(
|
||||
&["openai:search".to_string()],
|
||||
@@ -842,6 +842,20 @@ mod tests {
|
||||
),
|
||||
vec!["openai:search".to_string()]
|
||||
);
|
||||
assert_eq!(
|
||||
aether_ai_formats::intersect_api_format_allowed_lists(
|
||||
&["openai:responses".to_string()],
|
||||
&["openai:responses:compact".to_string()],
|
||||
),
|
||||
vec!["openai:responses:compact".to_string()]
|
||||
);
|
||||
assert_eq!(
|
||||
aether_ai_formats::intersect_api_format_allowed_lists(
|
||||
&["openai:responses:compact".to_string()],
|
||||
&["openai:responses".to_string()],
|
||||
),
|
||||
vec!["openai:responses:compact".to_string()]
|
||||
);
|
||||
assert!(aether_ai_formats::intersect_api_format_allowed_lists(
|
||||
&["openai:search".to_string()],
|
||||
&["openai:chat".to_string()],
|
||||
|
||||
Reference in New Issue
Block a user