//! Verify credentials round-trip through the real platform secret store. //! //! cargo run -p dr-plat --example keyring_check //! //! Writes a test value, reads it back, deletes it. Touches nothing else. use dr_plat::{PlatformSecretStore, SecretRef, SecretStore}; fn main() { env_logger::init(); let store = PlatformSecretStore::new(); println!("store available: {}", store.is_available()); if !store.is_available() { println!("no secrets daemon — the app would run in degraded mode"); return; } let r = SecretRef::app_password("https://test.invalid", "darkroom-selftest"); let secret = "test-token-do-not-reuse"; print!("store … "); match store.store(&r, secret) { Ok(()) => println!("ok"), Err(e) => { println!("FAILED: {e}"); std::process::exit(1); } } print!("retrieve … "); match store.retrieve(&r) { Ok(v) if v == secret => println!("ok (round-tripped)"), Ok(_) => { println!("FAILED: wrong value"); std::process::exit(1); } Err(e) => { println!("FAILED: {e}"); std::process::exit(1); } } print!("delete … "); match store.delete(&r) { Ok(()) => println!("ok"), Err(e) => { println!("FAILED: {e}"); std::process::exit(1); } } print!("confirm gone … "); match store.retrieve(&r) { Err(dr_plat::SecretError::NotFound) => println!("ok"), Ok(_) => { println!("FAILED: still present after delete"); std::process::exit(1); } Err(e) => println!("unexpected: {e}"), } println!("\nplatform secret store works (FR-NC-2)"); }