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

Add missing shared recovery cli commands #9100

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

AureliaDolo
Copy link
Contributor

@AureliaDolo AureliaDolo commented Dec 3, 2024

Fix #8672

TODO

  • list
  • info
  • remove
  • test list
  • test info
  • test remove
  • end to end manual test

End to end test scenario:

  • assert alice's shared recovery info is never setup echo P@ssw0rd. | target/debug/parsec-cli shared-recovery info --password-stdin -d a79

  • setup shared recovery for alice, bob and toto, with the two other users as recipient, with threshold = 1 echo P@ssw0rd. | target/debug/parsec-cli shared-recovery create --password-stdin -d 932 -t 1 -r [email protected] [email protected]

    in the current test_env organization, toto is external, so he can't access alice's and bob's informations, so he needs to rely on the default shamir recipients (ie all admins = just alice)

  • assert alice's shared recovery info is setup

  • assert alice's shared recovery list has bob's and toto's setup listed echo P@ssw0rd. | target/debug/parsec-cli shared-recovery list --password-stdin -d a79

  • remove alice's setup echo P@ssw0rd. | target/debug/parsec-cli shared-recovery delete --password-stdin -d a79

  • assert alice's shared recovery info is deleted

  • assert bob's shared recovery list has toto's setup setup and alice's deleted

  • setup shared recovery for alice with the same args as before

  • assert alice's shared recovery info is setup

  • revoke toto

  • assert alice's shared recovery info is warning that a recipient is revoked

  • assert bob's shared recovery list has alice's warning that a recipient is revoked

  • revoke bob

  • assert alice's shared recovery info is warning that a recipient is unusable

  • assert bob's shared recovery list has alice's setup unusable

how to revoke

This section describe how to test revocation for now, as the cli command for revocation is not exposed (see #9143). Make sure to close/kill EVERY instance of parsec and testbed that's laying around before starting.

  • run a testbed server in a separated terminal
  • in a separated terminal run the testenv for the cli
  • in a separated terminal open the GUI (this part will become unnecessary)
    • export the variable in the output of the cli testenv (so this parsec will use the test organization, not your real data)
    • cd client
    • npm install
    • cd electron
    • npm install
    • npx electron . --no-sandbox
  • check that both the gui and the cli connect to the same organization (by creating a workspace on one side and checking it exists on the other side

    Note that to connect to the gui, you're using one device, so if you don't want to close the gui to use the cli, you'll need to use alice's other device

  • cli : setup alice's shared recovery
  • gui: revoke toto
  • cli: check alice's shared recovery

@AureliaDolo AureliaDolo marked this pull request as ready for review December 4, 2024 10:49
@AureliaDolo AureliaDolo requested a review from a team as a code owner December 4, 2024 10:49
cli/src/commands/shared_recovery/delete.rs Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@FirelightFlagboy FirelightFlagboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command shared-recovery create is often called in the tests,
Could its logic be extracted in a helpers that could be used without using the CLI ?


#[rstest::rstest]
#[tokio::test]
async fn remove_shared_recovery_ok(tmp_path: TmpPath) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to limit call to the cli, each call add 2sec (on my machine) to the test duration.

Here some call could be removed since they're tested elsewhere (I think of the 2 info command)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed the cli tests do not use the testbed pre-configured organization. Those would solve the slowness you are mentioning. I suggest we:

  • factor test initialization into a fixture (i.e. the creation of shamir recoveries)
  • create an issue to migrate the cli tests to the testbed pre-configured organization

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created the corresponding issue: #9144

Comment on lines +19 to +28
crate::assert_cmd_success!(
with_password = DEFAULT_DEVICE_PASSWORD,
"shared-recovery",
"list",
"--device",
&bob.device_id.hex()
)
.stdout(predicates::str::contains("No shared recovery found"));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
crate::assert_cmd_success!(
with_password = DEFAULT_DEVICE_PASSWORD,
"shared-recovery",
"list",
"--device",
&bob.device_id.hex()
)
.stdout(predicates::str::contains("No shared recovery found"));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why this chink should be delted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@vxgmichel vxgmichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of suggestions, LGTM otherwise 👍

cli/src/commands/shared_recovery/create.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/delete.rs Show resolved Hide resolved
cli/src/commands/shared_recovery/delete.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/info.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/list.rs Outdated Show resolved Hide resolved
Comment on lines +46 to +55
crate::assert_cmd_success!(
with_password = DEFAULT_DEVICE_PASSWORD,
"shared-recovery",
"info",
"--device",
&alice.device_id.hex()
)
.stdout(predicates::str::contains(format!(
"Shared recovery {GREEN}set up{RESET}"
)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be done without using the CLI ?

Copy link
Contributor

@vxgmichel vxgmichel Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FirelightFlagboy

Could this be done without using the CLI ?

Personally I'd rather have more CLI testing than less, even though this test is meant to test another command than shared-recovery info.

I understand this is a trade-off between unit tests being more "unit" and more test coverage, and I tend to choose the latter.

Copy link
Contributor

@vxgmichel vxgmichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better, thanks 👍

cli/src/commands/shared_recovery/list.rs Outdated Show resolved Hide resolved
cli/src/commands/shared_recovery/list.rs Outdated Show resolved Hide resolved
cli/tests/integration/shared_recovery/mod.rs Outdated Show resolved Hide resolved
Comment on lines +46 to +55
crate::assert_cmd_success!(
with_password = DEFAULT_DEVICE_PASSWORD,
"shared-recovery",
"info",
"--device",
&alice.device_id.hex()
)
.stdout(predicates::str::contains(format!(
"Shared recovery {GREEN}set up{RESET}"
)));
Copy link
Contributor

@vxgmichel vxgmichel Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FirelightFlagboy

Could this be done without using the CLI ?

Personally I'd rather have more CLI testing than less, even though this test is meant to test another command than shared-recovery info.

I understand this is a trade-off between unit tests being more "unit" and more test coverage, and I tend to choose the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Shamir port] CLI commands
4 participants