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

[BWA-39] Properly generate codes for search results #119

Merged
merged 16 commits into from
Sep 24, 2024

Conversation

KatherineInCode
Copy link
Contributor

@KatherineInCode KatherineInCode commented Jun 13, 2024

🎟️ Tracking

BWA-39

📔 Objective

This fixes a bug where search results weren't generating/refreshing TOTP codes properly. This also backfills some tests.

📸 Screenshots

Simulator Screenshot - iPhone 15 Pro - 2024-06-13 at 15 43 14

⏰ 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

@KatherineInCode KatherineInCode linked an issue Jun 13, 2024 that may be closed by this pull request
1 task
Copy link
Contributor

github-actions bot commented Jun 13, 2024

Logo
Checkmarx One – Scan Summary & Details8694e7e3-3dac-453f-a448-8e6a5e07c692

No New Or Fixed Issues Found

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 86.20690% with 8 lines in your changes missing coverage. Please review.

Project coverage is 65.99%. Comparing base (4cfe64f) to head (e4459ef).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ared/Core/Platform/Services/ServiceContainer.swift 0.00% 4 Missing ⚠️
...ult/Repositories/AuthenticatorItemRepository.swift 90.90% 3 Missing ⚠️
...UI/Vault/ItemList/ItemList/ItemListProcessor.swift 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   63.37%   65.99%   +2.61%     
==========================================
  Files         202      202              
  Lines        8685     8698      +13     
==========================================
+ Hits         5504     5740     +236     
+ Misses       3181     2958     -223     

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

@KatherineInCode KatherineInCode marked this pull request as ready for review September 20, 2024 18:45
@KatherineInCode KatherineInCode requested a review from a team as a code owner September 20, 2024 18:45
Copy link
Contributor

@SaintPatrck SaintPatrck left a comment

Choose a reason for hiding this comment

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

LGTM. Left a question about testing one area that may benefit from it, if it makes sense to cover.

Comment on lines +213 to +215
errorReporter.log(error: TOTPServiceError
.unableToGenerateCode("Unable to refresh TOTP code for list view item: \(item.id)"))
return item
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we test this?

Copy link
Contributor Author

@KatherineInCode KatherineInCode Sep 20, 2024

Choose a reason for hiding this comment

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

Not as far as I can tell, unfortunately. In practice I don't think we'll ever actually get here, because we don't have a itemType other than .totp at the moment, and if the type is TOTP an ItemListItem can't be created unless the key is valid. However, because the contained AuthenticatorItemView has an optional totpKey and TOTPKeyModel.init() is a failable initializer, we still have to have code to handle if those, even though in practice the nil/fail cases won't ever happen.

else {
errorReporter.log(error: TOTPServiceError
.unableToGenerateCode("Unable to refresh TOTP code for list view item: \(item.id)"))
return item
Copy link
Member

Choose a reason for hiding this comment

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

🤔 I know this scenario is highly unlikely to happen, but shouldn't we return nil here and .compactMap the result of the asyncMap? Not quite understanding why it would return the item if it can't create the TOTPKeyModel.

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 figured that it would be better to keep the item in the list with a stale code rather than have it suddenly disappear, especially because if a new type of item is added at some point, this would still return the item as-is.

@KatherineInCode KatherineInCode merged commit f1e1a7e into main Sep 24, 2024
9 checks passed
@KatherineInCode KatherineInCode deleted the bwa-39/codes-in-search branch September 24, 2024 19:49
@KatherineInCode KatherineInCode linked an issue Sep 26, 2024 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants