Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/ATL-7363' into test/backup
Browse files Browse the repository at this point in the history
  • Loading branch information
amagyar-iohk committed Jul 15, 2024
2 parents 612b68e + 3a0ad7c commit 985ac26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@file:Suppress("ktlint:standard:import-ordering")

package org.hyperledger.identus.walletsdk.pluto

import java.util.*
import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
Expand Down Expand Up @@ -32,11 +35,12 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.IndexKey
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.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.pollux.models.AnonCredential
import org.hyperledger.identus.walletsdk.pollux.models.JWTCredential
import java.util.*
import kotlin.jvm.Throws
import kotlin.time.DurationUnit
import kotlin.time.toDuration

Expand All @@ -57,12 +61,12 @@ open class PlutoRestoreTask(
*/
fun run() {
restoreCredentials()
restoreDids()
restoreDidPairs()
restoreKeys()
restoreLinkSecret()
restoreMessages()
restoreMediators()
restoreDids()
}

/**
Expand Down Expand Up @@ -169,14 +173,21 @@ open class PlutoRestoreTask(
}.forEach {
if (it.third is DID) {
if (it.third.toString().contains("peer")) {
val metaId = (it.third as DID).toString()
val origDid = (it.third as DID)
val did = if (origDid.toString().contains("#")) {
val splits = origDid.toString().split("#")
DID(splits[0])
} else {
DID(origDid.toString())
}
val keyId = origDid.toString()
pluto.storePrivateKeys(
it.first as StorableKey,
it.third as DID,
did,
(it.first.keySpecification[IndexKey().property])?.toInt(),
metaId
keyId
)
pluto.storePeerDID(it.third as DID)
// pluto.storePeerDID(did)
} else {
pluto.storePrismDIDAndPrivateKeys(
it.third as DID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ class BackupRestorationTests {

// Validates DIDs are backed up and restored properly, and passed to pluto for storage
val didCaptor = argumentCaptor<DID>()
verify(edgeAgent.pluto, times(9)).storePeerDID(didCaptor.capture())
assertEquals(9, didCaptor.allValues.size)
verify(edgeAgent.pluto, times(5)).storePeerDID(didCaptor.capture())
assertEquals(5, didCaptor.allValues.size)

assertTrue {
didCaptor.allValues.contains(DID("did:peer:2.Ez6LSok96TA4orHQXSMHZj3mqyUuVLMfLfGGqj27i1giErbXL.Vz6Mku5mY1GuJ9AN2vvDwjMv5QUC2zqKVRPCcbmJVYTFTCFmr"))
Expand All @@ -328,18 +328,6 @@ class BackupRestorationTests {
assertTrue {
didCaptor.allValues.contains(DID("did:prism:0a4b552169e3158781741fbbeffe81212784d32d90cf8f2622923f11f6ecd966:CoUBCoIBEjsKB21hc3RlcjAQAUouCglzZWNwMjU2azESIQLgzhsuOqhAyImy-c8o9ZmIJ4iY_Gc8tvNIT3l1w58f2BJDCg9hdXRoZW50aWNhdGlvbjAQBEouCglzZWNwMjU2azESIQLgzhsuOqhAyImy-c8o9ZmIJ4iY_Gc8tvNIT3l1w58f2A"))
}
assertTrue {
didCaptor.allValues.contains(DID("did:peer:2.Ez6LSok96TA4orHQXSMHZj3mqyUuVLMfLfGGqj27i1giErbXL.Vz6Mku5mY1GuJ9AN2vvDwjMv5QUC2zqKVRPCcbmJVYTFTCFmr#key-2"))
}
assertTrue {
didCaptor.allValues.contains(DID("did:peer:2.Ez6LSok96TA4orHQXSMHZj3mqyUuVLMfLf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luVnlhU0k2SW1oMGRIQnpPaTh2YzJsMExYQnlhWE50TFcxbFpHbGhkRzl5TG1GMFlXeGhjSEpwYzIwdWFXOGlMQ0poSWpwYkltUnBaR052YlcwdmRqSWlYWDE5LlNleUowSWpvaVpHMGlMQ0p6SWpwN0luVnlhU0k2SW5kemN6b3ZMM05wZEMxd2NtbHpiUzF0WldScFlYUnZjaTVoZEdGc1lYQnlhWE50TG1sdkwzZHpJaXdpWVNJNld5SmthV1JqYjIxdEwzWXlJbDE5ZlEiLCJyIjpbXSwiYSI6W119fQ#key-1"))
}

// Validates DID pairs are backed up and restored properly, and passed to pluto for storage
val didPairsHostCaptor = argumentCaptor<DID>()
Expand Down Expand Up @@ -371,7 +359,7 @@ class BackupRestorationTests {
)
// 9 because of already ran items and items in the key backup
val keysDidCaptor2 = argumentCaptor<DID>()
verify(edgeAgent.pluto, times(9)).storePeerDID(keysDidCaptor2.capture())
verify(edgeAgent.pluto, times(5)).storePeerDID(keysDidCaptor2.capture())

val keysCaptor = argumentCaptor<StorableKey>()
val keysDidCaptor3 = argumentCaptor<DID>()
Expand Down

Large diffs are not rendered by default.

0 comments on commit 985ac26

Please sign in to comment.