Skip to content

Commit

Permalink
chore: increase test coverage (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianIOHK authored Aug 11, 2024
1 parent 8bdb59b commit 7fede0f
Show file tree
Hide file tree
Showing 14 changed files with 701 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.hyperledger.identus.walletsdk.domain.models.StorableCredential
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.data.AvailableClaims
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import org.hyperledger.identus.walletsdk.logger.PrismLogger
import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl
import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask
import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta
import org.kotlincrypto.hash.sha2.SHA256
import kotlin.text.encodeToByteArray
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.hyperledger.identus.walletsdk.pluto

import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import kotlin.reflect.KClass

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.serialization.json.Json
import org.hyperledger.identus.apollo.base64.base64UrlEncoded
import org.hyperledger.identus.walletsdk.domain.buildingblocks.Pluto
import org.hyperledger.identus.walletsdk.domain.models.UnknownError
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.JWK
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PrivateKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.data.DbConnection
import org.hyperledger.identus.walletsdk.pluto.data.isConnected
import org.hyperledger.identus.walletsdk.pluto.models.DidKeyLink
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta
import org.hyperledger.identus.walletsdk.pluto.data.AvailableClaims as AvailableClaimsDB
import org.hyperledger.identus.walletsdk.pluto.data.DID as DIDDB
Expand Down Expand Up @@ -184,7 +185,7 @@ class PlutoImpl(private val connection: DbConnection) : Pluto {
alias
)
)
privateKeys.map { privateKey ->
privateKeys.forEach { privateKey ->
storePrivateKeys(privateKey, did, keyPathIndex)
}
}
Expand Down Expand Up @@ -439,7 +440,7 @@ class PlutoImpl(private val connection: DbConnection) : Pluto {
@OptIn(ExperimentalCoroutinesApi::class)
override fun getDIDInfoByDID(did: DID): Flow<PrismDIDInfo?> {
return getInstance().dIDQueries
.fetchDIDInfoByDID(did.methodId)
.fetchDIDInfoByDID(did.toString())
.asFlow()
.mapLatest {
try {
Expand Down Expand Up @@ -1233,4 +1234,20 @@ class PlutoImpl(private val connection: DbConnection) : Pluto {
}
}
}

fun getAllDIDKeyLinkData(): Flow<List<DidKeyLink>> {
return getInstance().dIDKeyLinkQueries
.fetchAll()
.asFlow()
.map { didKeyLinks ->
didKeyLinks.executeAsList().map { didKeyLink ->
DidKeyLink(
id = didKeyLink.id.toInt(),
didId = didKeyLink.didId,
keyId = didKeyLink.keyId,
alias = didKeyLink.alias
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask.BackUpMessage.JsonAsStringSerializer.descriptor
import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask.BackUpMessage.JsonAsStringSerializer.deserialize
import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask.BackUpMessage.JsonAsStringSerializer.serialize
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential
import org.hyperledger.identus.walletsdk.pollux.models.JWTCredential
import kotlin.time.DurationUnit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.hyperledger.identus.walletsdk.pluto.models

data class DidKeyLink(val id: Int, val didId: String, val keyId: String, val alias: String? = null)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hyperledger.identus.walletsdk.pluto.backup.models
package org.hyperledger.identus.walletsdk.pluto.models.backup

import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.ExperimentalSerializationApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ CREATE TABLE DIDKeyLink (
insert:
INSERT INTO DIDKeyLink(didId, keyId, alias)
VALUES (:didId, :keyId, :alias);

fetchAll:
SELECT *
FROM DIDKeyLink;
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery
import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask
import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask
import org.hyperledger.identus.walletsdk.pluto.RestorationID
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pollux.PolluxImpl
import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.hyperledger.identus.walletsdk.domain.models.StorableCredential
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.data.AvailableClaims
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta

class PlutoMock : Pluto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PrivateKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey
import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey
import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.data.AvailableClaims
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta
import java.util.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.hyperledger.identus.walletsdk.edgeagent.EdgeAgent
import org.hyperledger.identus.walletsdk.edgeagent.MediationHandlerMock
import org.hyperledger.identus.walletsdk.edgeagent.MercuryMock
import org.hyperledger.identus.walletsdk.logger.PrismLoggerMock
import org.hyperledger.identus.walletsdk.pluto.backup.models.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1
import org.hyperledger.identus.walletsdk.pollux.PolluxImpl
import org.hyperledger.identus.walletsdk.pollux.models.JWTCredential
import org.junit.Before
Expand Down
Loading

0 comments on commit 7fede0f

Please sign in to comment.