diff --git a/vector/src/test/java/im/vector/app/features/onboarding/StartAuthenticationFlowUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/onboarding/StartAuthenticationFlowUseCaseTest.kt index 632272caa2..93bfc045de 100644 --- a/vector/src/test/java/im/vector/app/features/onboarding/StartAuthenticationFlowUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/onboarding/StartAuthenticationFlowUseCaseTest.kt @@ -131,6 +131,21 @@ class StartAuthenticationFlowUseCaseTest { verifyClearsAndThenStartsLogin(A_HOMESERVER_CONFIG) } + @Test + fun `given identity providers and login supports SSO with OIDC compatibility then prefers Sso for compatibility`() = runTest { + val loginResult = aLoginResult(supportedLoginTypes = SSO_LOGIN_TYPE, ssoProviders = SSO_IDENTITY_PROVIDERS, hasOidcCompatibilityFlow = true) + fakeAuthenticationService.givenLoginFlow(A_HOMESERVER_CONFIG, loginResult) + + val result = useCase.execute(A_HOMESERVER_CONFIG) + + result shouldBeEqualTo expectedResult( + supportedLoginTypes = SSO_LOGIN_TYPE, + preferredLoginMode = LoginMode.Sso(SsoState.IdentityProviders(SSO_IDENTITY_PROVIDERS), hasOidcCompatibilityFlow = true), + hasOidcCompatibilityFlow = true + ) + verifyClearsAndThenStartsLogin(A_HOMESERVER_CONFIG) + } + private fun aLoginResult( supportedLoginTypes: List, ssoProviders: List = FALLBACK_SSO_IDENTITY_PROVIDERS, @@ -150,7 +165,8 @@ class StartAuthenticationFlowUseCaseTest { isHomeserverOutdated: Boolean = false, preferredLoginMode: LoginMode = LoginMode.Unsupported, supportedLoginTypes: List = emptyList(), - homeserverSourceUrl: String = A_HOMESERVER_CONFIG.homeServerUri.toString() + homeserverSourceUrl: String = A_HOMESERVER_CONFIG.homeServerUri.toString(), + hasOidcCompatibilityFlow: Boolean = false ) = StartAuthenticationResult( isHomeserverOutdated, SelectedHomeserverState( @@ -158,7 +174,7 @@ class StartAuthenticationFlowUseCaseTest { upstreamUrl = A_DECLARED_HOMESERVER_URL, preferredLoginMode = preferredLoginMode, supportedLoginTypes = supportedLoginTypes, - hasOidcCompatibilityFlow = false + hasOidcCompatibilityFlow = hasOidcCompatibilityFlow ) )