From 36a7344a3ec336b2318e50cd567a89c9d6105710 Mon Sep 17 00:00:00 2001 From: Michael Avoyan <64565419+michaelavoyan@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:18:52 +0300 Subject: [PATCH] unlock testGenerateDidJwkSECP256k1 --- .../infrastructure/keys/KeyServiceTest.kt | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/VCL/src/test/java/io/velocitycareerlabs/infrastructure/keys/KeyServiceTest.kt b/VCL/src/test/java/io/velocitycareerlabs/infrastructure/keys/KeyServiceTest.kt index 899a223..928c9dc 100644 --- a/VCL/src/test/java/io/velocitycareerlabs/infrastructure/keys/KeyServiceTest.kt +++ b/VCL/src/test/java/io/velocitycareerlabs/infrastructure/keys/KeyServiceTest.kt @@ -9,10 +9,7 @@ import io.velocitycareerlabs.api.VCLSignatureAlgorithm import io.velocitycareerlabs.api.entities.VCLDidJwk import io.velocitycareerlabs.api.entities.VCLDidJwkDescriptor import io.velocitycareerlabs.api.entities.handleResult -import io.velocitycareerlabs.impl.GlobalConfig import io.velocitycareerlabs.impl.keys.VCLKeyServiceLocalImpl -import io.velocitycareerlabs.impl.extensions.decodeBase64 -import io.velocitycareerlabs.impl.extensions.toJsonObject import io.velocitycareerlabs.infrastructure.db.SecretStoreServiceMock import org.junit.Before import org.junit.Test @@ -51,24 +48,23 @@ class KeyServiceTest { } } -// TODO: Investigate the test failure: -// @Test -// fun testGenerateDidJwkSECP256k1() { -// subject.generateDidJwk(VCLDidJwkDescriptor(VCLSignatureAlgorithm.SECP256k1)) { didJwkResult -> -// didJwkResult.handleResult({ didJwk -> -// val jwkJson = didJwk.publicJwk.valueJson -// -// assert(didJwk.did.startsWith(VCLDidJwk.DidJwkPrefix)) -// assert(didJwk.kid.startsWith(VCLDidJwk.DidJwkPrefix)) -// assert(didJwk.kid.endsWith(VCLDidJwk.DidJwkSuffix)) -// -// assert(jwkJson.optString("kty") == "EC") -// assert(jwkJson.optString("use") == "sig") -// assert(jwkJson.optString("crv") == VCLSignatureAlgorithm.SECP256k1.curve.name) -// assert(jwkJson.optString("use") == "sig") -// }, { -// assert(false) { "Failed to generate did:jwk $it" } -// }) -// } -// } + @Test + fun testGenerateDidJwkSECP256k1() { + subject.generateDidJwk(VCLDidJwkDescriptor(VCLSignatureAlgorithm.SECP256k1)) { didJwkResult -> + didJwkResult.handleResult({ didJwk -> + val jwkJson = didJwk.publicJwk.valueJson + + assert(didJwk.did.startsWith(VCLDidJwk.DidJwkPrefix)) + assert(didJwk.kid.startsWith(VCLDidJwk.DidJwkPrefix)) + assert(didJwk.kid.endsWith(VCLDidJwk.DidJwkSuffix)) + + assert(jwkJson.optString("kty") == "EC") + assert(jwkJson.optString("use") == "sig") + assert(jwkJson.optString("crv") == VCLSignatureAlgorithm.SECP256k1.curve.name) + assert(jwkJson.optString("use") == "sig") + }, { + assert(false) { "Failed to generate did:jwk $it" } + }) + } + } } \ No newline at end of file