Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
103 lines
3.2 KiB
Rust
103 lines
3.2 KiB
Rust
//! Tests native cause classification without touching the real keyring.
|
|
|
|
use super::*;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn preserves_typed_causes_without_guessing_from_messages() {
|
|
let cases = [
|
|
(
|
|
keyring::Error::NoStorageAccess(Box::new(std::io::Error::other(
|
|
"locked timeout access denied",
|
|
))),
|
|
ErrorKind::Other,
|
|
),
|
|
(
|
|
keyring::Error::PlatformFailure(Box::new(std::io::Error::new(
|
|
ErrorKind::TimedOut,
|
|
"private account",
|
|
))),
|
|
ErrorKind::TimedOut,
|
|
),
|
|
(
|
|
keyring::Error::PlatformFailure(Box::new(std::sync::Arc::new(std::io::Error::new(
|
|
ErrorKind::PermissionDenied,
|
|
"private D-Bus socket",
|
|
)))),
|
|
ErrorKind::PermissionDenied,
|
|
),
|
|
(
|
|
keyring::Error::Invalid("private account".into(), "private reason".into()),
|
|
ErrorKind::Other,
|
|
),
|
|
];
|
|
for (error, expected) in cases {
|
|
let error = std::io::Error::from(CredentialStoreError::new(error));
|
|
assert_eq!(error.kind(), expected);
|
|
assert!(
|
|
error
|
|
.get_ref()
|
|
.unwrap()
|
|
.downcast_ref::<CredentialStoreError>()
|
|
.is_some()
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn classifies_native_backend_errors() {
|
|
#[cfg(target_os = "macos")]
|
|
let native: Box<dyn Error + Send + Sync> = Box::new(
|
|
security_framework::base::Error::from_code(/*code*/ -25291),
|
|
);
|
|
#[cfg(target_os = "linux")]
|
|
let native: Box<dyn Error + Send + Sync> = Box::new(secret_service::Error::Locked);
|
|
#[cfg(target_os = "windows")]
|
|
let native: Box<dyn Error + Send + Sync> = Box::new(keyring::windows::Error(1312));
|
|
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
|
assert_eq!(
|
|
classify(&CredentialStoreError::new(keyring::Error::NoStorageAccess(
|
|
native
|
|
))),
|
|
if cfg!(target_os = "linux") {
|
|
ErrorKind::WouldBlock
|
|
} else {
|
|
ErrorKind::NotConnected
|
|
},
|
|
);
|
|
}
|
|
|
|
#[cfg(target_os = "linux")]
|
|
#[test]
|
|
fn unavailable_secret_service_is_not_connected() {
|
|
let error = CredentialStoreError::new(keyring::Error::PlatformFailure(Box::new(
|
|
secret_service::Error::Unavailable,
|
|
)));
|
|
assert_eq!(std::io::Error::from(error).kind(), ErrorKind::NotConnected);
|
|
}
|
|
|
|
#[cfg(target_os = "linux")]
|
|
#[test]
|
|
fn secret_service_dbus_io_error_preserves_its_kind() {
|
|
let error = secret_service::Error::Zbus(
|
|
std::io::Error::new(ErrorKind::PermissionDenied, "private D-Bus socket").into(),
|
|
);
|
|
let error = CredentialStoreError::new(keyring::Error::PlatformFailure(Box::new(error)));
|
|
assert_eq!(
|
|
std::io::Error::from(error).kind(),
|
|
ErrorKind::PermissionDenied
|
|
);
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
#[test]
|
|
fn read_only_keychain_is_permission_denied() {
|
|
let error = CredentialStoreError::new(keyring::Error::NoStorageAccess(Box::new(
|
|
security_framework::base::Error::from_code(/*code*/ -25292),
|
|
)));
|
|
assert_eq!(
|
|
std::io::Error::from(error).kind(),
|
|
ErrorKind::PermissionDenied
|
|
);
|
|
}
|