diff --git a/feature/login-check/src/main/java/com/simprints/feature/logincheck/LoginCheckViewModel.kt b/feature/login-check/src/main/java/com/simprints/feature/logincheck/LoginCheckViewModel.kt index 0ae310033d..59c187f48f 100644 --- a/feature/login-check/src/main/java/com/simprints/feature/logincheck/LoginCheckViewModel.kt +++ b/feature/login-check/src/main/java/com/simprints/feature/logincheck/LoginCheckViewModel.kt @@ -139,7 +139,7 @@ class LoginCheckViewModel @Inject internal constructor( } } - private suspend fun proceedWithAction(actionRequest: ActionRequest) = viewModelScope.launch { + private fun proceedWithAction(actionRequest: ActionRequest) = viewModelScope.launch { updateProjectInCurrentSession() updateStoredUserId(actionRequest.userId) awaitAll( diff --git a/infra/auth-logic/src/main/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticator.kt b/infra/auth-logic/src/main/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticator.kt index c45f4b046d..8fdc5ebc6b 100644 --- a/infra/auth-logic/src/main/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticator.kt +++ b/infra/auth-logic/src/main/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticator.kt @@ -1,5 +1,6 @@ package com.simprints.infra.authlogic.authenticator +import com.simprints.fingerprint.infra.scanner.data.FirmwareRepository import com.simprints.infra.authlogic.authenticator.remote.AuthenticationRemoteDataSource import com.simprints.infra.authlogic.integrity.IntegrityTokenRequester import com.simprints.infra.authlogic.integrity.exceptions.RequestingIntegrityTokenException @@ -21,6 +22,7 @@ internal class ProjectAuthenticator @Inject constructor( private val signerManager: SignerManager, private val authenticationRemoteDataSource: AuthenticationRemoteDataSource, private val integrityTokenRequester: IntegrityTokenRequester, + private val firmwareRepository: FirmwareRepository, ) { /** @@ -41,6 +43,9 @@ internal class ProjectAuthenticator @Inject constructor( val config = configManager.getProjectConfiguration() fetchProjectLongConsentTexts(config.general.languageOptions, config.projectId) + + // This is safe to call even on face-only projects as it will do nothing in such cases + firmwareRepository.updateStoredFirmwareFilesWithLatest() } private suspend fun prepareAuthRequestParameters( diff --git a/infra/auth-logic/src/test/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticatorTest.kt b/infra/auth-logic/src/test/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticatorTest.kt index 17e88018c8..70d346c546 100644 --- a/infra/auth-logic/src/test/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticatorTest.kt +++ b/infra/auth-logic/src/test/java/com/simprints/infra/authlogic/authenticator/ProjectAuthenticatorTest.kt @@ -1,6 +1,7 @@ package com.simprints.infra.authlogic.authenticator import com.google.android.play.core.integrity.model.IntegrityErrorCode +import com.simprints.fingerprint.infra.scanner.data.FirmwareRepository import com.simprints.infra.authlogic.authenticator.remote.AuthenticationRemoteDataSource import com.simprints.infra.authlogic.integrity.IntegrityTokenRequester import com.simprints.infra.authlogic.integrity.exceptions.RequestingIntegrityTokenException @@ -42,6 +43,9 @@ class ProjectAuthenticatorTest { @MockK private lateinit var integrityTokenRequester: IntegrityTokenRequester + @MockK + private lateinit var firmwareRepository: FirmwareRepository + private lateinit var authenticator: ProjectAuthenticator @Before @@ -55,6 +59,7 @@ class ProjectAuthenticatorTest { signerManager, authenticationRemoteDataSource, integrityTokenRequester, + firmwareRepository, ) } @@ -137,6 +142,14 @@ class ProjectAuthenticatorTest { coVerify(exactly = 1) { configManager.getPrivacyNotice(PROJECT_ID, LANGUAGE_2) } } + @Test + fun `authenticate should fetch the firmware if needed`() = + runTest(StandardTestDispatcher()) { + authenticator.authenticate(NonceScope(PROJECT_ID, DEVICE_ID), PROJECT_SECRET) + + coVerify(exactly = 1) { firmwareRepository.updateStoredFirmwareFilesWithLatest() } + } + @Test fun integrityFailed_shouldThrowRightException() = runTest(StandardTestDispatcher()) { coEvery { integrityTokenRequester.getToken(any()) } throws RequestingIntegrityTokenException(