Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.duckduckgo.contentscopescripts.impl

import com.duckduckgo.app.privacy.db.UserAllowListRepository
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
import com.duckduckgo.appbuildconfig.api.isInternalBuild
import com.duckduckgo.common.utils.plugins.PluginPoint
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
import com.duckduckgo.di.scopes.AppScope
Expand Down Expand Up @@ -200,7 +201,7 @@ class RealContentScopeScripts @Inject constructor(
}

private fun getVersionNumberKeyValuePair() = "\"versionNumber\":${appBuildConfig.versionCode}"
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\"}"
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\",\"internal\":${appBuildConfig.isInternalBuild()}}"
private fun getLanguageKeyValuePair() = "\"locale\":\"${Locale.getDefault().language}\""
private fun getDesktopModeKeyValuePair(isDesktopMode: Boolean) = "\"desktopModeEnabled\":$isDesktopMode"
private fun getSessionKeyValuePair() = "\"sessionKey\":\"${fingerprintProtectionManager.getSeed()}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.duckduckgo.contentscopescripts.impl

import com.duckduckgo.app.privacy.db.UserAllowListRepository
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
import com.duckduckgo.appbuildconfig.api.isInternalBuild
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.common.utils.plugins.PluginPoint
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
Expand Down Expand Up @@ -204,7 +205,7 @@ class RealWebViewCompatContentScopeScripts @Inject constructor(
}

private fun getVersionNumberKeyValuePair() = "\"versionNumber\":${appBuildConfig.versionCode}"
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\"}"
private fun getPlatformKeyValuePair() = "\"platform\":{\"name\":\"android\",\"internal\":${appBuildConfig.isInternalBuild()}}"
private fun getLanguageKeyValuePair() = "\"locale\":\"${Locale.getDefault().language}\""
private fun getDesktopModeKeyValuePair(isDesktopMode: Boolean) = "\"desktopModeEnabled\":$isDesktopMode"
private fun getSessionKeyValuePair() = "\"sessionKey\":\"${fingerprintProtectionManager.getSeed()}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.contentscopescripts.impl
import android.annotation.SuppressLint
import com.duckduckgo.app.privacy.db.UserAllowListRepository
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
import com.duckduckgo.appbuildconfig.api.BuildFlavor
import com.duckduckgo.common.utils.plugins.PluginPoint
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
import com.duckduckgo.feature.toggles.api.FakeFeatureToggleFactory
Expand Down Expand Up @@ -71,6 +72,7 @@ class RealContentScopeScriptsTest {
whenever(mockUserAllowListRepository.domainsInUserAllowList()).thenReturn(listOf(exampleUrl))
whenever(mockContentScopeJsReader.getContentScopeJS()).thenReturn(contentScopeJS)
whenever(mockAppBuildConfig.versionCode).thenReturn(versionCode)
whenever(mockAppBuildConfig.flavor).thenReturn(BuildFlavor.INTERNAL)
whenever(mockUnprotectedTemporary.unprotectedTemporaryExceptions)
.thenReturn(listOf(unprotectedTemporaryException, unprotectedTemporaryException2))
whenever(mockFingerprintProtectionManager.getSeed()).thenReturn(sessionKey)
Expand Down Expand Up @@ -101,7 +103,8 @@ class RealContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"foo\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -128,7 +131,8 @@ class RealContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -155,7 +159,7 @@ class RealContentScopeScriptsTest {
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"globalPrivacyControlValue\":true,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -182,7 +186,7 @@ class RealContentScopeScriptsTest {
"\"config2\":\\{\"state\":\"disabled\"\\}\\}," +
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -210,7 +214,8 @@ class RealContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":true," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -235,7 +240,7 @@ class RealContentScopeScriptsTest {
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -268,7 +273,7 @@ class RealContentScopeScriptsTest {
"\\{\"currentCohorts\":\\[" +
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}," +
"\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"bloops\"}\\]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -347,7 +352,7 @@ class RealContentScopeScriptsTest {
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[" +
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}\\]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -409,7 +414,7 @@ class RealContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.contentscopescripts.impl
import android.annotation.SuppressLint
import com.duckduckgo.app.privacy.db.UserAllowListRepository
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
import com.duckduckgo.appbuildconfig.api.BuildFlavor.INTERNAL
import com.duckduckgo.common.test.CoroutineTestRule
import com.duckduckgo.common.utils.plugins.PluginPoint
import com.duckduckgo.contentscopescripts.api.ContentScopeConfigPlugin
Expand Down Expand Up @@ -78,6 +79,7 @@ class RealWebViewCompatContentScopeScriptsTest {
whenever(mockUserAllowListRepository.domainsInUserAllowList()).thenReturn(listOf(exampleUrl))
whenever(mockContentScopeJsReader.getContentScopeJS()).thenReturn(contentScopeJS)
whenever(mockAppBuildConfig.versionCode).thenReturn(versionCode)
whenever(mockAppBuildConfig.flavor).thenReturn(INTERNAL)
whenever(mockUnprotectedTemporary.unprotectedTemporaryExceptions)
.thenReturn(listOf(unprotectedTemporaryException, unprotectedTemporaryException2))
whenever(mockFingerprintProtectionManager.getSeed()).thenReturn(sessionKey)
Expand Down Expand Up @@ -108,7 +110,8 @@ class RealWebViewCompatContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"foo\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -135,7 +138,8 @@ class RealWebViewCompatContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\\{\"globalPrivacyControlValue\":false,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -162,7 +166,7 @@ class RealWebViewCompatContentScopeScriptsTest {
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"globalPrivacyControlValue\":true,\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand All @@ -189,7 +193,8 @@ class RealWebViewCompatContentScopeScriptsTest {
"\"config2\":\\{\"state\":\"disabled\"\\}\\}," +
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -218,7 +223,7 @@ class RealWebViewCompatContentScopeScriptsTest {
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -251,7 +256,7 @@ class RealWebViewCompatContentScopeScriptsTest {
"\\{\"currentCohorts\":\\[" +
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}," +
"\\{\"cohort\":\"control\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"bloops\"}\\]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -337,7 +342,7 @@ class RealWebViewCompatContentScopeScriptsTest {
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[" +
"\\{\"cohort\":\"treatment\",\"feature\":\"contentScopeExperiments\",\"subfeature\":\"test\"}\\]," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\}," +
"\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\",\"internal\":true\\}," +
"\"locale\":\"en\",\"sessionKey\":\"5678\"," +
"\"desktopModeEnabled\":false,\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down Expand Up @@ -399,7 +404,8 @@ class RealWebViewCompatContentScopeScriptsTest {
"\"unprotectedTemporary\":\\[" +
"\\{\"domain\":\"example\\.com\",\"reason\":\"reason\"\\}," +
"\\{\"domain\":\"foo\\.com\",\"reason\":\"reason2\"\\}\\]\\}, \\[\"example\\.com\"\\], " +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234,\"platform\":\\{\"name\":\"android\"\\},\"locale\":\"en\"," +
"\\{\"currentCohorts\":\\[\\],\"versionNumber\":1234," +
"\"platform\":\\{\"name\":\"android\",\"internal\":true\\},\"locale\":\"en\"," +
"\"sessionKey\":\"5678\",\"desktopModeEnabled\":false," +
"\"messageSecret\":\"([\\da-f]{32})\"," +
"\"messageCallback\":\"([\\da-f]{32})\"," +
Expand Down
Loading