Skip to content

Commit

Permalink
Merge pull request #124 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
New Age verification attestation support, adjusted tests and authoriz…
  • Loading branch information
stzouvaras authored Jun 10, 2024
2 parents 782c963 + 59cd1b0 commit c81ca11
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
val credentialOfferScheme = "openid-credential-offer"
val credentialOfferHost = "*"

val openId4VciAuthorizationScheme = "eudi-issuance"
val openId4VciAuthorizationScheme = "eu.europa.ec.euidi"
val openId4VciAuthorizationHost = "authorization"

val storedVersion = getProperty<String>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fun DocumentIdentifier.toUiName(resourceProvider: ResourceProvider): String {
return when (this) {
is DocumentIdentifier.PID -> resourceProvider.getString(R.string.pid)
is DocumentIdentifier.MDL -> resourceProvider.getString(R.string.mdl)
is DocumentIdentifier.AGE -> resourceProvider.getString(R.string.age_verification)
is DocumentIdentifier.SAMPLE -> resourceProvider.getString(R.string.load_sample_data)
is DocumentIdentifier.OTHER -> docType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ object TestsData {
const val mockedMdlDocName = "mDL"
const val mockedPidId = "000001"
const val mockedMdlId = "000002"
const val mockedAgeVerificationId = "000003"
const val mockedUserFirstName = "JAN"
const val mockedUserBase64Portrait = "SE"
const val mockedDocUiNamePid = "National ID"
const val mockedDocUiNameMdl = "Driving License"
const val mockedDocUiNameAge = "Age Verification"
const val mockedDocUiNameSampleData = "Load Sample Documents"
const val mockedNoUserFistNameFound = ""
const val mockedNoUserBase64PortraitFound = ""
Expand All @@ -78,6 +80,8 @@ object TestsData {
const val mockedPidDocType = "eu.europa.ec.eudiw.pid.1"
const val mockedPidCodeName = "eu.europa.ec.eudiw.pid.1"
const val mockedMdlDocType = "org.iso.18013.5.1.mDL"
const val mockedAgeVerificationDocType = "eu.europa.ec.eudiw.pseudonym.age_over_18.1"
const val mockedAgeVerificationCodeName = "eu.europa.ec.eudiw.pseudonym.age_over_18.1"
const val mockedMdlCodeName = "org.iso.18013.5.1"

val mockedValidReaderAuth = ReaderAuth(
Expand Down Expand Up @@ -174,6 +178,25 @@ object TestsData {
readerAuth = mockedValidReaderAuth
)

val mockedAgeVerificationWithBasicFieldsDocRequest = DocRequest(
docType = mockedAgeVerificationDocType,
requestItems = listOf(
DocItem(
namespace = mockedAgeVerificationCodeName,
elementIdentifier = "age_over_18"
),
DocItem(
namespace = mockedAgeVerificationCodeName,
elementIdentifier = "expiry_date"
),
DocItem(
namespace = mockedAgeVerificationCodeName,
elementIdentifier = "issuing_country",
)
),
readerAuth = mockedValidReaderAuth
)

val mockedValidPidWithBasicFieldsRequestDocument = RequestDocument(
documentId = mockedPidId,
docType = mockedPidDocType,
Expand Down Expand Up @@ -364,6 +387,13 @@ object TestsData {
available = true
)

val mockedAgeOptionItemUi = DocumentOptionItemUi(
text = mockedDocUiNameAge,
icon = AppIcons.Id,
type = DocumentIdentifier.AGE,
available = true
)

val mockedSampleDataOptionItemUi = DocumentOptionItemUi(
text = mockedDocUiNameSampleData,
icon = AppIcons.Id,
Expand Down Expand Up @@ -497,6 +527,12 @@ object TestsData {
value = testFieldUi.value,
)

is DocumentIdentifier.AGE -> mockCreateOptionalFieldForAgeVerification(
docId = transformedRequestDataUi.documentId,
elementIdentifier = testFieldUi.elementIdentifier,
value = testFieldUi.value,
)

is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException
}

Expand Down Expand Up @@ -572,6 +608,25 @@ object TestsData {
)
}

private fun mockCreateOptionalFieldForAgeVerification(
docId: String,
elementIdentifier: String,
value: String,
checked: Boolean = true,
enabled: Boolean = true,
): RequestDataUi.OptionalField<Event> {
val uniqueId = mockedAgeVerificationDocType + elementIdentifier + docId
return mockCreateOptionalField(
documentIdentifierUi = DocumentIdentifier.MDL,
uniqueId = uniqueId,
elementIdentifier = elementIdentifier,
value = value,
checked = checked,
enabled = enabled,
event = Event.UserIdentificationClicked(itemId = uniqueId)
)
}

private fun mockCreateOptionalField(
documentIdentifierUi: DocumentIdentifier,
uniqueId: String,
Expand Down Expand Up @@ -625,6 +680,13 @@ object TestsData {
docRequest = mockedMdlWithBasicFieldsDocRequest
}

is DocumentIdentifier.AGE -> {
namespace = mockedAgeVerificationCodeName
docId = mockedAgeVerificationId
docType = mockedAgeVerificationDocType
docRequest = mockedAgeVerificationWithBasicFieldsDocRequest
}

is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ sealed interface DocumentIdentifier {
get() = "load_sample_documents"
}

data object AGE : DocumentIdentifier {
override val nameSpace: String
get() = "eu.europa.ec.eudiw.pseudonym.age_over_18.1"
override val docType: String
get() = "eu.europa.ec.eudiw.pseudonym.age_over_18.1"
}

data class OTHER(
override val nameSpace: String,
override val docType: String,
Expand All @@ -49,7 +56,7 @@ sealed interface DocumentIdentifier {

fun DocumentIdentifier.isSupported(): Boolean {
return when (this) {
is DocumentIdentifier.PID, DocumentIdentifier.MDL -> true
is DocumentIdentifier.PID, DocumentIdentifier.MDL, DocumentIdentifier.AGE -> true
is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> false
}
}
Expand All @@ -58,6 +65,7 @@ fun String.toDocumentIdentifier(): DocumentIdentifier = when (this) {
"eu.europa.ec.eudiw.pid.1" -> DocumentIdentifier.PID
"org.iso.18013.5.1.mDL" -> DocumentIdentifier.MDL
"load_sample_documents" -> DocumentIdentifier.SAMPLE
"eu.europa.ec.eudiw.pseudonym.age_over_18.1" -> DocumentIdentifier.AGE
else -> DocumentIdentifier.OTHER(
nameSpace = this,
docType = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ class AddDocumentInteractorImpl(
text = DocumentIdentifier.MDL.toUiName(resourceProvider),
icon = AppIcons.Id,
type = DocumentIdentifier.MDL,
available = canCreateMdl(flowType)
available = canCreateExtraDocument(flowType)
),
DocumentOptionItemUi(
text = DocumentIdentifier.AGE.toUiName(resourceProvider),
icon = AppIcons.Id,
type = DocumentIdentifier.AGE,
available = canCreateExtraDocument(flowType)
)
)
if (flowType == IssuanceFlowUiConfig.NO_DOCUMENT) {
Expand Down Expand Up @@ -147,6 +153,6 @@ class AddDocumentInteractorImpl(
}
}

private fun canCreateMdl(flowType: IssuanceFlowUiConfig): Boolean =
private fun canCreateExtraDocument(flowType: IssuanceFlowUiConfig): Boolean =
flowType != IssuanceFlowUiConfig.NO_DOCUMENT
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import eu.europa.ec.authenticationlogic.controller.authentication.DeviceAuthenti
import eu.europa.ec.authenticationlogic.model.BiometricCrypto
import eu.europa.ec.commonfeature.config.IssuanceFlowUiConfig
import eu.europa.ec.commonfeature.interactor.DeviceAuthenticationInteractor
import eu.europa.ec.commonfeature.util.TestsData.mockedAgeOptionItemUi
import eu.europa.ec.commonfeature.util.TestsData.mockedMdlOptionItemUi
import eu.europa.ec.commonfeature.util.TestsData.mockedPidId
import eu.europa.ec.commonfeature.util.TestsData.mockedPidOptionItemUi
Expand Down Expand Up @@ -128,6 +129,9 @@ class TestAddDocumentInteractor {
mockedMdlOptionItemUi.copy(
available = false
),
mockedAgeOptionItemUi.copy(
available = false
),
mockedSampleDataOptionItemUi
)
),
Expand Down Expand Up @@ -160,7 +164,8 @@ class TestAddDocumentInteractor {
AddDocumentInteractorPartialState.Success(
options = listOf(
mockedPidOptionItemUi,
mockedMdlOptionItemUi
mockedMdlOptionItemUi,
mockedAgeOptionItemUi
)
),
awaitItem()
Expand Down
2 changes: 2 additions & 0 deletions resources-logic/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<!-- Document Types -->
<string name="pid">National ID</string>
<string name="mdl">Driving License</string>
<string name="age_verification">Age Verification</string>
<string name="load_sample_data">Load Sample Documents</string>

<!-- Biometric prompt -->
Expand Down Expand Up @@ -166,6 +167,7 @@
<!-- Document Details -->
<string name="document_details_portrait_readable_identifier">Shown above</string>
<string name="vehicle_category_code">Vehicle category code</string>
<string name="user_pseudonym">User Pseudonym</string>
<string name="document_details_boolean_item_true_readable_value">yes</string>
<string name="document_details_boolean_item_false_readable_value">no</string>

Expand Down
4 changes: 4 additions & 0 deletions test-feature/src/main/java/eu/europa/ec/testfeature/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.mockito.kotlin.whenever

private const val mockedDocUiNamePid = "National ID"
private const val mockedDocUiNameMdl = "Driving License"
private const val mockedDocUiNameAgeVerification = "Age Verification"
private const val mockedDocUiNameSampleData = "Load Sample Documents"

@VisibleForTesting(otherwise = VisibleForTesting.NONE)
Expand All @@ -41,6 +42,9 @@ object MockResourceProviderForStringCalls {

whenever(resourceProvider.getString(R.string.load_sample_data))
.thenReturn(mockedDocUiNameSampleData)

whenever(resourceProvider.getString(R.string.age_verification))
.thenReturn(mockedDocUiNameAgeVerification)
}

/**
Expand Down

0 comments on commit c81ca11

Please sign in to comment.