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

Extract key backup engine #1578

Merged
merged 1 commit into from
Sep 27, 2022
Merged

Extract key backup engine #1578

merged 1 commit into from
Sep 27, 2022

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Sep 22, 2022

As part of implementing key backups with Rust-based CryptoSDK I need to separate out shared and distinct backup functionality in the existing codebase. In the past I have simply duplicated a class (MXCrypto, MXKeyVerificationManager) and overriden all of its methods, but this approach is not suitable for backups, because a lot more code ends up being shared (state management, enabling/disabling backups, restoring, sending http requests etc).

The approach I have chosen instead is to identify all of the code specific to native / legacy implementation and refactor it as new MXKeyBackupEngine protocol. At the moment only Native implementation exists, but in a future PR I will add the rust-based variant. It is absent from this PR to make the refactor cleaner and easier to review.

As for the refactor I have copy-pasted entire chunks of code with no or very minimal changes to avoid any regressions. There are some integration tests that cover this functionality, but given the complexity of this code it is best to be extra careful. In reviewing I recommend comparing the deleted and added chunks to confirm there are no behaviour changes.

@Anderas Anderas requested review from a team and aringenbach and removed request for a team September 22, 2022 17:07
@codecov
Copy link

codecov bot commented Sep 22, 2022

Codecov Report

Base: 12.48% // Head: 12.47% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (da216b6) compared to base (14cb2f3).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1578      +/-   ##
===========================================
- Coverage    12.48%   12.47%   -0.02%     
===========================================
  Files          521      523       +2     
  Lines        84974    85079     +105     
  Branches     36180    36226      +46     
===========================================
+ Hits         10610    10612       +2     
- Misses       73977    74081     +104     
+ Partials       387      386       -1     
Impacted Files Coverage Δ
...K/Crypto/KeyBackup/Engine/MXKeyBackupPayload.swift 0.00% <0.00%> (ø)
.../Crypto/KeyBackup/Engine/MXNativeKeyBackupEngine.m 0.00% <0.00%> (ø)
MatrixSDK/Crypto/KeyBackup/MXKeyBackup.m 0.00% <0.00%> (ø)
MatrixSDK/Crypto/MXCrypto.m 2.02% <0.00%> (-0.01%) ⬇️
MatrixSDK/MXRestClient.m 2.48% <0.00%> (-0.01%) ⬇️
MatrixSDKTests/MXBaseKeyBackupTests.m 0.00% <0.00%> (ø)
MatrixSDK/Utils/MXHTTPClient.m 30.39% <0.00%> (ø)
MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m 76.59% <0.00%> (+4.25%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Anderas
Copy link
Contributor Author

Anderas commented Sep 23, 2022

@aringenbach it seems that codecov has made reviewing this PR quite difficult, in that it annotates almost every line of the refactor. I can disable codecov for the purpose of the review, unless you have some other flow of reviewing (e.g. from local command line)

Copy link
Contributor

@aringenbach aringenbach left a comment

Choose a reason for hiding this comment

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

@Anderas No worries I reviewed locally instead.

Code LGTM 👍

@param crypto the related 'MXCrypto'.
@param engine backup engine that stores and manages keys
@param restClient rest client to perform http requests
@param secretShareManager manages of secrets hsaring
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
@param secretShareManager manages of secrets hsaring
@param secretShareManager manager of secrets sharing

@Anderas Anderas merged commit d6e721a into develop Sep 27, 2022
@Anderas Anderas deleted the andy/backup_engine branch September 27, 2022 08:17
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.

None yet

2 participants