Skip to content

Commit

Permalink
Fixes startup options reset (#1581)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1205465612515839/f

BSK PR: duckduckgo/BrowserServicesKit#489
iOS PR: duckduckgo/iOS#2003

## Description

Fixes startup options reset, and improves the options loading logic so
we can easily unit test it.
  • Loading branch information
diegoreymendez authored Sep 12, 2023
1 parent 64ef1f1 commit b835c0a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9470,7 +9470,6 @@
3706FAC4293F65D500E42796 /* PrintingUserScript.swift in Sources */,
9D9AE86C2AA76D1B0026E7DC /* LoginItemsManager.swift in Sources */,
4B9DB0392A983B24000927DB /* JoinedWaitlistView.swift in Sources */,
4B4D60B42A0C847900BCD287 /* LoginItem.swift in Sources */,
3706FEBF293F6EFF00E42796 /* BWError.swift in Sources */,
3706FAC6293F65D500E42796 /* ConnectBitwardenViewController.swift in Sources */,
EEC589DA2A4F1CE400BCD60C /* AppLauncher.swift in Sources */,
Expand Down Expand Up @@ -12278,7 +12277,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 77.3.0;
version = 77.3.1;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class NetworkProtectionOnboardingMenu: NSMenu {
import NetworkProtection
import NetworkProtectionUI

/// Implements the logic for Network Protection's simulate failures menu.
/// Implements the logic for Network Protection's onboarding menu.
///
@objc
@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ final class NetworkProtectionTunnelController: NetworkProtection.TunnelControlle
protocolConfiguration.providerConfiguration = [
NetworkProtectionOptionKey.defaultPixelHeaders: APIRequest.Headers().httpHeaders,
NetworkProtectionOptionKey.excludedRoutes: excludedRoutes().map(\.stringRepresentation) as NSArray,
NetworkProtectionOptionKey.includedRoutes: includedRoutes().map(\.stringRepresentation) as NSArray,
NetworkProtectionOptionKey.connectionTesterEnabled: NSNumber(value: isConnectionTesterEnabled)
NetworkProtectionOptionKey.includedRoutes: includedRoutes().map(\.stringRepresentation) as NSArray
]

// always-on
Expand Down Expand Up @@ -315,15 +314,16 @@ final class NetworkProtectionTunnelController: NetworkProtection.TunnelControlle
options[NetworkProtectionOptionKey.authToken] = try tokenStore.fetchToken() as NSString?
options[NetworkProtectionOptionKey.selectedServer] = debugUtilities.selectedServerName() as NSString?
options[NetworkProtectionOptionKey.keyValidity] = debugUtilities.registrationKeyValidity.map(String.init(describing:)) as NSString?
options[NetworkProtectionOptionKey.connectionTesterEnabled] = await NSNumber(value: isConnectionTesterEnabled)

if Self.simulationOptions.isEnabled(.tunnelFailure) {
Self.simulationOptions.setEnabled(false, option: .tunnelFailure)
options[NetworkProtectionOptionKey.tunnelFailureSimulation] = NetworkProtectionOptionValue.true
options[NetworkProtectionOptionKey.tunnelFailureSimulation] = NSNumber(value: true)
}

if Self.simulationOptions.isEnabled(.crashFatalError) {
Self.simulationOptions.setEnabled(false, option: .crashFatalError)
options[NetworkProtectionOptionKey.tunnelFatalErrorCrashSimulation] = NetworkProtectionOptionValue.true
options[NetworkProtectionOptionKey.tunnelFatalErrorCrashSimulation] = NSNumber(value: true)
}

if Self.simulationOptions.isEnabled(.controllerFailure) {
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.1"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
targets: ["NetworkProtectionUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "77.3.1"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit b835c0a

Please sign in to comment.