[vault] Tests: any two factors, never one; factors added and removed alone; v1 upgrade; tamper; machine store

This commit is contained in:
2026-11-02 15:45:54 +01:00
parent 4daffdff73
commit df6565941e
2 changed files with 212 additions and 1 deletions
+4 -1
View File
@@ -104,8 +104,11 @@ fn tampered_kdf_params_are_refused_before_argon2_runs() {
fn not_a_vault_and_future_versions_are_refused() {
assert!(matches!(Vault::open(b"hello world, not a vault at all", &pw("x")), Err(Error::NotAVault)));
let mut bytes = sample_vault("pw").to_bytes().unwrap();
// Version 2 exists now (docs/FACTORS.md); a v1 file relabelled as 2 is malformed, 3 is unknown.
bytes[6] = 2;
assert!(matches!(Vault::open(&bytes, &pw("pw")), Err(Error::UnsupportedVersion(2))));
assert!(matches!(Vault::open(&bytes, &pw("pw")), Err(Error::Malformed)));
bytes[6] = 3;
assert!(matches!(Vault::open(&bytes, &pw("pw")), Err(Error::UnsupportedVersion(3))));
}
fn opens_with(path: &Path, password: &str, title: &str) -> bool {