Merge remote-tracking branch 'origin/main' into phase5/gpui-shell-minors

This commit is contained in:
faumaray committed 2026-10-27 22:50:14 +03:00
commit daa2111ea1
12 files changed
+191 -46

No files matched your search

+48 -2
View File
@@ -791,6 +791,11 @@ fn pair(blob: &IdentityBlob) -> (String, String) {
(blob.kind.clone(), blob.uid.clone())
}
/// How many times a sign-out's list names the identity `key` (by kind and uid).
fn times_listed(infos: &[IdentityInfo], key: &IdentityInfo) -> usize {
infos.iter().filter(|info| info.kind == key.kind && info.uid == key.uid).count()
}
/// The record of the install replaced by damaged JSON.
fn damage_the_record(store: &SqliteKeyStore, json: &str) {
let mut damaged = store.get(KIND_ACCOUNT, &record().blob_uid()).unwrap().unwrap();
@@ -1887,9 +1892,19 @@ fn a_device_key_that_carries_a_binding_is_unbound_and_keeps_the_rest_of_its_row(
};
assert!(bound(&before), "the setup binds the key");
// It is listed once, as kept: VoelinProtocol before v0.2.0 listed a key whose
// row carried the binding twice in `unbound`.
let done = install.store.sign_out(&binding().account, DeviceKeyChoice::Auto).unwrap();
assert!(done.unbound.contains(&device_key_info()), "{bound_existing_key}: {done:?}");
assert!(!done.removed.contains(&device_key_info()), "{bound_existing_key}: {done:?}");
assert_eq!(
times_listed(&done.unbound, &device_key_info()),
1,
"{bound_existing_key}: {done:?}"
);
assert_eq!(
times_listed(&done.removed, &device_key_info()),
0,
"{bound_existing_key}: {done:?}"
);
let after = named_row(&db, KIND_VOELIN, &uid);
assert!(!bound(&after), "{bound_existing_key}: unbound");
@@ -1905,6 +1920,37 @@ fn a_device_key_that_carries_a_binding_is_unbound_and_keeps_the_rest_of_its_row(
}
}
#[test]
fn a_device_key_that_carries_a_binding_is_listed_once_as_deleted_when_it_is_forgotten() {
// The same row, named by `Forget`: the sign-out unbinds it in its loop over
// the account's identities and deletes it after. It is listed once, as
// deleted; VoelinProtocol before v0.2.0 also left it in `unbound`.
for bound_existing_key in [true, false] {
let Install { store, .. } = signed_in_install(bound_existing_key);
let device_only = AccountBinding { synced: false, ..binding() };
store.put(&IdentityBlob::voelin(&key()).unwrap().with_binding(device_only)).unwrap();
let done =
store.sign_out(&binding().account, DeviceKeyChoice::Forget(key().uid())).unwrap();
assert_eq!(
times_listed(&done.removed, &device_key_info()),
1,
"{bound_existing_key}: {done:?}"
);
assert_eq!(
times_listed(&done.unbound, &device_key_info()),
0,
"{bound_existing_key}: {done:?}"
);
assert!(store.voelin_key(&key().uid()).unwrap().is_none(), "the key is deleted");
assert_eq!(store.account_record().unwrap(), None);
assert_eq!(
store.sign_out(&binding().account, DeviceKeyChoice::Auto).unwrap(),
SignOut::default()
);
}
}
#[test]
fn a_sign_out_scrubs_the_copies_it_deletes_and_leaves_the_kept_keys_in_the_file() {
// What a sign-out still deletes is a synced copy (a private key, which