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 @@ -72,7 +72,12 @@ internal class BuildStepsUseCase @Inject constructor(
is ActionRequest.VerifyActionRequest -> listOf(
buildSetupStep(),
buildAgeSelectionStepIfNeeded(action, projectConfiguration),
buildFetchGuidStep(action.projectId, action.verifyGuid),
buildFetchGuidStepIfNeeded(
projectId = action.projectId,
subjectId = action.verifyGuid,
biometricDataSource = action.biometricDataSource,
callerPackageName = action.callerPackageName
),
buildConsentStep(ConsentType.VERIFY),
buildModalityCaptureAndMatchStepsForVerify(action, projectConfiguration)
)
Expand Down Expand Up @@ -226,14 +231,26 @@ internal class BuildStepsUseCase @Inject constructor(
)
)

private fun buildFetchGuidStep(projectId: String, subjectId: String) = listOf(
Step(
id = StepId.FETCH_GUID,
navigationActionId = R.id.action_orchestratorFragment_to_fetchSubject,
destinationId = FetchSubjectContract.DESTINATION,
payload = FetchSubjectContract.getArgs(projectId, subjectId),
private fun buildFetchGuidStepIfNeeded(
projectId: String,
subjectId: String,
biometricDataSource: String,
callerPackageName: String
) = when (BiometricDataSource.fromString(
value = biometricDataSource,
callerPackageName = callerPackageName
)) {
BiometricDataSource.Simprints -> listOf(
Step(
id = StepId.FETCH_GUID,
navigationActionId = R.id.action_orchestratorFragment_to_fetchSubject,
destinationId = FetchSubjectContract.DESTINATION,
payload = FetchSubjectContract.getArgs(projectId, subjectId),
)
)
)

is BiometricDataSource.CommCare -> emptyList()
}

private fun buildConsentStep(consentType: ConsentType) = listOf(
Step(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,32 @@ class BuildStepsUseCaseTest {
)
}

@Test
fun `build - verify action - co-sync data source - returns steps without fetch GUID`() {
val projectConfiguration = mockCommonProjectConfiguration()
val ageGroup = AgeGroup(18, 60)
every { secugenSimMatcher.allowedAgeRange } returns ageGroup
every { nec.allowedAgeRange } returns ageGroup
every { projectConfiguration.face?.rankOne?.allowedAgeRange } returns ageGroup

val action = mockk<ActionRequest.VerifyActionRequest>(relaxed = true)
every { action.getSubjectAgeIfAvailable() } returns 25 // Subject age within the supported range
every { action.biometricDataSource } returns "COMMCARE"
val steps = useCase.build(action, projectConfiguration)

assertStepOrder(steps,
StepId.SETUP,
// no StepId.FETCH_GUID
StepId.CONSENT,
StepId.FINGERPRINT_CAPTURE,
StepId.FINGERPRINT_CAPTURE,
StepId.FACE_CAPTURE,
StepId.FINGERPRINT_MATCHER,
StepId.FINGERPRINT_MATCHER,
StepId.FACE_MATCHER
)
}

@Test
fun `build - enrol action - age restriction - subject age not supported - throws SubjectAgeNotSupportedException`() {
val projectConfiguration = mockCommonProjectConfiguration()
Expand Down