8000 Merge tag '5.85.3' into develop · sdevpiyush/Android@1ef6164 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ef6164

Browse files
committed
Merge tag '5.85.3' into develop
no message # Conflicts: # app/version/release-notes
2 parents 2ecd804 + 7fc6411 commit 1ef6164

File tree

5 files changed

+118
-114
lines changed

5 files changed

+118
-114
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/useragent/UserAgentProviderTest.kt

Lines changed: 99 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package com.duckduckgo.app.browser.useragent
1919
import com.duckduckgo.app.global.device.DeviceInfo
2020
import com.nhaarman.mockitokotlin2.mock
2121
import com.nhaarman.mockitokotlin2.whenever
22+
import org.junit.Assert.assertTrue
2223
import org.junit.Before
24+
import org.junit.Test
2325

2426
class UserAgentProviderTest {
2527

@@ -32,103 +34,103 @@ class UserAgentProviderTest {
3234
whenever(deviceInfo.majorAppVersion).thenReturn("5")
3335
}
3436

35-
// @Test
36-
// fun whenUaRetrievedWithNoParamsThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
37-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
38-
// val actual = testee.userAgent()
39-
// assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
40-
// }
41-
//
42-
// @Test
43-
// fun whenMobileUaRetrievedThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
44-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
45-
// val actual = testee.userAgent(isDesktop = false)
46-
// assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
47-
// }
48-
//
49-
// @Test
50-
// fun whenDesktopUaRetrievedThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
51-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
52-
// val actual = testee.userAgent(isDesktop = true)
53-
// assertTrue("$actual does not match expected regex", ValidationRegex.desktop.matches(actual))
54-
// }
55-
//
56-
// @Test
57-
// fun whenMissingAppleWebKitComponentThenUaContainsMozillaAndApplicationAndSafariComponents() {
58-
// testee = UserAgentProvider(Agent.NO_WEBKIT, deviceInfo)
59-
// val actual = testee.userAgent(isDesktop = false)
60-
// assertTrue("$actual does not match expected regex", ValidationRegex.missingWebKit.matches(actual))
61-
// }
62-
//
63-
// @Test
64-
// fun whenMissingSafariComponentThenUaContainsMozillaAndVersionAndApplicationComponents() {
65-
// testee = UserAgentProvider(Agent.NO_SAFARI, deviceInfo)
66-
// val actual = testee.userAgent(isDesktop = false)
67-
// assertTrue("$actual does not match expected result", ValidationRegex.missingSafari.matches(actual))
68-
// }
69-
//
70-
// @Test
71-
// fun whenMissingVersionComponentThenUaContainsMozillaAndApplicationAndSafariComponents() {
72-
// testee = UserAgentProvider(Agent.NO_VERSION, deviceInfo)
73-
// val actual = testee.userAgent(isDesktop = false)
74-
// assertTrue("$actual does not match expected result", ValidationRegex.noVersion.matches(actual))
75-
// }
76-
//
77-
// @Test
78-
// fun whenDomainDoesNotSupportApplicationThenUaOmitsApplicationComponent() {
79-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
80-
// val actual = testee.userAgent(NO_APPLICATION_DOMAIN)
81-
// assertTrue("$actual does not match expected regex", ValidationRegex.noApplication.matches(actual))
82-
// }
83-
//
84-
// @Test
85-
// fun whenSubdomsinDoesNotSupportApplicationThenUaOmitsApplicationComponent() {
86-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
87-
// val actual = testee.userAgent(NO_APPLICATION_SUBDOMAIN)
88-
// assertTrue("$actual does not match expected regex", ValidationRegex.noApplication.matches(actual))
89-
// }
90-
//
91-
// @Test
92-
// fun whenDomainSupportsApplicationThenUaAddsApplicationComponentBeforeSafari() {
93-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
94-
// val actual = testee.userAgent(DOMAIN)
95-
// assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
96-
// }
97-
//
98-
// @Test
99-
// fun whenDomainDoesNotSupportVersionThenUaOmitsVersionComponent() {
100-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
101-
// val actual = testee.userAgent(NO_VERSION_DOMAIN)
102-
// assertTrue("$actual does not match expected regex", ValidationRegex.noVersion.matches(actual))
103-
// }
104-
//
105-
// @Test
106-
// fun whenSubdomainDoesNotSupportVersionThenUaOmitsVersionComponent() {
107-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
108-
// val actual = testee.userAgent(NO_VERSION_SUBDOMAIN)
109-
// assertTrue("$actual does not match expected regex", ValidationRegex.noVersion.matches(actual))
110-
// }
111-
//
112-
// @Test
113-
// fun whenDomainSupportsVersionThenUaIncludesVersionComponentInUsualLocation() {
114-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
115-
// val actual = testee.userAgent(DOMAIN)
116-
// assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
117-
// }
118-
//
119-
// @Test
120-
// fun whenUserAgentIsForASiteThatShouldUseDesktopAgentThenReturnDesktopUserAgent() {
121-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
122-
// val actual = testee.userAgent(DESKTOP_ONLY_SITE)
123-
// assertTrue("$actual does not match expected regex", ValidationRegex.desktop.matches(actual))
124-
// }
125-
//
126-
// @Test
127-
// fun whenUserAgentIsForASiteThatShouldUseDesktopAgentButContainsAnExclusionThenDoNotReturnConvertedUserAgent() {
128-
// testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
129-
// val actual = testee.userAgent(DESKTOP_ONLY_SITE_EXCEPTION)
130-
// assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
131-
// }
37+
@Test
38+
fun whenUaRetrievedWithNoParamsThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
39+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
40+
val actual = testee.userAgent()
41+
assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
42+
}
43+
44+
@Test
45+
fun whenMobileUaRetrievedThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
46+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
47+
val actual = testee.userAgent(isDesktop = false)
48+
assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
49+
}
50+
51+
@Test
52+
fun whenDesktopUaRetrievedThenDeviceStrippedAndApplicationComponentAddedBeforeSafari() {
53+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
54+
val actual = testee.userAgent(isDesktop = true)
55+
assertTrue("$actual does not match expected regex", ValidationRegex.desktop.matches(actual))
56+
}
57+
58+
@Test
59+
fun whenMissingAppleWebKitComponentThenUaContainsMozillaAndApplicationAndSafariComponents() {
60+
testee = UserAgentProvider(Agent.NO_WEBKIT, deviceInfo)
61+
val actual = testee.userAgent(isDesktop = false)
62+
assertTrue("$actual does not match expected regex", ValidationRegex.missingWebKit.matches(actual))
63+
}
64+
65+
@Test
66+
fun whenMissingSafariComponentThenUaContainsMozillaAndVersionAndApplicationComponents() {
67+
testee = UserAgentProvider(Agent.NO_SAFARI, deviceInfo)
68+
val actual = testee.userAgent(isDesktop = false)
69+
assertTrue("$actual does not match expected result", ValidationRegex.missingSafari.matches(actual))
70+
}
71+
72+
@Test
73+
fun whenMissingVersionComponentThenUaContainsMozillaAndApplicationAndSafariComponents() {
74+
testee = UserAgentProvider(Agent.NO_VERSION, deviceInfo)
75+
val actual = testee.userAgent(isDesktop = false)
76+
assertTrue("$actual does not match expected result", ValidationRegex.noVersion.matches(actual))
77+
}
78+
79+
@Test
80+
fun whenDomainDoesNotSupportApplicationThenUaOmitsApplicationComponent() {
81+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
82+
val actual = testee.userAgent(NO_APPLICATION_DOMAIN)
83+
assertTrue("$actual does not match expected regex", ValidationRegex.noApplication.matches(actual))
84+
}
85+
86+
@Test
87+
fun whenSubdomsinDoesNotSupportApplicationThenUaOmitsApplicationComponent() {
88+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
89+
val actual = testee.userAgent(NO_APPLICATION_SUBDOMAIN)
90+
assertTrue("$actual does not match expected regex", ValidationRegex.noApplication.matches(actual))
91+
}
92+
93+
@Test
94+
fun whenDomainSupportsApplicationThenUaAddsApplicationComponentBeforeSafari() {
95+ testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
96+
val actual = testee.userAgent(DOMAIN)
97+
assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
98+
}
99+
100+
@Test
101+
fun whenDomainDoesNotSupportVersionThenUaOmitsVersionComponent() {
102+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
103+
val actual = testee.userAgent(NO_VERSION_DOMAIN)
104+
assertTrue("$actual does not match expected regex", ValidationRegex.noVersion.matches(actual))
105+
}
106+
107+
@Test
108+
fun whenSubdomainDoesNotSupportVersionThenUaOmitsVersionComponent() {
109+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
110+
val actual = testee.userAgent(NO_VERSION_SUBDOMAIN)
111+
assertTrue("$actual does not match expected regex", ValidationRegex.noVersion.matches(actual))
112+
}
113+
114+
@Test
115+
fun whenDomainSupportsVersionThenUaIncludesVersionComponentInUsualLocation() {
116+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
117+
val actual = testee.userAgent(DOMAIN)
118+
assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
119+
}
120+
121+
@Test
122+
fun whenUserAgentIsForASiteThatShouldUseDesktopAgentThenReturnDesktopUserAgent() {
123+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
124+
val actual = testee.userAgent(DESKTOP_ONLY_SITE)
125+
assertTrue("$actual does not match expected regex", ValidationRegex.desktop.matches(actual))
126+
}
127+
128+
@Test
129+
fun whenUserAgentIsForASiteThatShouldUseDesktopAgentButContainsAnExclusionThenDoNotReturnConvertedUserAgent() {
130+
testee = UserAgentProvider(Agent.DEFAULT, deviceInfo)
131+
val actual = testee.userAgent(DESKTOP_ONLY_SITE_EXCEPTION)
132+
assertTrue("$actual does not match expected regex", ValidationRegex.converted.matches(actual))
133+
}
132134

133135
companion object {
134136
const val DOMAIN = "http://example.com"

app/src/androidTest/java/com/duckduckgo/app/global/api/ApiRequestInterceptorTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class ApiRequestInterceptorTest {
5454
assertTrue(result.matches(regex))
5555
}
5656

57-
// @Test
58-
// fun whenAPIRequestIsRqPixelThenOverrideHeader() {
59-
// val fakeChain = FakeChain("https://improving.duckduckgo.com/t/rq_0")
60-
//
61-
// val response = testee.intercept(fakeChain)
62-
// val header = response.request.header(Header.USER_AGENT)!!
63-
// val regex = "Mozilla/.* \\(Linux; Android.*\\) AppleWebKit/.* \\(KHTML, like Gecko\\) Version/.* Chrome/.* Mobile DuckDuckGo/.* Safari/.*".toRegex()
64-
// assertTrue(header.matches(regex))
65-
// }
57+
@Test
58+
fun whenAPIRequestIsRqPixelThenOverrideHeader() {
59+
val fakeChain = FakeChain("https://improving.duckduckgo.com/t/rq_0")
60+
61+
val response = testee.intercept(fakeChain)
62+
val header = response.request.header(Header.USER_AGENT)!!
63+
val regex = "Mozilla/.* \\(Linux; Android.*\\) AppleWebKit/.* \\(KHTML, like Gecko\\) Version/.* Chrome/.* Mobile DuckDuckGo/.* Safari/.*".toRegex()
64+
assertTrue(header.matches(regex))
65+
}
6666
}

app/src/main/java/com/duckduckgo/app/browser/useragent/UserAgentProvider.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class UserAgentProvider constructor(private val defaultUserAgent: String, privat
5353
*/
5454
fun userAgent(url: String? = null, isDesktop: Boolean = false): String {
5555
val host = url?.toUri()?.host
56-
val omitApplicationComponent = if (host != null) sitesWithUserAgent.any { UriString.sameOrSubdomain(host, it) } else false
56+
val omitApplicationComponent = if (host != null) sitesThatOmitApplication.any { UriString.sameOrSubdomain(host, it) } else false
5757
val omitVersionComponent = if (host != null) sitesThatOmitVersion.any { UriString.sameOrSubdomain(host, it) } else false
5858
val shouldUseDesktopAgent =
5959
if (url != null && host != null) {
@@ -66,7 +66,7 @@ class UserAgentProvider constructor(private val defaultUserAgent: String, privat
6666
prefix = prefix.replace(AgentRegex.version, "")
6767
}
6868

69-
val application = if (omitApplicationComponent) applicationComponent else null
69+
val application = if (!omitApplicationComponent) applicationComponent else null
7070
return concatWithSpaces(prefix, application, safariComponent)
7171
}
7272

@@ -122,10 +122,6 @@ class UserAgentProvider constructor(private val defaultUserAgent: String, privat
122122
"chase.com"
123123
)
124124

125-
val sitesWithUserAgent = listOf(
126-
"wikipedia.org"
127-
)
128-
129125
val sitesThatShouldUseDesktopAgent = listOf(
130126
DesktopAgentSiteOnly("m.facebook.com", listOf("dialog", "sharer"))
131127
)

app/version/release-notes

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
Mended a few broken pipes.
1+
What's new in this release?
2+
This update resolves an issue blocking users from accessing websites that use Akamai
3+
4+
Join our fully distributed team and help raise the standard of trust online — from anywhere! https://duckduckgo.com/hiring
5+
6+
Have feedback?
7+
You can always reach us at https://duckduckgo.com/feedback.

app/version/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=5.85.2
1+
VERSION=5.85.3

0 commit comments

Comments
 (0)
0