envseal 0.3.7

Write-only secret vault with process-level access control — post-agent secret management
Documentation
//! Scenario: concurrent listing while storing.
use envseal::keychain::MasterKey;
use envseal::vault::Vault;
use std::sync::Arc;

#[test]
fn parallel_list() {
    let dir = crate::common::vault_tempdir();
    let key = MasterKey::from_test_bytes([0x42; 32]);
    let vault = Arc::new(Vault::open_with_key(dir.path(), key).unwrap());

    // Pre-populate
    for i in 0..10 {
        vault.store(&format!("pre-{i}"), b"val", false).unwrap();
    }

    let mut handles = Vec::new();

    for i in 0..10 {
        let v = Arc::clone(&vault);
        handles.push(std::thread::spawn(move || {
            v.store(&format!("concurrent-{i}"), b"val", false).unwrap();
        }));
    }

    for _ in 0..5 {
        let v = Arc::clone(&vault);
        handles.push(std::thread::spawn(move || {
            let names = v.list().unwrap();
            assert!(!names.is_empty());
        }));
    }

    for h in handles {
        h.join().unwrap();
    }

    let final_names = vault.list().unwrap();
    assert_eq!(final_names.len(), 20);
}