From 13eb7501a8eede67413431d0d52ebe3008c833ae Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:49:41 +0200 Subject: [PATCH] chore: ebsi-ct did update, sdjwt, ktor version updates (#4) --- build.gradle.kts | 2 +- .../kotlin/id/walt/oid4vc/EBSITestWallet.kt | 2 +- .../id/walt/oid4vc/EBSI_Conformance_Test.kt | 71 ++++++++----------- 3 files changed, 33 insertions(+), 42 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f3f04d2..94276f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -64,7 +64,7 @@ kotlin { isMingwX64 -> mingwX64("native") else -> throw GradleException("Host OS is not supported in Kotlin/Native.") } - val ktor_version = "2.3.4" + val ktor_version = "2.3.5" sourceSets { diff --git a/src/jvmTest/kotlin/id/walt/oid4vc/EBSITestWallet.kt b/src/jvmTest/kotlin/id/walt/oid4vc/EBSITestWallet.kt index 5f2db51..1bee49e 100644 --- a/src/jvmTest/kotlin/id/walt/oid4vc/EBSITestWallet.kt +++ b/src/jvmTest/kotlin/id/walt/oid4vc/EBSITestWallet.kt @@ -39,7 +39,7 @@ import java.util.* const val EBSI_WALLET_PORT = 8011 const val EBSI_WALLET_BASE_URL = "http://localhost:${EBSI_WALLET_PORT}" const val EBSI_WALLET_TEST_KEY = "{\"kty\":\"EC\",\"d\":\"AENUGJiPF4zRlF1uXV1NTWE5zcQPz-8Ie8SGLdQugec\",\"use\":\"sig\",\"crv\":\"P-256\",\"kid\":\"de8aca52c110485a87fa6fda8d1f2f4e\",\"x\":\"hJ0hFBtp72j1V2xugQI51ernWY_vPXzXjnEg7A709Fc\",\"y\":\"-Mm1j5Zz1mWJU7Nqylk0_6qKjZ5fn6ddzziEFscQPhQ\",\"alg\":\"ES256\"}" -const val EBSI_WALLET_TEST_DID = "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbrksdXfcbvmhgF2h7YfpxWuywkXxDZ7ohTPNPTQpD39Rm9WiBWuEpvvgtfuPHtHi2wTEkZ95KC2ijUMUowyKMueaMhtA5bLYkt9k8Y8Gq4sm6PyTCHTxuyedMMrBKdRXNZS" +const val EBSI_WALLET_TEST_DID = "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbrvNZGYo92og84YugxANd6yfYsq43i85BTx7KDWzNwVVrNiuNmgSSrC11kbg9qg1sm6TJh7soF5vDAgGRBF3wScih9gUCcH7H8Nxd9GAG8hN4AmJnoEtkeUrFU18eb6wNpc" class EBSITestWallet(config: CredentialWalletConfig): OpenIDCredentialWallet(EBSI_WALLET_BASE_URL, config) { private val sessionCache = mutableMapOf() private val ktorClient = HttpClient(Java) { diff --git a/src/jvmTest/kotlin/id/walt/oid4vc/EBSI_Conformance_Test.kt b/src/jvmTest/kotlin/id/walt/oid4vc/EBSI_Conformance_Test.kt index 1b5be7f..b03e367 100644 --- a/src/jvmTest/kotlin/id/walt/oid4vc/EBSI_Conformance_Test.kt +++ b/src/jvmTest/kotlin/id/walt/oid4vc/EBSI_Conformance_Test.kt @@ -26,8 +26,10 @@ import kotlinx.serialization.json.jsonPrimitive class EBSI_Conformance_Test: StringSpec({ - val VcTestsEnabled = true - val VpTestsEnabled = true + val VcTestsEnabled = false + val VpTestsEnabled = false + + val credentialOfferUrl = "https://api-conformance.ebsi.eu/conformance/v3/issuer-mock/initiate-credential-offer?credential_type=" lateinit var credentialWallet: EBSITestWallet lateinit var ebsiClientConfig: OpenIDClientConfig @@ -67,18 +69,10 @@ class EBSI_Conformance_Test: StringSpec({ */ "issue in-time credential".config(enabled = VcTestsEnabled) { forAll( - row("CTWalletCrossInTime", crossDeviceCredentialOfferRequestCaller), - row("CTWalletSameInTime", sameDeviceCredentialOfferRequestCaller), - ) { credentialType, credentialOfferRequestCall -> - val initCredentialOfferUrl = - URLBuilder("https://api-conformance.ebsi.eu/conformance/v3/issuer-mock/initiate-credential-offer?credential_type=$credentialType").run { - parameters.appendAll(StringValues.build { - append("client_id", credentialWallet.TEST_DID) - append("credential_offer_endpoint", "openid-credential-offer://") - }) - build() - } - val credentialOfferRequest = credentialOfferRequestCall(initCredentialOfferUrl) + row("${credentialOfferUrl}CTWalletSameInTime", credentialWallet.TEST_DID, sameDeviceCredentialOfferRequestCaller), + row("${credentialOfferUrl}CTWalletCrossInTime", credentialWallet.TEST_DID, crossDeviceCredentialOfferRequestCaller), + ) { url, clientId, credentialOfferRequestCall -> + val credentialOfferRequest = getCredentialOfferRequest(url, clientId, credentialOfferRequestCall) val credentialOffer = credentialWallet.resolveCredentialOffer(credentialOfferRequest) val credentialResponses = credentialWallet.executeFullAuthIssuance(credentialOffer, credentialWallet.TEST_DID, ebsiClientConfig) @@ -94,18 +88,10 @@ class EBSI_Conformance_Test: StringSpec({ */ "issue deferred credential".config(enabled = VcTestsEnabled) { forAll( - row("CTWalletCrossDeferred", crossDeviceCredentialOfferRequestCaller), - row("CTWalletSameDeferred", sameDeviceCredentialOfferRequestCaller), - ) { credentialType, credentialOfferRequestCall -> - val initCredentialOfferUrl = - URLBuilder("https://api-conformance.ebsi.eu/conformance/v3/issuer-mock/initiate-credential-offer?credential_type=$credentialType").run { - parameters.appendAll(StringValues.build { - append("client_id", credentialWallet.TEST_DID) - append("credential_offer_endpoint", "openid-credential-offer://") - }) - build() - } - val deferredCredentialOfferRequest = credentialOfferRequestCall(initCredentialOfferUrl) + row("${credentialOfferUrl}CTWalletSameDeferred", credentialWallet.TEST_DID, sameDeviceCredentialOfferRequestCaller), + row("${credentialOfferUrl}CTWalletCrossDeferred", credentialWallet.TEST_DID, crossDeviceCredentialOfferRequestCaller), + ) { url, clientId, credentialOfferRequestCall -> + val deferredCredentialOfferRequest = getCredentialOfferRequest(url, clientId, credentialOfferRequestCall) val deferredCredentialOffer = credentialWallet.resolveCredentialOffer(deferredCredentialOfferRequest) val deferredCredentialResponses = credentialWallet.executeFullAuthIssuance(deferredCredentialOffer, credentialWallet.TEST_DID, ebsiClientConfig) @@ -128,21 +114,13 @@ class EBSI_Conformance_Test: StringSpec({ */ "issue pre-authorized code credential".config(enabled = VcTestsEnabled) { forAll( - row("CTWalletCrossPreAuthorised", crossDeviceCredentialOfferRequestCaller), - row("CTWalletSamePreAuthorised", sameDeviceCredentialOfferRequestCaller), - ) { credentialType, credentialOfferRequestCall -> - val initCredentialOfferUrl = - URLBuilder("https://api-conformance.ebsi.eu/conformance/v3/issuer-mock/initiate-credential-offer?credential_type=$credentialType").run { - parameters.appendAll(StringValues.build { - append("client_id", credentialWallet.TEST_DID) - append("credential_offer_endpoint", "openid-credential-offer://") - }) - build() - } - val preAuthCredentialOfferRequest = credentialOfferRequestCall(initCredentialOfferUrl) + row("${credentialOfferUrl}CTWalletSamePreAuthorised", credentialWallet.TEST_DID, sameDeviceCredentialOfferRequestCaller), + row("${credentialOfferUrl}CTWalletCrossPreAuthorised", credentialWallet.TEST_DID, crossDeviceCredentialOfferRequestCaller), + ) { url, clientId, credentialOfferRequestCall -> + val preAuthCredentialOfferRequest = getCredentialOfferRequest(url, clientId, credentialOfferRequestCall) val preAuthCredentialOffer = credentialWallet.resolveCredentialOffer(preAuthCredentialOfferRequest) val preAuthCredentialResponses = credentialWallet.executePreAuthorizedCodeFlow( - preAuthCredentialOffer, credentialWallet.TEST_DID, ebsiClientConfig, "3818" + preAuthCredentialOffer, credentialWallet.TEST_DID, ebsiClientConfig, "9511" ) preAuthCredentialResponses.size shouldBe 1 preAuthCredentialResponses[0].isSuccess shouldBe true @@ -179,4 +157,17 @@ internal typealias credentialOfferRequestCaller = (initCredentialOfferUrl: Url) internal fun storeCredentials(vararg credentialResponses: CredentialResponse) = credentialResponses.forEach { val cred = VerifiableCredential.fromString(it.credential!!.jsonPrimitive.content) Custodian.getService().storeCredential(cred.id ?: randomUUID(), cred) -} \ No newline at end of file +} + +internal fun getCredentialOfferRequest( + url: String, clientId: String? = null, credentialOfferRequestCall: credentialOfferRequestCaller? = null +) = clientId?.let { + val initCredentialOfferUrl = URLBuilder(url).run { + parameters.appendAll(StringValues.build { + append("client_id", clientId) + append("credential_offer_endpoint", "openid-credential-offer://") + }) + build() + } + credentialOfferRequestCall!!(initCredentialOfferUrl) +} ?: CredentialOfferRequest(credentialOfferUri = url) \ No newline at end of file