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-11894] update password generator policy #948

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

aj-rosado
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-11894

📔 Objective

Renaming property defaultValue to overridePasswordType as it is the name used on the other clients
Updating the behaviour so that it forces the user to use the overridePasswordType on the password generator

📸 Screenshots

Screen.Recording.2024-09-18.at.17.39.41.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Sep 18, 2024

Logo
Checkmarx One – Scan Summary & Detailsa2e7f755-2da4-4077-81a2-0f397837f026

No New Or Fixed Issues Found

@@ -10,7 +10,7 @@ enum PolicyOptionType: String {
case capitalize

/// A policy option for the default type of the password generator.
case defaultType
case overridePasswordType
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ The documentation comment should probably be updated as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

BitwardenShared/Core/Vault/Services/PolicyService.swift Outdated Show resolved Hide resolved
@@ -48,6 +48,9 @@ struct PasswordGenerationOptions: Codable, Equatable {

/// The separator to put between words in the passphrase.
var wordSeparator: String?

/// Whether the password type should be enforced or not
var overridePasswordType: Bool?
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Why is this boolean optional? What does a nil value represent as different from a false value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should never be nil actually, removed the optional

Copy link
Contributor Author

@aj-rosado aj-rosado Sep 19, 2024

Choose a reason for hiding this comment

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

Actually, this is making the test_decode_empty on PasswordGenerationOptionsTests to fail.

I'm afraid it might throw an exception when calling the decodePasswordOptions and there is no overridePasswordType.

Not sure on what scenarios this is used

Copy link
Collaborator

Choose a reason for hiding this comment

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

This model is persisted to UserDefaults to maintain the user's options between app runs. The optional bool allows decoding to succeed even if it doesn't exist in the previously persisted model.

}
// if the stringValue is NOT emptu or null, overridePasswordType should be true
options.overridePasswordType = !(policy[.overridePasswordType]?.stringValue?.isEmpty ?? true)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Maybe I'm misunderstanding the logic, but doesn't putting this here mean that the options.overridePasswordType != true on line 187 will always be true for the first policy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right I messed up here.
It would work for most of the scenario but would fail on some edge cases. Fixed it and changed tests in order to catch this.

Copy link
Contributor

@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

Seems reasonable so far, but we'll want to make a change so we don't have failing tests.

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.68%. Comparing base (753e539) to head (2f1ff82).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #948   +/-   ##
=======================================
  Coverage   88.68%   88.68%           
=======================================
  Files         622      622           
  Lines       39374    39374           
=======================================
  Hits        34918    34918           
  Misses       4456     4456           

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

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