wire-ios icon indicating copy to clipboard operation
wire-ios copied to clipboard

refactor: mls group verification in `ZMUserSession` [WPB-9149]

Open markusfassbender opened this issue 1 year ago β€’ 2 comments

BugWPB-9149 iOS: refactor mls group verification in ZMUserSession

Motivation

The ZMUserSession's initialiser takes about 25 arguments. They can be categorised in two:

  1. primary dependencies: foundational services, caches etc.. Ideally they should not use other dependencies.
  2. secondary dependencies: derived objects that can be initialised by the primary dependencies.

The ObserveMLSGroupVerificationStatusUseCase belongs to category 2 and thus should not be passed to the initialiser of ZMUserSession to avoid a infinite growing of responsibilities.

The second point was, that the use case has a state. Therefore it was required to retain the whole use case and keep a task reference alive, again a responsibility of ZMUserSession until now. This is implicit and cannot be easily understand from the outer scope.

Refactoring

  1. While working on it, I figured out that the logic broke into several smaller files, that kind of belong together, and overlapped in some points, logs etc.:
  • ObserveMLSGroupVerificationStatusUseCase
  • MLSConversationVerificationStatusUpdater
  • UpdateMLSGroupVerificationStatusUseCase

ObserveMLSGroupVerificationStatusUseCase and MLSConversationVerificationStatusUpdater got merged into MLSGroupVerification. Extract extension to user session. Simplify mocking and unit tests.

  1. Extract CertificateRevocationLists as extension to user session.

Review

[!NOTE] Start your review in ZMUserSession.swift to see the benefit there.

Maybe it's also helpful to checkout the whole branch and read classes in code.

Testing

  • Simple test: breakpoints, run the app and login
  • For the whole ticket we need to test the MLS group verification with @KaterinaWire and QA.

Checklist

  • [x] Title contains a reference JIRA issue number like [WPB-XXX].
  • [x] Description is filled and free of optional paragraphs.
  • [x] Adds/updates automated tests.

markusfassbender avatar May 10 '24 15:05 markusfassbender

Test Results

β€‡β€ˆβ€‡β€‡5 filesβ€„β€ƒβ€‡β€ˆ894 suites   24m 10s :stopwatch: 7β€ˆ270 tests 7β€ˆ270 :white_check_mark: 0 :zzz: 0 :x: 7β€ˆ278 runsβ€Šβ€ƒ7β€ˆ278 :white_check_mark: 0 :zzz: 0 :x:

Results for commit 4da25044.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar May 13 '24 10:05 github-actions[bot]

Datadog Report

Branch report: refactor/zmusersession-observeMLSGroupVerificationStatusUseCase Commit report: d03f80d Test service: wire-ios-mono

:white_check_mark: 0 Failed, 7270 Passed, 0 Skipped, 2m 59.94s Total Time

datadog-wireapp[bot] avatar May 13 '24 10:05 datadog-wireapp[bot]