Keep iPhone TOTP cache across installs (#78)
This commit is contained in:
@@ -306,6 +306,47 @@ fn totp_cache_reuses_ciphertext_hashes_and_removes_deleted_entries() -> TestResu
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn totp_cache_survives_application_container_relocation() -> TestResult {
|
||||
let fixture = FixtureSet::load()?;
|
||||
let application = tempfile::tempdir()?;
|
||||
let installed = application.path().join("installed");
|
||||
fs::create_dir(&installed)?;
|
||||
let vault = installed.join("vault");
|
||||
fs::rename(fixture.materialize_store("basic")?.keep(), &vault)?;
|
||||
let cache = installed.join("totp-catalog.toml");
|
||||
let keys = KeyStore::load(fixture.path("keys"))?;
|
||||
let expected = {
|
||||
let repository = Repository::open(&vault)?;
|
||||
let service = MobileTotpService::new(&repository, &keys);
|
||||
let operation = MobileTotpOperation::default();
|
||||
let mut secrets = CountingSecrets::all(&fixture);
|
||||
service.discover(&BTreeSet::new(), &mut secrets, &cache, &operation)?
|
||||
};
|
||||
|
||||
let updated = application.path().join("updated");
|
||||
fs::rename(&installed, &updated)?;
|
||||
let repository = Repository::open(updated.join("vault"))?;
|
||||
let service = MobileTotpService::new(&repository, &keys);
|
||||
let relocated_cache = updated.join("totp-catalog.toml");
|
||||
assert_eq!(
|
||||
service
|
||||
.cached_page(&BTreeSet::new(), &relocated_cache)
|
||||
.expect("relocated cache remains valid")
|
||||
.rows(),
|
||||
expected.rows()
|
||||
);
|
||||
let operation = MobileTotpOperation::default();
|
||||
let mut secrets = CountingSecrets::all(&fixture);
|
||||
service.discover(&BTreeSet::new(), &mut secrets, &relocated_cache, &operation)?;
|
||||
assert_eq!(secrets.requests, 0);
|
||||
assert_eq!(
|
||||
operation.progress().cache_hits(),
|
||||
operation.progress().total()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decrypted_entry_details_reconcile_totp_cache_without_persisting_secrets() -> TestResult {
|
||||
let fixture = FixtureSet::load()?;
|
||||
|
||||
Reference in New Issue
Block a user