Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean committed Jun 28, 2022
1 parent 411cd56 commit 86988cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import id.walt.crypto.Key
import id.walt.crypto.KeyAlgorithm
import id.walt.custodian.Custodian
import id.walt.services.key.KeyFormat
import id.walt.services.key.KeyService
import id.walt.services.keystore.KeyType
import id.walt.vclib.credentials.VerifiablePresentation
import id.walt.vclib.model.VerifiableCredential
Expand Down
16 changes: 9 additions & 7 deletions src/test/kotlin/id/walt/custodian/CustodianKeyTestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package id.walt.custodian
import id.walt.common.readWhenContent
import id.walt.crypto.Key
import id.walt.crypto.KeyAlgorithm
import id.walt.services.key.KeyService
import id.walt.crypto.KeyId
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.ints.shouldBeExactly
import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual
Expand All @@ -14,6 +14,8 @@ object CustodianKeyTestUtils {

private lateinit var key1: Key
private lateinit var key2: Key
private lateinit var ed25519_kid: KeyId
private lateinit var secp256k1_kid: KeyId

fun StringSpec.standardKeyTests(custodian: Custodian) {
"1.1: Generate EdDSA_Ed25519 key" {
Expand Down Expand Up @@ -53,25 +55,25 @@ object CustodianKeyTestUtils {

"5.1: Store EdDSA_Ed25519 key" {
// custodian.importKey(key1)
custodian.importKey(readWhenContent(File("src/test/resource/cli/privKeyEd25519Jwk.json")))
ed25519_kid = custodian.importKey(readWhenContent(File("src/test/resources/cli/privKeyEd25519Jwk.json")))
}

"5.2: Store ECDSA_Secp256k1 key" {
// custodian.importKey(key2)
custodian.importKey(readWhenContent(File("src/test/resource/key/privKeySecp256k1Jwk.json")))
secp256k1_kid = custodian.importKey(readWhenContent(File("src/test/resources/key/privKeySecp256k1Jwk.json")))
}

"6.1: Retrieve stored EdDSA_Ed25519 key" {
val loadedKey = custodian.getKey(key1.keyId.id)
val loadedKey = custodian.getKey(ed25519_kid.id)

loadedKey.keyId.id shouldBe key1.keyId.id
loadedKey.keyId.id shouldBe ed25519_kid.id
loadedKey.algorithm shouldBe KeyAlgorithm.EdDSA_Ed25519
}

"6.2: Retrieve stored ECDSA_Secp256k1 key" {
val loadedKey = custodian.getKey(key2.keyId.id)
val loadedKey = custodian.getKey(secp256k1_kid.id)

loadedKey.keyId.id shouldBe key2.keyId.id
loadedKey.keyId.id shouldBe secp256k1_kid.id
loadedKey.algorithm shouldBe KeyAlgorithm.ECDSA_Secp256k1

custodian.listKeys().forEach {
Expand Down

0 comments on commit 86988cf

Please sign in to comment.