Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
) {

/**
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -42,6 +43,9 @@ class ProjectAuthenticatorTest {
@MockK
private lateinit var integrityTokenRequester: IntegrityTokenRequester

@MockK
private lateinit var firmwareRepository: FirmwareRepository

private lateinit var authenticator: ProjectAuthenticator

@Before
Expand All @@ -55,6 +59,7 @@ class ProjectAuthenticatorTest {
signerManager,
authenticationRemoteDataSource,
integrityTokenRequester,
firmwareRepository,
)
}

Expand Down Expand Up @@ -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(
Expand Down