Skip to content

Commit

Permalink
unlock testGenerateDidJwkSECP256k1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavoyan committed Sep 9, 2024
1 parent b1ab286 commit 36a7344
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
})
}
}
}

0 comments on commit 36a7344

Please sign in to comment.