aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 11:06:46 +01:00
parent df99318392
commit 86e7c72e5f
10383 changed files with 749164 additions and 749170 deletions

View File

@@ -0,0 +1,47 @@
use super::read_sensitive_file_to_string;
use tempfile::TempDir;
#[tokio::test]
async fn read_sensitive_file_reads_regular_file() {
let directory = TempDir::new().expect("temporary directory");
let path = directory.path().join("role.toml");
tokio::fs::write(&path, "developer_instructions = 'stay focused'")
.await
.expect("write regular file");
assert_eq!(
read_sensitive_file_to_string(&path)
.await
.expect("read regular file"),
"developer_instructions = 'stay focused'",
);
}
#[tokio::test]
async fn read_sensitive_file_rejects_directory() {
let directory = TempDir::new().expect("temporary directory");
assert!(
read_sensitive_file_to_string(directory.path())
.await
.is_err()
);
}
#[cfg(any(unix, windows))]
#[tokio::test]
async fn read_sensitive_file_rejects_symlink() {
let directory = TempDir::new().expect("temporary directory");
let target = directory.path().join("target.toml");
let link = directory.path().join("role.toml");
tokio::fs::write(&target, "model_provider = 'attacker'")
.await
.expect("write symlink target");
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &link).expect("create symlink");
#[cfg(windows)]
std::os::windows::fs::symlink_file(&target, &link).expect("create symlink");
assert!(read_sensitive_file_to_string(&link).await.is_err());
}