Move 17 library crates into crates/, CLI binary into bin/fxt, consolidate 10 test crates into testing/, split config crate from deployment config files. Root directory reduced from 38+ to ~17 directories. All Cargo.toml paths and build.rs proto refs updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
3.0 KiB
Rust
89 lines
3.0 KiB
Rust
//! Debug test for FileTokenStorage
|
|
|
|
// Suppress false-positive unused_crate_dependencies warnings
|
|
// dev-dependencies are shared across ALL test targets in the crate
|
|
// This test may not use all deps, but they are required by other integration tests
|
|
#![allow(unused_crate_dependencies)]
|
|
|
|
use anyhow::Result;
|
|
use fxt::auth::token_manager::{FileTokenStorage, TokenStorage};
|
|
|
|
#[tokio::test]
|
|
async fn debug_file_storage() -> Result<()> {
|
|
let storage = FileTokenStorage::new()?;
|
|
|
|
println!("\n=== FileTokenStorage Debug Test ===");
|
|
|
|
// Store token
|
|
let test_token = "debug_test_token_12345";
|
|
println!("1. Storing token: {}", test_token);
|
|
|
|
match storage.store_access_token(test_token).await {
|
|
Ok(()) => println!(" ✓ Store succeeded"),
|
|
Err(e) => {
|
|
println!(" ✗ Store failed: {}", e);
|
|
return Err(e);
|
|
},
|
|
}
|
|
|
|
// Immediately retrieve
|
|
println!("2. Retrieving token immediately...");
|
|
match storage.get_access_token().await {
|
|
Ok(Some(token)) => {
|
|
println!(" ✓ Retrieved: {}", token);
|
|
assert_eq!(token, test_token, "Tokens don't match!");
|
|
},
|
|
Ok(None) => {
|
|
println!(" ✗ Retrieved None (token not found)");
|
|
|
|
// Debug: Check file paths
|
|
let token_dir = std::env::var("HOME")
|
|
.or_else(|_| std::env::var("USERPROFILE"))
|
|
.expect("Cannot find home directory")
|
|
+ "/.config/foxhunt-tli/tokens";
|
|
|
|
println!("\n3. Debug file system:");
|
|
println!(" Token dir: {}", token_dir);
|
|
|
|
// Check if directory exists
|
|
if std::path::Path::new(&token_dir).exists() {
|
|
println!(" ✓ Directory exists");
|
|
|
|
// List files
|
|
if let Ok(entries) = std::fs::read_dir(&token_dir) {
|
|
println!(" Files in directory:");
|
|
for entry in entries {
|
|
if let Ok(entry) = entry {
|
|
println!(" - {}", entry.path().display());
|
|
|
|
// Try to read the file
|
|
if let Ok(contents) = std::fs::read_to_string(entry.path()) {
|
|
println!(
|
|
" Contents (first 50 chars): {}",
|
|
&contents.chars().take(50).collect::<String>()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
println!(" ✗ Cannot list directory");
|
|
}
|
|
} else {
|
|
println!(" ✗ Directory does not exist");
|
|
}
|
|
|
|
panic!("Token retrieval returned None");
|
|
},
|
|
Err(e) => {
|
|
println!(" ✗ Retrieval failed: {}", e);
|
|
return Err(e);
|
|
},
|
|
}
|
|
|
|
// Clean up
|
|
storage.clear_access_token().await?;
|
|
println!("4. Cleanup complete");
|
|
|
|
Ok(())
|
|
}
|