Skip to content

Commit

Permalink
Authenticator refactor (#486)
Browse files Browse the repository at this point in the history
* Tidy sync flags.

* Tweak doc comments.

* Prune obsolete code.

* Remove NO_SYNC flag from authenticator.

* Support options in create_folder().

* Rename methods in VaultAccess.

* Tidy functions for flag access and doc comments.

* Support setting vault flags in VaultAccess.

* Respect SetVaultFlags event in folder reducer.

* Add test spec for set_vault_flags().

* Expose update_folder_flags() in Account.

* Support remove_local_folder().

To delete a folder, not apply the AccountEvent::DeleteFolder event to
the account logs so the folder will not be deleted from other devices
and the network implementation does not need to sync.

This is for folders which need special handling such as an authenticator
folder.

* Add initial NO_SYNC test spec.

* Test for is_sync_disabled() when building UpdateSet.

* Test for is_sync_disabled() when building sync diff.

* Add test spec for NO_SYNC flag.

* Bump patch version.
  • Loading branch information
tmpfs committed Jul 7, 2024
1 parent befb705 commit f95a532
Show file tree
Hide file tree
Showing 63 changed files with 762 additions and 328 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/integration_tests/tests/audit_trail/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ async fn simulate_session(
// Create a new folder
let FolderCreate {
folder: new_folder, ..
} = account.create_folder("New folder".to_string()).await?;
} = account
.create_folder("New folder".to_string(), Default::default())
.await?;
// Rename the folder
account
.rename_folder(&new_folder, "New name".to_string())
Expand Down
4 changes: 3 additions & 1 deletion crates/integration_tests/tests/diff_merge/folder_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ async fn diff_merge_folder_create() -> Result<()> {
// Create a new folder
let FolderCreate {
folder: summary, ..
} = local.create_folder("new_folder".to_owned()).await?;
} = local
.create_folder("new_folder".to_owned(), Default::default())
.await?;

assert_ne!(local.sync_status().await?, remote.sync_status().await?);

Expand Down
4 changes: 3 additions & 1 deletion crates/integration_tests/tests/diff_merge/folder_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ async fn diff_merge_folder_delete() -> Result<()> {
// Create a new folder
let FolderCreate {
folder: summary, ..
} = local.create_folder("new_folder".to_owned()).await?;
} = local
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Delete the folder
local.delete_folder(&summary).await?;
Expand Down
4 changes: 3 additions & 1 deletion crates/integration_tests/tests/diff_merge/folder_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ async fn diff_merge_folder_import() -> Result<()> {
temp.sign_in(&key).await?;
let FolderCreate {
folder: summary, ..
} = temp.create_folder("new_folder".to_owned()).await?;
} = temp
.create_folder("new_folder".to_owned(), Default::default())
.await?;
let (folder_password, _) = generate_passphrase()?;
let folder_key: AccessKey = folder_password.into();
let exported = data_dir_export.join("exported.vault");
Expand Down
4 changes: 3 additions & 1 deletion crates/integration_tests/tests/diff_merge/secret_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ async fn diff_merge_secret_move() -> Result<()> {
// Create a new folder
let FolderCreate {
folder: summary, ..
} = local.create_folder("new_folder".to_owned()).await?;
} = local
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Move the secret
let SecretMove { id: new_id, .. } = local
Expand Down
5 changes: 3 additions & 2 deletions crates/integration_tests/tests/event_log/account_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ async fn event_log_account() -> Result<()> {
// Create a folder
let commit = event_log.tree().last_commit();
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;

let event = last_log_event(&mut event_log, commit.as_ref()).await?;
assert!(matches!(event, Some(AccountEvent::CreateFolder(_, _))));
Expand Down
5 changes: 3 additions & 2 deletions crates/integration_tests/tests/event_log/file_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ async fn event_log_file() -> Result<()> {

// Create a folder so we can move the secret
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;

// Create an external file secret
let (meta, secret, _file_path) = mock::file_text_secret()?;
Expand Down
5 changes: 4 additions & 1 deletion crates/integration_tests/tests/file_transfers/abort_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ async fn file_transfers_abort_move() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Create an external file secret
let (secret_id, _, _, file_name) =
Expand Down
5 changes: 4 additions & 1 deletion crates/integration_tests/tests/file_transfers/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ async fn file_transfers_attach_move() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Moving the secret also needs to move the files
let SecretMove { id: secret_id, .. } = device
Expand Down
5 changes: 4 additions & 1 deletion crates/integration_tests/tests/file_transfers/late_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ async fn file_transfers_late_upload() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;
let SecretMove { id: secret_id, .. } = device
.owner
.move_secret(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ async fn file_transfers_multi_move() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Moving the secret also needs to move the file
let SecretMove { id: secret_id, .. } = device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ async fn file_transfers_offline_multi_move() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Moving the secret also needs to move the file
let SecretMove { id: secret_id, .. } = device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ async fn file_transfers_single_move() -> Result<()> {
let FolderCreate {
folder: destination,
..
} = device.owner.create_folder("new_folder".to_owned()).await?;
} = device
.owner
.create_folder("new_folder".to_owned(), Default::default())
.await?;

// Moving the secret also needs to move the file
let SecretMove { id: secret_id, .. } = device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ async fn local_account_statistics() -> Result<()> {

// Create a folder and add a secret to the folder
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;
let (login_password, _) = generate_passphrase()?;
let (mut meta, secret) = mock::login("login", TEST_ID, login_password);
meta.set_favorite(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ async fn assert_move_file_secret(
let FolderCreate {
folder: destination,
..
} = account.create_folder(new_folder_name).await?;
} = account
.create_folder(new_folder_name, Default::default())
.await?;

let SecretMove { id: new_id, .. } = account
.move_secret(
Expand Down Expand Up @@ -400,7 +402,9 @@ async fn assert_create_update_move_file_secret(
let FolderCreate {
folder: destination,
..
} = account.create_folder(new_folder_name).await?;
} = account
.create_folder(new_folder_name, Default::default())
.await?;

let (new_secret_data, _) = update_file_secret(
account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ async fn local_folder_lifecycle() -> Result<()> {

// Create a folder
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;

// Open the new folder for writing
account.open_folder(&folder).await?;
Expand Down
5 changes: 3 additions & 2 deletions crates/integration_tests/tests/local_account/move_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ async fn local_move_secret() -> Result<()> {

// Create a folder
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;

// Move to the new folder
account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ async fn local_search_view_query() -> Result<()> {

// Create a folder and add secrets to the other folder
let folder_name = "folder_name";
let FolderCreate { folder, .. } =
account.create_folder(folder_name.to_string()).await?;
let FolderCreate { folder, .. } = account
.create_folder(folder_name.to_string(), Default::default())
.await?;

account.open_folder(&folder).await?;
account.insert_secrets(new_folder_docs).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async fn network_sync_listen_folder_create() -> Result<()> {
..
} = device1
.owner
.create_folder("sync_folder".to_string())
.create_folder("sync_folder".to_string(), Default::default())
.await?;
assert!(sync_error.is_none());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async fn network_sync_listen_folder_delete() -> Result<()> {
..
} = device1
.owner
.create_folder("sync_folder".to_string())
.create_folder("sync_folder".to_string(), Default::default())
.await?;
assert!(sync_error.is_none());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async fn network_sync_listen_folder_import() -> Result<()> {
..
} = device1
.owner
.create_folder("sync_folder".to_string())
.create_folder("sync_folder".to_string(), Default::default())
.await?;
assert!(sync_error.is_none());

Expand Down
2 changes: 2 additions & 0 deletions crates/integration_tests/tests/network_account/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ mod listen_multiple;
mod multiple_remotes;
mod multiple_remotes_fallback;

mod no_sync;

mod offline_manual;
mod rename_account;
mod server_definitions;
Expand Down
Loading

0 comments on commit f95a532

Please sign in to comment.