Skip to content

Commit

Permalink
Merge pull request #81 from velocitycareerlabs/dev-to-rc
Browse files Browse the repository at this point in the history
Dev to rc
  • Loading branch information
michaelavoyan authored Jan 22, 2024
2 parents 8821d23 + b624842 commit f42c1cc
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
4 changes: 2 additions & 2 deletions VCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdk 24
targetSdk 33
versionName "1.23.1"
versionCode 120
versionName "1.23.2"
versionCode 121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.velocitycareerlabs.impl.extensions.encodeToBase64URL

data class VCLDidJwk(
/**
* The did in jwk format encoded to Base64 format
* The did in jwk format encoded to Base64 format - the holder did
*/
val did: String,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ data class VCLExchangeDescriptor(
) {

val processUri: String get() = presentationSubmission.progressUri
val did: String get() = presentationSubmission.iss
val exchangeId: String get() = submissionResult.exchange.id
val sessionToken: VCLToken get() = submissionResult.sessionToken

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class VCLIdentificationSubmission(
verifiableCredentials: List<VCLVerifiableCredential>? = null
) : VCLSubmission(
submitUri = credentialManifest.submitPresentationUri,
iss = credentialManifest.iss,
exchangeId = credentialManifest.exchangeId,
presentationDefinitionId = credentialManifest.presentationDefinitionId,
verifiableCredentials = verifiableCredentials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class VCLPresentationSubmission(
verifiableCredentials: List<VCLVerifiableCredential>
) : VCLSubmission(
submitUri = presentationRequest.submitPresentationUri,
iss = presentationRequest.iss,
exchangeId = presentationRequest.exchangeId,
presentationDefinitionId = presentationRequest.presentationDefinitionId,
verifiableCredentials = verifiableCredentials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.util.*

abstract class VCLSubmission(
val submitUri: String,
val iss: String,
val exchangeId: String,
val presentationDefinitionId: String,
val verifiableCredentials: List<VCLVerifiableCredential>? = null,
Expand All @@ -24,9 +23,7 @@ abstract class VCLSubmission(
val jti = UUID.randomUUID().toString()
val submissionId = UUID.randomUUID().toString()

val payload get() = generatePayload()

private fun generatePayload(): JSONObject {
internal fun generatePayload(iss: String?): JSONObject {
val retVal = JSONObject()
retVal.putOpt(VCLSubmission.KeyJti, jti)
.putOpt(VCLSubmission.KeyIss, iss)
Expand All @@ -49,7 +46,7 @@ abstract class VCLSubmission(
return retVal
}

fun generateRequestBody(jwt: VCLJwt) = JSONObject()
fun generateRequestBody(jwt: VCLJwt): JSONObject = JSONObject()
.putOpt(VCLSubmission.KeyExchangeId, exchangeId)
.putOpt(VCLSubmission.KeyJwtVp, jwt.encodedJwt)
.putOpt(VCLSubmission.KeyPushDelegate, pushDelegate?.toJsonObject())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal class SubmissionUseCaseImpl(
kid = didJwk?.kid,
jwtDescriptor = VCLJwtDescriptor(
keyId = didJwk?.keyId,
payload = submission.payload,
payload = submission.generatePayload(didJwk?.did),
jti = submission.jti,
iss = submission.iss
iss = didJwk?.did ?: ""
),
remoteCryptoServicesToken = remoteCryptoServicesToken,
completionBlock = { signedJwtResult ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,73 @@

package io.velocitycareerlabs.entities

import io.velocitycareerlabs.api.entities.VCLCredentialManifest
import io.velocitycareerlabs.api.entities.VCLIdentificationSubmission
import io.velocitycareerlabs.api.entities.VCLPresentationSubmission
import io.velocitycareerlabs.api.entities.VCLPushDelegate
import io.velocitycareerlabs.api.entities.VCLSubmission
import io.velocitycareerlabs.api.entities.VCLVerifiedProfile
import io.velocitycareerlabs.impl.extensions.toJsonObject
import io.velocitycareerlabs.impl.extensions.toList
import io.velocitycareerlabs.infrastructure.resources.CommonMocks
import io.velocitycareerlabs.infrastructure.resources.valid.JwtServiceMocks
import io.velocitycareerlabs.infrastructure.resources.valid.PresentationSubmissionMocks
import io.velocitycareerlabs.infrastructure.resources.valid.VerifiedProfileMocks
import org.junit.Before
import org.junit.Test

class VCLSubmissionTest {
internal lateinit var subject: VCLSubmission
private lateinit var subjectPresentationSubmission: VCLSubmission
private lateinit var subjectIdentificationSubmission: VCLSubmission

private val issuingIss = "issuing iss"
private val inspectionIss = "inspection iss"

@Before
fun setUp() {
subject = VCLPresentationSubmission(
subjectPresentationSubmission = VCLPresentationSubmission(
PresentationSubmissionMocks.PresentationRequest,
PresentationSubmissionMocks.SelectionsList
)
subjectIdentificationSubmission = VCLIdentificationSubmission(
VCLCredentialManifest(
jwt = CommonMocks.JWT,
verifiedProfile = VCLVerifiedProfile(VerifiedProfileMocks.VerifiedProfileIssuerJsonStr1.toJsonObject()!!)
),
PresentationSubmissionMocks.SelectionsList
)
}

@Test
fun testPayload() {
assert(subject.payload.optString(VCLSubmission.KeyJti) == subject.jti)
assert(subject.payload.optString(VCLSubmission.KeyIss) == subject.iss)
val presentationSubmissionPayload = subjectPresentationSubmission.generatePayload(inspectionIss)
assert(presentationSubmissionPayload.optString(VCLSubmission.KeyJti) == subjectPresentationSubmission.jti)
assert(presentationSubmissionPayload.optString(VCLSubmission.KeyIss) == inspectionIss)

val identificationSubmissionPayload = subjectIdentificationSubmission.generatePayload(issuingIss)
assert(identificationSubmissionPayload.optString(VCLSubmission.KeyJti) == subjectIdentificationSubmission.jti)
assert(identificationSubmissionPayload.optString(VCLSubmission.KeyIss) == issuingIss)
}

@Test
fun testPushDelegate() {
assert(subject.pushDelegate!!.pushUrl == PresentationSubmissionMocks.PushDelegate.pushUrl)
assert(subject.pushDelegate!!.pushToken == PresentationSubmissionMocks.PushDelegate.pushToken)
assert(subjectPresentationSubmission.pushDelegate!!.pushUrl == PresentationSubmissionMocks.PushDelegate.pushUrl)
assert(subjectPresentationSubmission.pushDelegate!!.pushToken == PresentationSubmissionMocks.PushDelegate.pushToken)
}

@Test
fun testRequestBody() {
val requestBodyJsonObj = subject.generateRequestBody(JwtServiceMocks.JWT)
assert(requestBodyJsonObj.optString(VCLSubmission.KeyExchangeId) == subject.exchangeId)
val requestBodyJsonObj = subjectPresentationSubmission.generateRequestBody(JwtServiceMocks.JWT)
assert(requestBodyJsonObj.optString(VCLSubmission.KeyExchangeId) == subjectPresentationSubmission.exchangeId)
assert(requestBodyJsonObj.optJSONArray(VCLSubmission.KeyContext)!!.toList() == VCLSubmission.ValueContextList)

val pushDelegateBodyJsonObj = requestBodyJsonObj.optJSONObject(VCLSubmission.KeyPushDelegate)!!

assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushUrl) == PresentationSubmissionMocks.PushDelegate.pushUrl)
assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushToken) == PresentationSubmissionMocks.PushDelegate.pushToken)

assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushUrl) == subject.pushDelegate!!.pushUrl)
assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushToken) == subject.pushDelegate!!.pushToken)
assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushUrl) == subjectPresentationSubmission.pushDelegate!!.pushUrl)
assert(pushDelegateBodyJsonObj.optString(VCLPushDelegate.KeyPushToken) == subjectPresentationSubmission.pushDelegate!!.pushToken)
}

@Test
Expand Down

0 comments on commit f42c1cc

Please sign in to comment.