diff options
| author | Steffen Ernst <steffen.ernst@mullvad.net> | 2025-02-10 15:55:44 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-02-18 11:51:59 +0100 |
| commit | 63d9f6fc8814c5bbe9e07a26ad6487ec32e5fcab (patch) | |
| tree | 345185d02b62cd06008af61ec88d90fb1fb1a6f2 | |
| parent | 01fc82e1a429b6374e6b5c3747e6965064265b65 (diff) | |
| download | mullvadvpn-63d9f6fc8814c5bbe9e07a26ad6487ec32e5fcab.tar.xz mullvadvpn-63d9f6fc8814c5bbe9e07a26ad6487ec32e5fcab.zip | |
Add tests for new settings version migration
3 files changed, 28 insertions, 4 deletions
diff --git a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsInfoButtonItem.swift b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsInfoButtonItem.swift index 9df6ed2a41..e04402f476 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsInfoButtonItem.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsInfoButtonItem.swift @@ -26,7 +26,6 @@ enum VPNSettingsInfoButtonItem: CustomStringConvertible { tableName: "LocalNetworkSharing", value: """ This feature allows access to other devices on the local network, such as for sharing, printing, streaming, etc. - It does this by allowing network communication outside the tunnel to local multicast and broadcast ranges as well as to and from these private IP ranges: 10.0.0.0/8 172.16.0.0/12 @@ -34,7 +33,6 @@ enum VPNSettingsInfoButtonItem: CustomStringConvertible { 169.254.0.0/16 fe80::/10 fc00::/7 - Attention: toggling “Local network sharing” requires restarting the VPN connection. """, comment: "" diff --git a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsViewController.swift b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsViewController.swift index 90dd685b85..398830365e 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsViewController.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsViewController.swift @@ -161,7 +161,7 @@ extension VPNSettingsViewController: @preconcurrency VPNSettingsDataSourceDelega } func showLocalNetworkSharingWarning(_ enable: Bool, completion: @escaping (Bool) -> Void) { - if interactor.tunnelManager.tunnelStatus.state.isSecured { + if interactor.tunnelManager.tunnelStatus.state.isSecured && interactor.tunnelManager.tunnelStatus.observedState.connectionState?.isNetworkReachable ?? false { let description = NSLocalizedString( "VPN_SETTINGS_LOCAL_NETWORK_SHARING_WARNING", tableName: "LocalNetworkSharing", @@ -172,7 +172,6 @@ extension VPNSettingsViewController: @preconcurrency VPNSettingsDataSourceDelega : "Disabling" ) “Local network sharing” requires restarting the VPN connection, which will disconnect you and briefly expose your traffic. To prevent this, manually enable Airplane Mode and turn off Wi-Fi before continuing. - Would you like to continue to enable “Local network sharing”? """, comment: "" diff --git a/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift b/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift index adbc92c5d8..078b0f5a62 100644 --- a/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift +++ b/ios/MullvadVPNTests/MullvadSettings/MigrationManagerTests.swift @@ -128,6 +128,33 @@ final class MigrationManagerTests: XCTestCase { wait(for: [failedMigrationExpectation], timeout: .UnitTest.timeout) } + func testSuccessfulMigrationFromV6ToLatest() throws { + var settingsV6 = TunnelSettingsV6() + let relayConstraints = RelayConstraints( + exitLocations: .only(UserSelectedRelays(locations: [.city("jp", "osa")])) + ) + + settingsV6.relayConstraints = relayConstraints + settingsV6.tunnelQuantumResistance = .off + settingsV6.wireGuardObfuscation = WireGuardObfuscationSettings( + state: .off, + udpOverTcpPort: .automatic + ) + settingsV6.tunnelMultihopState = .off + settingsV6.daita = .init(daitaState: .on) + + try migrateToLatest(settingsV6, version: .v6) + + // Once the migration is done, settings should have been updated to the latest available version + // Verify that the old settings are still valid + let latestSettings = try SettingsManager.readSettings() + XCTAssertEqual(settingsV6.relayConstraints, latestSettings.relayConstraints) + XCTAssertEqual(settingsV6.tunnelQuantumResistance, latestSettings.tunnelQuantumResistance) + XCTAssertEqual(settingsV6.wireGuardObfuscation, latestSettings.wireGuardObfuscation) + XCTAssertEqual(settingsV6.tunnelMultihopState, latestSettings.tunnelMultihopState) + XCTAssertEqual(settingsV6.daita, latestSettings.daita) + } + func testSuccessfulMigrationFromV5ToLatest() throws { var settingsV5 = TunnelSettingsV5() let relayConstraints = RelayConstraints( |
