-
Notifications
You must be signed in to change notification settings - Fork 11
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
Check DBP Prerequisites in App and Disable Login Item If Necessary #2850
Conversation
0a2b3d6
to
7aa0d56
Compare
return | ||
} | ||
|
||
Task { | ||
try? await DataBrokerProtectionWaitlist().redeemDataBrokerProtectionInviteCodeIfAvailable() | ||
let loginItemsManager = LoginItemsManager() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the creation of these later in the method, after guard checks, when we know they are needed.
|
||
@testable import DuckDuckGo_Privacy_Browser | ||
|
||
final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was renamed, and so this is not all new code. The newly added tests start at line 127.
7aa0d56
to
27c5277
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
DuckDuckGo.xcodeproj/project.pbxproj
Outdated
@@ -9825,7 +9845,7 @@ | |||
3706FB4C293F65D500E42796 /* SharingMenu.swift in Sources */, | |||
3706FB4D293F65D500E42796 /* GrammarFeaturesManager.swift in Sources */, | |||
3706FB50293F65D500E42796 /* SafariFaviconsReader.swift in Sources */, | |||
31267C692B640C4200FEF811 /* DataBrokerProtectionFeatureVisibility.swift in Sources */, | |||
31267C692B640C4200FEF811 /* DataBrokerProtectionFeatureGatekeeper.swift in Sources */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What name do we use for this sort of thing generally? I didn't like visibility, but it would be good if we can be consistent across the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, Visibility
is inaccurate IMO, as it’s availability rather than visibility. Good point, we have NetworkProtectionFeatureVisibility
and NetworkProtectionBouncer
. They do different things so if we were to rename I’d prob only rename NetworkProtectionFeatureVisibility
at this point. Happy to do that now if you think it makes sense @THISISDINOSAUR .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind either way, but either way I'd mention it to the O-N people
I'm also not a fan of bouncer, IMO it could mean too many different things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I’ll mention to O-N people and rename …Visibility
if no objections. Agree on the Bouncer
re: meanings.
|
||
Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we do for the VPN that I'm not sure we're doing for DBP is restart the agent on launch, if there's been an app update. This basically tries to ensure the agent we're running is updated too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, @jotaemepereira has mentioned this as something we should do at some point. Thanks for highlighting @diegoreymendez .
func arePrerequisitesSatisfied() async -> Bool { | ||
let entitlements = await accountManager.hasEntitlement(for: .dataBrokerProtection, | ||
cachePolicy: .reloadIgnoringLocalCacheData) | ||
var hasEntitlements: Bool | ||
switch entitlements { | ||
case .success(let value): | ||
hasEntitlements = value | ||
case .failure: | ||
hasEntitlements = false | ||
} | ||
|
||
let isAuthenticated = accountManager.accessToken != nil | ||
|
||
firePrerequisitePixelsAndLogIfNecessary(hasEntitlements: hasEntitlements, isAuthenticatedResult: isAuthenticated) | ||
|
||
return hasEntitlements && isAuthenticated | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding a though here for you, but I think this can be addressed incrementally as I don't want to blow up the scope of your PR.
I think this logic is likely to be the same across PPro products, and that we might want to push this up to the subscription library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I’ll refrain from actioning here to avoid scope increase as you say.
Added some comments looking mostly at the code changes. None of the two comments are blocking though - they're more thoughts I wanted to share. |
Thanks @diegoreymendez , I’m implemented the VPN renaming changes I suggested on MM. Can you take a quick look please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @aataraxiaa , thanks for doing this!
# Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo/Preferences/Model/PreferencesSidebarModel.swift
# By Sam Symons (8) and others # Via GitHub * main: (35 commits) Check DBP Prerequisites in App and Disable Login Item If Necessary (#2850) Fixes an issue with my last merge Implement VPN control through UDS (#2767) Add VPN reddit cookie workaround (#2851) Bump version to 1.92.0 (202) Update Send Feedback icon (#2852) Make passwords easier to discover (#2847) Bump version to 1.92.0 (201) Update BSK for RMF survey changes (#2846) DBP: Update people-wizard.com (#2849) Remove VPN launch pixels (#2845) Prevent showing multiple VPN uninstalled popovers (#2844) Bump version to 1.92.0 (200) Set marketing version to 1.92.0 Update embedded files DBP: Implement stats pixels (#2812) DBP: Add support for noResultsSelector (#2840) Fire compilation failed pixel if needed (#1626) Update autoconsent to v10.10.0 (#2842) Fix running Autofill-related UI tests in CI (#2843) ... # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Task/Issue URL: https://app.asana.com/0/1206488453854252/1207501562611619/f
Description:
This PR introduces changes to check DBP prerequisites (user is authenticated and has valid entitlements) from the App when the app becomes active. When prerequisites are not satisfied, the app disables the login item. This is to prevent a scenario where the background agent checks prerequisites, exits due to failed prerequisites, and then is automatically re-started by the login item.
Notable Changes:
DataBrokerProtectionFeatureVisibility
toDataBrokerProtectionFeatureGatekeeper
arePrerequisitesSatisfied
toDataBrokerProtectionFeatureGatekeeper
arePrerequisitesSatisfied
scenariosSteps to test this PR:
Test Setup:
stopAgent
immediately in theDefaultDataBrokerProtectionAgentStopper.validateRunPrerequisitesAndStopAgentIfnecessary
method, e.gDataBrokerProtectionFeatureGatekeeper.arePrerequisitesSatisfied
method, e.gcategory:Data Broker Protection
Tests:
Test 1: App Kills the Login Item
Note: You may see the background agent also start and then stop. This is due to different threads performing the work. This is ok, as long as the background agent does not continuously restart.
Test 2: DPB Functions as expected
—
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation