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

[PM-3436] Username generator #285

Merged
merged 21 commits into from
Dec 18, 2023
Merged

Conversation

dani-garcia
Copy link
Member

Type of change

- [ ] Bug fix
- [x] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Implement username generation.

Some of the methods are shared with password and passphrase generation (like capitalize_first_letter, random_lowercase_string and the username word generation). To avoid dependencies between the PRs, I included them here again, once we're done with all the generators I'll unify them.

@bitwarden-bot
Copy link

bitwarden-bot commented Oct 13, 2023

Logo
Checkmarx One – Scan Summary & Detailsa1635293-230a-430e-9c76-4d30027be3f8

No New Or Fixed Issues Found

@dani-garcia dani-garcia requested a review from Hinton December 11, 2023 14:55
Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

Looks good, a few comments. Would be nice if we either in this PR or a followup write some integration tests for the external forwarders, i.e. mock the response.

We should consider if there is an easy way to have e2e tests for this to, and call the external services.

crates/bitwarden-uniffi/src/tool/mod.rs Show resolved Hide resolved
crates/bitwarden/src/client/client.rs Show resolved Hide resolved
crates/bitwarden/src/tool/generators/username.rs Outdated Show resolved Hide resolved
crates/bitwarden/src/tool/generators/username.rs Outdated Show resolved Hide resolved
crates/bitwarden/src/tool/generators/username.rs Outdated Show resolved Hide resolved
Comment on lines 23 to 27
let description = website
.as_ref()
.map(|w| format!("{w} - "))
.unwrap_or_default();
let description = format!("{description}Generated by Bitwarden.");
Copy link
Member

Choose a reason for hiding this comment

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

We seem to be duplicating this in many of the handlers. Should we pre-process this as part of the input?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've extracted it to a function at least, as not all the services use it. I've noticed that at the moment Firefox is using a slightly different message. I don't know if that matters, but I defined a separate function for it.

crates/bitwarden/src/tool/generators/username.rs Outdated Show resolved Hide resolved
crates/bitwarden/src/tool/generators/username.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 131 lines in your changes are missing coverage. Please review.

Comparison is base (c8a1d77) 40.02% compared to head (c807432) 45.45%.

Files Patch % Lines
crates/bitwarden/src/tool/generators/username.rs 66.94% 39 Missing ⚠️
...rc/tool/generators/username_forwarders/fastmail.rs 80.89% 30 Missing ⚠️
...ool/generators/username_forwarders/forwardemail.rs 85.36% 24 Missing ⚠️
crates/bitwarden-uniffi/src/tool/mod.rs 0.00% 10 Missing ⚠️
...src/tool/generators/username_forwarders/firefox.rs 91.39% 8 Missing ⚠️
...tool/generators/username_forwarders/simplelogin.rs 90.80% 8 Missing ⚠️
.../bitwarden/src/tool/generators/client_generator.rs 0.00% 4 Missing ⚠️
.../tool/generators/username_forwarders/duckduckgo.rs 93.75% 4 Missing ⚠️
crates/bitwarden/src/client/client.rs 0.00% 3 Missing ⚠️
.../src/tool/generators/username_forwarders/addyio.rs 99.09% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   40.02%   45.45%   +5.43%     
==========================================
  Files         141      149       +8     
  Lines        5947     6771     +824     
==========================================
+ Hits         2380     3078     +698     
- Misses       3567     3693     +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dani-garcia dani-garcia requested a review from Hinton December 18, 2023 12:20
Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

Generally looks good, would have liked if the forwarder tests could verify the error conditions to.

Comment on lines +16 to +22
fn format_description_ff(website: &Option<String>) -> String {
let description = website
.as_ref()
.map(|w| format!("{w} - "))
.unwrap_or_default();
format!("{description}Generated by Bitwarden.")
}
Copy link
Member

Choose a reason for hiding this comment

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

@kspearrin do you remember why Firefox forwarder uses a different description than the other formatters?

Copy link
Member

Choose a reason for hiding this comment

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

I do not, sorry.

Copy link
Member

Choose a reason for hiding this comment

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

👍, let's keep it for now but with the knowledge we can revisit this in the future.

@dani-garcia dani-garcia merged commit 4c079e8 into main Dec 18, 2023
42 checks passed
@dani-garcia dani-garcia deleted the ps/pm-3436-username-generator branch December 18, 2023 17:08
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.

4 participants