Test case for OIDC compatibility

This commit is contained in:
Hugh Nimmo-Smith 2023-01-11 11:54:37 +00:00
parent 624e2ffb19
commit 51f227a13b

View file

@ -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<String>,
ssoProviders: List<SsoIdentityProvider> = FALLBACK_SSO_IDENTITY_PROVIDERS,
@ -150,7 +165,8 @@ class StartAuthenticationFlowUseCaseTest {
isHomeserverOutdated: Boolean = false,
preferredLoginMode: LoginMode = LoginMode.Unsupported,
supportedLoginTypes: List<String> = 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
)
)