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

refactor: add proxy support - WPB-16256 #2740

Conversation

johnxnguyen
Copy link
Collaborator

@johnxnguyen johnxnguyen commented Mar 25, 2025

TaskWPB-16256 [iOS] Login via email - proxy support

Issue

This PR adds proxy support in WireAuthentication. A number of refactoring were necessary:

  • adjust the component graph to follow linear user flows, e.g root -> determine auth method -> login via email -> verification -> no history
  • introduce NetworkStack to encapsulate network related objects to simplify the component graph, it ensures there is a valid network service, performs api resolving, handles proxy credentials etc.
  • apply consistent patterns across all components, views, and view models: etc using Factory objects
  • clean up a bit the MockDependencies into separate files
  • move general alert handling to RootView

Testing

  1. Start authentication flow
  2. Switch to backend that has proxy enabled
  3. Complete authentication flow and verify that all requests are proxied

Note

Several tests are missing, but we will add these in another PR.


Checklist

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

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Make sure you use the API for UI elements that support large fonts.
  • All colors are taken from WireDesign.ColorTheme or constructed using WireDesign.BaseColorPalette.
  • New UI elements have Accessibility strings for VoiceOver.

…twork-stack-wpb-16256

# Conflicts:
#	WireAuthentication/Sources/WireAuthentication/Components/DetermineAuthMethodComponent.swift
#	WireAuthentication/Sources/WireAuthentication/Components/DetermineAuthMethodOnPremComponent.swift
#	WireAuthentication/Sources/WireAuthentication/Components/LoginViaEmailComponent.swift
#	WireAuthentication/Sources/WireAuthentication/Needle.generated.swift
#	WireAuthentication/Sources/WireAuthenticationUI/Mocks/MockDependencies.swift
#	WireAuthentication/Sources/WireAuthenticationUI/Views/DetermineAuthMethod/DetermineAuthMethodView.swift
#	WireAuthentication/Sources/WireAuthenticationUI/Views/Login/LoginViaEmail/LoginViaEmailView.swift
#	WireAuthentication/Sources/WireAuthenticationUI/Views/Login/LoginViaEmail/LoginViaEmailViewModel.swift
#	WireAuthentication/Sources/WireAuthenticationUI/Views/Root/RootView.swift
#	WireAuthentication/Tests/WireAuthenticationUITests/LoginViaEmail/LoginViaEmailViewModelTests.swift
@johnxnguyen johnxnguyen marked this pull request as ready for review March 26, 2025 08:56
@datadog-wireapp
Copy link

datadog-wireapp bot commented Mar 26, 2025

Datadog Report

Branch report: refactor/network-stack-wpb-16256
Commit report: ad99ddb
Test service: wire-ios-mono

❌ 2 Failed (0 Known Flaky), 1697 Passed, 27 Skipped, 1m 48.17s Total Time

❌ Failed Tests (2)

  • testYesterdayNoUnread() - Wire-iOS-Tests - Details

    Expand for error
     XCTAssertNil failed: "Snapshot does not match reference.
     @−
     "file:///Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/Wire-iOS Tests/ReferenceImages/ConversationCellBurstTimestampViewSnapshotTests/testYesterdayNoUnread.1.png"
     @+
     "file:///Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/SnapshotResults/ConversationCellBurstTimestampViewSnapshotTests/testYesterdayNoUnread.1.png"
     To configure output for a custom diff tool, use 'withSnapshotTesting'. For example:
         withSnapshotTesting(diffTool: .ksdiff) {
           // ...
         }
     Newly-taken snapshot@(169.0, 40.0) does not match reference@(186.66666666666666, 40.0)." (/Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/Wire-iOS%20Tests/ConversationCell/ConversationCellBurstTimestampViewSnapshotTests.swift#EndingLineNumber=92&StartingLineNumber=92)
    
  • testYesterdayWithUnreadAndFirstMessageOfToday() - Wire-iOS-Tests - Details

    Expand for error
     XCTAssertNil failed: "Snapshot does not match reference.
     @−
     "file:///Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/Wire-iOS Tests/ReferenceImages/ConversationCellBurstTimestampViewSnapshotTests/testYesterdayWithUnreadAndFirstMessageOfToday.1.png"
     @+
     "file:///Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/SnapshotResults/ConversationCellBurstTimestampViewSnapshotTests/testYesterdayWithUnreadAndFirstMessageOfToday.1.png"
     To configure output for a custom diff tool, use 'withSnapshotTesting'. For example:
         withSnapshotTesting(diffTool: .ksdiff) {
           // ...
         }
     Newly-taken snapshot@(169.0, 40.0) does not match reference@(186.66666666666666, 40.0)." (/Users/admin/actions-runner/_work/wire-ios/wire-ios/wire-ios/Wire-iOS%20Tests/ConversationCell/ConversationCellBurstTimestampViewSnapshotTests.swift#EndingLineNumber=118&StartingLineNumber=118)
    

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice work! I love that there is more code deleted than added despite adding a bunch of files. I added comments for a couple of issues that should be fixed but are simple.

Copy link
Contributor

github-actions bot commented Mar 26, 2025

Test Results

    2 files      3 suites   2m 7s ⏱️
1 802 tests 1 773 ✅ 27 💤 2 ❌
1 812 runs  1 783 ✅ 27 💤 2 ❌

For more details on these failures, see this check.

Results for commit 78bc22f.

♻️ This comment has been updated with latest results.

@johnxnguyen johnxnguyen requested a review from samwyndham March 26, 2025 12:30
import Foundation
import WireAuthenticationAPI

package struct ValidateEmailUseCase: ValidateEmailUseCaseProtocol {
Copy link
Contributor

@samwyndham samwyndham Mar 26, 2025

Choose a reason for hiding this comment

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

thought (non-blocking): I think this is worth discussing in some kind of retrospective of the architecture. I wonder if sometimes we are being forced to add too much boilerplate.

  • The implementation here
  • Tests for the implementation
  • The new type EmailValidationResult
  • Some kind of mock. This mocking I particularly don't like as I think it adds brittleness but I'm a classist not a mockist kind of tester

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Certainly! I think also some boilerplate could be avoided using macros.

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice work! I think there may be a couple of issues around password validation. Ping me when done and I will approve

@johnxnguyen johnxnguyen merged commit 343d00c into refactor/support-proxy-mode-wpb-16256 Mar 26, 2025
7 of 10 checks passed
@johnxnguyen johnxnguyen deleted the refactor/network-stack-wpb-16256 branch March 26, 2025 17:06
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.

3 participants