Skip to content

Add forget all certificates & poll to client CLI#10017

Merged
touilleMan merged 12 commits intomasterfrom
cli-forget_all_certificates
Apr 1, 2025
Merged

Add forget all certificates & poll to client CLI#10017
touilleMan merged 12 commits intomasterfrom
cli-forget_all_certificates

Conversation

@touilleMan
Copy link
Copy Markdown
Contributor

No description provided.

@touilleMan touilleMan requested review from a team as code owners March 27, 2025 16:12
Copy link
Copy Markdown
Contributor

@AureliaDolo AureliaDolo left a comment

Choose a reason for hiding this comment

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

A few nits but otherwise LGTM

Comment on lines +19 to +21
println!("You are about to clear the local certificates database for device:");
println!("{YELLOW}{short_id}{RESET} - {organization_id}: {human_handle} @ {device_label}");
println!("Are you sure? (y/n)");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want to be shinny, you can use the Confirm prompt from dialogue like here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm all okay for additional shininess, though I'd rather not do this change in this PR

This is because I've copied this code from another command, so it should also be modified

So I've opened issue #10020

crate::build_main_with_client!(main, poll);

pub async fn poll(_args: Args, client: &StartedClient) -> anyhow::Result<()> {
let mut spinner = start_spinner("Poll server for new certificates".into());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here is an helper

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I used it initially, however this helper doesn't display the number of new certificates

I think not showing the number of new certificates is fine when the poll is a side task, but for this CLI command it is the main thing so reporting is a good thing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The function could easily updated to return the number of certificate

&self,
latest_known_timestamps: Option<&PerTopicLastTimestamps>,
) -> Result<(), CertifPollServerError> {
) -> Result<usize, CertifPollServerError> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's that number ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

returns the number of new certificates

I've added a comment (there was already one for Client::poll_server_for_new_certificates but not for CertficateOps::poll_server_for_new_certificates

let alice = env.local_device("alice@dev1");
let ops = certificates_ops_factory(env, &alice).await;

let add_first_certifcate = async || {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let add_first_certifcate = async || {
let add_first_certificate = async || {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 done.

@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch 2 times, most recently from 709182a to 5111633 Compare March 27, 2025 21:30
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from 5111633 to 1e5b8d5 Compare March 27, 2025 21:49
Comment thread client/src/parsec/login.ts Outdated
return { ok: true, value: null };
return {
ok: true,
// @ts-ignore: Too cumbersome to create a full `AvailableDevice` object,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can just c/c from

It may be easier than trying to trick the linter.
This code will be gone very soon anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks 🙏

Copy link
Copy Markdown
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.

Missing newsfragment

touilleMan added a commit that referenced this pull request Mar 28, 2025
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from 1e5b8d5 to 871bd18 Compare March 28, 2025 08:22
@touilleMan
Copy link
Copy Markdown
Contributor Author

@FirelightFlagboy I've added the newsfragment 🙏

touilleMan added a commit that referenced this pull request Mar 28, 2025
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from 871bd18 to 848bd0a Compare March 28, 2025 08:32
Copy link
Copy Markdown
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.

  • Missing test for cli change-authentication
  • Missing test for cli overwrite-server-url

Comment on lines +10 to +13
#[clap(long, short, action)]
password: bool,
#[clap(long, short, action)]
keyring: bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (blocking): Use a enum instead that simply the pattern matching

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've created issue #10028 to track this, since we want to also standardize the other CLI commands

@touilleMan
Copy link
Copy Markdown
Contributor Author

@FirelightFlagboy I've added a test for each new CLI command (and I found an error in the naming of a command thank this them ^^)

Comment thread libparsec/crates/platform_device_loader/src/web/mod.rs
Comment thread libparsec/crates/platform_device_loader/src/lib.rs
Comment thread cli/src/commands/device/overwrite_server_url.rs

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

Choose a reason for hiding this comment

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

issue (blocking): The test is not complete, we need to check if the device can be unlocked with the new authentication

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 👍


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

Choose a reason for hiding this comment

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

todo: Add a todo comment about inspecting the info of the device via device info (command not exiting for now)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

touilleMan added a commit that referenced this pull request Mar 28, 2025
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from bd0cf68 to 2f543ca Compare March 28, 2025 16:08
touilleMan added a commit that referenced this pull request Mar 28, 2025
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from 2f543ca to d432b0d Compare March 28, 2025 16:26
touilleMan added a commit that referenced this pull request Mar 29, 2025
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from d432b0d to 0f11f1e Compare March 29, 2025 13:38
@touilleMan touilleMan force-pushed the cli-forget_all_certificates branch from 0f11f1e to f650a0b Compare April 1, 2025 12:23
@touilleMan touilleMan added this pull request to the merge queue Apr 1, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Apr 1, 2025
Merged via the queue into master with commit 7c77b60 Apr 1, 2025
15 checks passed
@touilleMan touilleMan deleted the cli-forget_all_certificates branch April 1, 2025 13:06
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.

5 participants