-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update privacy toggle to be per site #811
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
353ecf3
Delete privacy store add whitelist functionality and update toggle
subsymbolic 263c9f3
Update pixels
subsymbolic 94398b6
New buttons
subsymbolic 2ccff7d
Add whitelist
subsymbolic 2a5b9ab
Merge branch 'develop' into feature/mia/toggle
subsymbolic e374aef
Add db migration test
subsymbolic 0ae138a
Add browser menu item, error messages and more tests
subsymbolic ae745be
Merge branch 'develop' into feature/mia/toggle
subsymbolic adfb5f2
Lint tidy up
subsymbolic e276c1d
Merge branch 'develop' into feature/mia/toggle
subsymbolic bf5197d
Add icon tint
subsymbolic b73f89d
Merge branch 'develop' into feature/mia/toggle
subsymbolic 7b271e7
Fix double pixel when activities not kept
subsymbolic 528924c
Remove mixed viewstate set and post value and access of viewState fro…
subsymbolic 1ccd425
Merge branch 'develop' into feature/mia/toggle
subsymbolic 8bdbf4a
Update test to also check pixel
subsymbolic 356b1d8
Cleanup unneeded annotations and client definition
subsymbolic 7e18623
Make db writes suspend functions to avoid future use without consider…
subsymbolic 98e88f1
Update coroutines to use suspend functions for private methods and ju…
subsymbolic 6b9d6d6
Extract repeated isWhitelisted check into own suspect function and ot…
subsymbolic fb9a63c
Merge branch 'develop' into feature/mia/toggle
subsymbolic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
700 changes: 700 additions & 0 deletions
700
app/schemas/com.duckduckgo.app.global.db.AppDatabase/20.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/src/androidTest/java/com/duckduckgo/app/brokensite/BrokenSiteDataTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /* | ||
| * Copyright (c) 2020 DuckDuckGo | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.duckduckgo.app.brokensite | ||
|
|
||
| import com.duckduckgo.app.global.model.Site | ||
| import com.duckduckgo.app.global.model.SiteMonitor | ||
| import com.duckduckgo.app.surrogates.SurrogateResponse | ||
| import com.duckduckgo.app.trackerdetection.model.TrackingEvent | ||
| import org.junit.Assert.* | ||
| import org.junit.Test | ||
|
|
||
| class BrokenSiteDataTest { | ||
|
|
||
| @Test | ||
| fun whenSiteIsNullThenDataIsEmptyAndUpgradedIsFalse() { | ||
| val data = BrokenSiteData.fromSite(null) | ||
| assertTrue(data.url.isEmpty()) | ||
| assertTrue(data.blockedTrackers.isEmpty()) | ||
| assertTrue(data.surrogates.isEmpty()) | ||
| assertFalse(data.upgradedToHttps) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteExistsThenDataContainsUrl() { | ||
| val site = buildSite(SITE_URL) | ||
| val data = BrokenSiteData.fromSite(site) | ||
| assertEquals(SITE_URL, data.url) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteUpgradedThenHttpsUpgradedIsTrue() { | ||
| val site = buildSite(SITE_URL, httpsUpgraded = true) | ||
| val data = BrokenSiteData.fromSite(site) | ||
| assertTrue(data.upgradedToHttps) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteNotUpgradedThenHttpsUpgradedIsFalse() { | ||
| val site = buildSite(SITE_URL, httpsUpgraded = false) | ||
| val data = BrokenSiteData.fromSite(site) | ||
| assertFalse(data.upgradedToHttps) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasNoTrackersThenBlockedTrackersIsEmpty() { | ||
| val site = buildSite(SITE_URL) | ||
| val data = BrokenSiteData.fromSite(site) | ||
| assertTrue(data.blockedTrackers.isEmpty()) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasBlockedTrackersThenBlockedTrackersExist() { | ||
| val site = buildSite(SITE_URL) | ||
| val event = TrackingEvent("http://www.example.com", "http://www.tracker.com/tracker.js", emptyList(), null, false) | ||
| val anotherEvent = TrackingEvent("http://www.example.com/test", "http://www.anothertracker.com/tracker.js", emptyList(), null, false) | ||
| site.trackerDetected(event) | ||
| site.trackerDetected(anotherEvent) | ||
| assertEquals("www.tracker.com,www.anothertracker.com", BrokenSiteData.fromSite(site).blockedTrackers) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasSameHostBlockedTrackersThenOnlyUniqueTrackersIncludedInData() { | ||
| val site = buildSite(SITE_URL) | ||
| val event = TrackingEvent("http://www.example.com", "http://www.tracker.com/tracker.js", emptyList(), null, false) | ||
| val anotherEvent = TrackingEvent("http://www.example.com/test", "http://www.tracker.com/tracker2.js", emptyList(), null, false) | ||
| site.trackerDetected(event) | ||
| site.trackerDetected(anotherEvent) | ||
| assertEquals("www.tracker.com", BrokenSiteData.fromSite(site).blockedTrackers) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasNoSurrogatesThenSurrogatesIsEmpty() { | ||
| val site = buildSite(SITE_URL) | ||
| val data = BrokenSiteData.fromSite(site) | ||
| assertTrue(data.surrogates.isEmpty()) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasSurrogatesThenSurrogatesExist() { | ||
| val surrogate = SurrogateResponse(true, "surrogate.com/test.js", "", "") | ||
| val anotherSurrogate = SurrogateResponse(true, "anothersurrogate.com/test.js", "", "") | ||
| val site = buildSite(SITE_URL) | ||
| site.surrogateDetected(surrogate) | ||
| site.surrogateDetected(anotherSurrogate) | ||
| assertEquals("surrogate.com,anothersurrogate.com", BrokenSiteData.fromSite(site).surrogates) | ||
| } | ||
|
|
||
| @Test | ||
| fun whenSiteHasSameHostSurrogatesThenOnlyUniqueSurrogateIncludedInData() { | ||
| val surrogate = SurrogateResponse(true, "surrogate.com/test.js", "", "") | ||
| val anotherSurrogate = SurrogateResponse(true, "surrogate.com/test2.js", "", "") | ||
| val site = buildSite(SITE_URL) | ||
| site.surrogateDetected(surrogate) | ||
| site.surrogateDetected(anotherSurrogate) | ||
| assertEquals("surrogate.com", BrokenSiteData.fromSite(site).surrogates) | ||
| } | ||
|
|
||
| private fun buildSite(url: String, httpsUpgraded: Boolean = false): Site { | ||
| return SiteMonitor(url, "", upgradedHttps = httpsUpgraded) | ||
| } | ||
|
|
||
| companion object { | ||
| private const val SITE_URL = "foo.com" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.