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

Convert verification request and transaction to protocols #1528

Merged
merged 2 commits into from
Jul 18, 2022

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Jul 18, 2022

As part of an ongoing work to implement Rust-based device verification I need to prepare the ground by converting existing MXKeyVerificationRequest, MXKeyVerificationTransaction and MXSASTransaction classes into protocols, so that future PRs can implement these protocols with MatrixCryptoSDK objects. This is not a full list of classes that need to be hidden behind an interface, only those directly needed for SAS flow.

I have previously taken a subclassing approach to solve a similar problem, but this was because refactoring existing code for MXCrypto class was too risky without extensive test coverage and it was best to leave this untouched. Swapping request and transaction objects for protocols should be safer, and now validated by some newly enabled integration tests. Subclassing existing implementation on the other hand leaves more technical debt behind and does not safeguard against some methods not being overriden.

Regarding naming, I considered both alternatives where protocol adopts existing name (e.g. MXKeyVerificationRequest) and subclasses extend this (e.g. Default, V2 ...), as well as naming the protocol MXKeyVerificationRequestProtocol and leaving the implementation names intact. Reviewing the SDK I did not find many examples of adding Protocol to protocol definitions so I opted for the first naming variant to preserve consistency. This choice also means that only objective-c files need to perform renames, whereas swift files remain unchanged.

@Anderas Anderas force-pushed the andy/1_verification_protocols branch from a860cea to d75c881 Compare July 18, 2022 09:26
@Anderas Anderas requested review from a team and stefanceriu and removed request for a team July 18, 2022 09:26
@@ -63,13 +63,13 @@ @interface MXKeyVerificationManager ()
dispatch_queue_t cryptoQueue;

// All running transactions
MXUsersDevicesMap<MXKeyVerificationTransaction*> *transactions;
MXUsersDevicesMap<MXDefaultKeyVerificationTransaction *> *transactions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MXKeyVerificationManager is accessing some of the internal methods of request and transaction which are defined in _Private.h header files and not exposed in the protocol. For this reason it is still using implementation types rather than protocol types

@codecov-commenter
Copy link

Codecov Report

Merging #1528 (d75c881) into develop (b83b814) will increase coverage by 0.00%.
The diff coverage is 0.00%.

@@           Coverage Diff            @@
##           develop    #1528   +/-   ##
========================================
  Coverage    12.04%   12.04%           
========================================
  Files          512      512           
  Lines        83822    83822           
  Branches     35786    35786           
========================================
+ Hits         10097    10099    +2     
+ Misses       73357    73355    -2     
  Partials       368      368           
Impacted Files Coverage Δ
...SDK/Crypto/Verification/MXKeyVerificationManager.m 0.00% <0.00%> (ø)
...o/Verification/Requests/MXKeyVerificationRequest.m 0.00% <ø> (ø)
...ification/Status/MXKeyVerificationStatusResolver.m 0.00% <0.00%> (ø)
...cation/Transactions/MXKeyVerificationTransaction.m 0.00% <0.00%> (ø)
...o/Verification/Transactions/SAS/MXSASTransaction.m 0.00% <0.00%> (ø)
MatrixSDKTests/MXCrossSigningVerificationTests.m 0.00% <0.00%> (ø)
MatrixSDKTests/MXCryptoKeyVerificationTests.m 0.00% <0.00%> (ø)
MatrixSDKTests/MXHTTPAdditionalHeadersUnitTests.m 76.08% <0.00%> (+4.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b83b814...d75c881. Read the comment docs.

Copy link
Contributor

@stefanceriu stefanceriu 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 to me 👍

@Anderas Anderas merged commit 5d74d03 into develop Jul 18, 2022
@Anderas Anderas deleted the andy/1_verification_protocols branch July 18, 2022 15:41
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

3 participants