Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logins key loss sync integration test #5885

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions testing/sync-test/src/logins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,49 @@ fn test_login_deletes(c0: &mut TestClient, c1: &mut TestClient) {
verify_missing_login(&c0.logins_store, &l2id);
}

fn test_key_loss_with_records(c0: &mut TestClient, c1: &mut TestClient) {
// This test is replicating a scenario in which the key and canary have been lost but encrypted login
// records remain in the database.
log::info!("Add some logins to client0");
let key = create_key().unwrap();

let login0 = add_login(
&c0.logins_store,
LoginEntry {
fields: LoginFields {
origin: "http://www.example.com".into(),
form_action_origin: Some("http://login.example.com".into()),
username_field: "uname".into(),
password_field: "pword".into(),
..Default::default()
},
sec_fields: SecureLoginFields {
username: "cool_username".into(),
password: "hunter2".into(),
},
},
&key,
)
.expect("add l0");
let l0id = login0.guid();

// Sync c0
log::info!("Syncing c0");

// The sync below should fail with the following error:
// "Store error: CryptoError(Crypto error: NSS error: NSS error: -8190 (decrypt SecureLoginFields))"
// This test will always fail because of the asserts in the auth crate.
let key2 = create_key().unwrap();
sync_logins(c0, &key2).expect_err("c0 sync should fail");
}

pub fn get_test_group() -> TestGroup {
TestGroup::new(
"logins",
vec![
("test_login_general", test_login_general),
("test_login_deletes", test_login_deletes),
("test_key_loss_with_records", test_key_loss_with_records),
],
)
}