Skip to content

Commit

Permalink
Fix internal user toggling (#2000)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/414235014887631/1206217864822184/f
Tech Design URL:
CC:

**Description**:

Fix internal user toggling.
  • Loading branch information
bwaresiak authored Dec 21, 2023
1 parent b758192 commit 85de0dc
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12976,7 +12976,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 97.0.0;
version = 98.0.0;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "d671accf1bf7097c4e7f5cd55cd1c6dfa005cf92",
"version" : "97.0.0"
"revision" : "064ed560f19fbfd36eb02decebf944689818ed35",
"version" : "98.0.0"
}
},
{
Expand Down
11 changes: 11 additions & 0 deletions DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ final class MockPrivacyConfiguration: PrivacyConfiguration {
func userDisabledProtection(forDomain: String) {}
}

final class MockInternalUserStoring: InternalUserStoring {
var isInternalUser: Bool = false
}

extension DefaultInternalUserDecider {
convenience init(mockedStore: MockInternalUserStoring = MockInternalUserStoring()) {
self.init(store: mockedStore)
}
}

final class MockPrivacyConfigurationManager: NSObject, PrivacyConfigurationManaging {
var embeddedConfigData: BrowserServicesKit.PrivacyConfigurationManager.ConfigurationData {
fatalError("not implemented")
Expand All @@ -70,6 +80,7 @@ final class MockPrivacyConfigurationManager: NSObject, PrivacyConfigurationManag

var updatesPublisher: AnyPublisher<Void, Never> = Just(()).eraseToAnyPublisher()
var privacyConfig: PrivacyConfiguration = MockPrivacyConfiguration()
var internalUserDecider: InternalUserDecider = DefaultInternalUserDecider()
}

#endif
8 changes: 5 additions & 3 deletions DuckDuckGoDBPBackgroundAgent/DBPMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ final class PrivacyConfigurationManagingMock: PrivacyConfigurationManaging {
guard let privacyConfigurationData = try? PrivacyConfigurationData(data: data) else {
fatalError("Could not retrieve privacy configuration data")
}
let privacyConfig = privacyConfiguration(withData: privacyConfigurationData)
let privacyConfig = privacyConfiguration(withData: privacyConfigurationData, internalUserDecider: internalUserDecider)
return privacyConfig
}

var internalUserDecider: InternalUserDecider = DefaultInternalUserDecider(store: InternalUserDeciderStoreMock())

func reload(etag: String?, data: Data?) -> PrivacyConfigurationManager.ReloadResult {
.downloaded
}
}

func privacyConfiguration(withData data: PrivacyConfigurationData) -> PrivacyConfiguration {
func privacyConfiguration(withData data: PrivacyConfigurationData, internalUserDecider: InternalUserDecider) -> PrivacyConfiguration {
let domain = MockDomainsProtectionStore()
return AppPrivacyConfiguration(data: data,
identifier: UUID().uuidString,
localProtection: domain,
internalUserDecider: DefaultInternalUserDecider(store: InternalUserDeciderStoreMock()))
internalUserDecider: internalUserDecider)
}

final class MockDomainsProtectionStore: DomainsProtectionStore {
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Account/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["Account"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
.package(path: "../Purchase")
],
targets: [
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: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
.package(path: "../PixelKit"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private class PrivacyConfigurationDataBrokerProtectionConfigOverride: PrivacyCon
var base: Data
var updatesPublisher: AnyPublisher<(), Never>
var privacyConfig: PrivacyConfiguration
var internalUserDecider: InternalUserDecider

var currentConfig: Data {
return updateConfigWithBrokerProtection()
Expand All @@ -176,6 +177,7 @@ private class PrivacyConfigurationDataBrokerProtectionConfigOverride: PrivacyCon
base = manager.currentConfig
updatesPublisher = manager.updatesPublisher
privacyConfig = manager.privacyConfig
internalUserDecider = manager.internalUserDecider
}

private func updateConfigWithBrokerProtection() -> Data {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@ extension DataBrokerScheduleConfig {
}
}

final class InternalUserDeciderStoreMock: InternalUserStoring {
var isInternalUser: Bool = false
}

final class PrivacyConfigurationManagingMock: PrivacyConfigurationManaging {
var currentConfig: Data = Data()

var updatesPublisher: AnyPublisher<Void, Never> = .init(Just(()))

var privacyConfig: BrowserServicesKit.PrivacyConfiguration = PrivacyConfigurationMock()

var internalUserDecider: InternalUserDecider = DefaultInternalUserDecider(store: InternalUserDeciderStoreMock())

func reload(etag: String?, data: Data?) -> PrivacyConfigurationManager.ReloadResult {
.downloaded
}
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/LoginItems/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
.package(path: "../XPCHelper"),
.package(path: "../SwiftUIExtensions")
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/PixelKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Purchase/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Subscription/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.package(path: "../Account"),
.package(path: "../Purchase"),
.package(path: "../SwiftUIExtensions"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SwiftUIExtensions/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(path: "../SwiftUIExtensions"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SystemExtensionManager/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/XPCHelper/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
.library(name: "XPCHelper", targets: ["XPCHelper"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "97.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down

0 comments on commit 85de0dc

Please sign in to comment.