mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(kiro): 隐藏 OAuth 刷新重试流程 (#339)
This commit is contained in:
@@ -241,6 +241,7 @@ mod tests {
|
||||
transport.key.decrypted_auth_config = Some(
|
||||
r#"{
|
||||
"access_token":"cached-token",
|
||||
"expires_at":4102444800,
|
||||
"refresh_token":"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
|
||||
"machine_id":"123e4567-e89b-12d3-a456-426614174000",
|
||||
"api_region":"us-west-2"
|
||||
@@ -261,6 +262,7 @@ mod tests {
|
||||
transport.key.decrypted_auth_config = Some(
|
||||
r#"{
|
||||
"access_token":"cached-token",
|
||||
"expires_at":4102444800,
|
||||
"refresh_token":"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
|
||||
"machine_id":"123e4567-e89b-12d3-a456-426614174000",
|
||||
"api_region":"us-west-2"
|
||||
@@ -295,6 +297,22 @@ mod tests {
|
||||
assert!(resolve_local_kiro_request_auth(&transport).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skips_refreshable_cached_access_token_without_expiry() {
|
||||
let mut transport = sample_transport();
|
||||
transport.key.decrypted_api_key = "__placeholder__".to_string();
|
||||
transport.key.decrypted_auth_config = Some(
|
||||
r#"{
|
||||
"access_token":"cached-token-without-expiry",
|
||||
"refresh_token":"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"
|
||||
}"#
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
assert!(resolve_local_kiro_request_auth(&transport).is_none());
|
||||
assert!(supports_local_kiro_request_auth_resolution(&transport));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refreshable_expired_cached_access_token_does_not_fallback_to_decrypted_api_key() {
|
||||
let mut transport = sample_transport();
|
||||
|
||||
@@ -141,7 +141,7 @@ impl KiroAuthConfig {
|
||||
|
||||
pub fn cached_access_token_requires_refresh(&self, skew_seconds: u64) -> bool {
|
||||
let Some(expires_at) = self.expires_at else {
|
||||
return false;
|
||||
return self.can_refresh_access_token();
|
||||
};
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
||||
Reference in New Issue
Block a user