Skip to content

Commit

Permalink
Merge pull request #13505 from woocommerce/issue/13467-improve-authen…
Browse files Browse the repository at this point in the history
…ticated-webview-3

Authenticated WebView improvement [Part 3]
  • Loading branch information
irfano authored Feb 17, 2025
2 parents 78257cc + 441ddea commit d7f1271
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WebViewAuthenticationFlowResolver @Inject constructor(
) {
// A list of domains that we know that wordpress.com supports redirecting to
private val wpComAuthAcceptedDomains
get() = listOf("wordpress.com", "wp.com", "jetpack.com", "woocommerce.com")
get() = listOf("wordpress.com", "wp.com", "jetpack.com", "jetpack.wordpress.com", "woocommerce.com")

fun resolve(url: String): WebViewAuthenticationFlow {
val currentSite = selectedSite.getOrNull()
Expand All @@ -24,8 +24,7 @@ class WebViewAuthenticationFlowResolver @Inject constructor(

return if (isWPComAuthenticated) {
when {
wpComAuthAcceptedDomains.any { it == urlDomain } ||
(currentSite?.isWPComAtomic == true && url.isPartOf(currentSite)) -> {
wpComAuthAcceptedDomains.any { it == urlDomain } -> {
WebViewAuthenticationFlow.WPCom
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ class WebViewAuthenticationFlowResolverTest {
assertThat(result).isEqualTo(WebViewAuthenticationFlowResolver.WebViewAuthenticationFlow.WPCom)
}

@Test
fun `given WPCom authenticated and an atomic site, when resolving the authentication flow, then it should return WPCom`() {
givenWPComAuthenticated()
givenSite {
setIsWPComAtomic(true)
url = "https://example.com"
}
val url = "https://example.com/test"

val result = sut.resolve(url)

assertThat(result).isEqualTo(WebViewAuthenticationFlowResolver.WebViewAuthenticationFlow.WPCom)
}

@Test
fun `given WPCom authenticated and a Jetpack SSO site, when resolving the authentication flow, then it should return JetpackSSO`() {
givenWPComAuthenticated()
Expand Down

0 comments on commit d7f1271

Please sign in to comment.