From 6b5ebf84293b4adf8ab71eac9f8cfbdf35450fa7 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 26 Aug 2024 09:56:22 -0400 Subject: [PATCH 1/4] refactor: add logger to component construtors and remove prism references from it Signed-off-by: Cristian G --- .../walletsdk/edgeagent/AnoncredsTests.kt | 10 +-- .../identus/walletsdk/apollo/ApolloImpl.kt | 7 +- .../identus/walletsdk/castor/CastorImpl.kt | 6 +- .../walletsdk/castor/shared/CastorShared.kt | 4 +- .../identus/walletsdk/edgeagent/EdgeAgent.kt | 10 +-- .../{PrismLogger.kt => EdgeAgentLogger.kt} | 25 ++++--- .../identus/walletsdk/mercury/MercuryImpl.kt | 6 +- .../mercury/resolvers/DIDCommWrapper.kt | 5 +- .../identus/walletsdk/pluto/PlutoImpl.kt | 8 ++- .../identus/walletsdk/pollux/PolluxImpl.kt | 6 +- .../walletsdk/edgeagent/EdgeAgentTests.kt | 72 +++++++++---------- ...smLoggerMock.kt => EdgeAgentLoggerMock.kt} | 2 +- .../identus/walletsdk/mercury/MercuryTests.kt | 4 +- .../walletsdk/pluto/BackupRestorationTests.kt | 5 +- .../walletsdk/pollux/PolluxImplTest.kt | 6 +- .../identus/walletsdk/sampleapp/Sdk.kt | 2 +- 16 files changed, 99 insertions(+), 79 deletions(-) rename edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/{PrismLogger.kt => EdgeAgentLogger.kt} (95%) rename edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/{PrismLoggerMock.kt => EdgeAgentLoggerMock.kt} (96%) diff --git a/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt b/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt index 837c7d2a2..9a0dcfa81 100644 --- a/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt +++ b/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt @@ -40,7 +40,7 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.Off import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmission import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation import org.hyperledger.identus.walletsdk.domain.models.KeyValue -import org.hyperledger.identus.walletsdk.logger.PrismLoggerMock +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock import org.hyperledger.identus.walletsdk.mercury.ApiMock import org.hyperledger.identus.walletsdk.pollux.PolluxImpl import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential @@ -114,7 +114,7 @@ class AnoncredsTests { connectionManager = connectionManager, seed = null, api = ApiMock(statusCode = HttpStatusCode.OK, response = "{\"success\":\"true\"}"), - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val attachmentDescriptor = @@ -192,7 +192,7 @@ class AnoncredsTests { connectionManager = connectionManager, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val attachmentDescriptor = @@ -263,7 +263,7 @@ class AnoncredsTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val credential = AnonCredential.fromStorableData( @@ -355,7 +355,7 @@ class AnoncredsTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) ) diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt index 65dcbe168..5708da63e 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt @@ -40,11 +40,16 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.SeedKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.LogComponent /** * Apollo defines the set of cryptographic operations that are used in the Atala PRISM. */ -class ApolloImpl : Apollo { +class ApolloImpl( + private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.APOLLO) +) : Apollo { /** * Creates a random set of mnemonic phrases that can be used as a seed for generating a private key. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt index 254df2860..136a76cd2 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt @@ -24,8 +24,8 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.PrismLogger -import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl /** * Castor is a powerful and flexible library for working with DIDs. Whether you are building a decentralised application @@ -36,7 +36,7 @@ class CastorImpl @JvmOverloads constructor( val apollo: Apollo, - private val logger: PrismLogger = PrismLoggerImpl(LogComponent.CASTOR) + private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.CASTOR) ) : Castor { var resolvers: Array = arrayOf( LongFormPrismDIDResolver(this.apollo), diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt index 8cd2a21fd..c765b6364 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt @@ -42,10 +42,10 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDUrl import org.hyperledger.identus.walletsdk.domain.models.OctetPublicKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.KeyPair import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl import org.kotlincrypto.hash.sha2.SHA256 import pbandk.decodeFromByteArray import pbandk.encodeToByteArray @@ -64,7 +64,7 @@ internal class CastorShared { * * @property logger The logger instance. */ - private val logger = PrismLoggerImpl(LogComponent.CASTOR) + private val logger = EdgeAgentLoggerImpl(LogComponent.CASTOR) /** * parseDID parses a string representation of a Decentralized Identifier (DID) into a DID object. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt index 34e986ef1..174bb10d5 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt @@ -107,8 +107,8 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.PrismLogger -import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1 @@ -153,7 +153,7 @@ open class EdgeAgent { private val edgeAgentScope: CoroutineScope = CoroutineScope(Dispatchers.Default) private val api: Api internal var connectionManager: ConnectionManager - private var logger: PrismLogger + private var logger: EdgeAgentLogger private val agentOptions: AgentOptions /** @@ -181,7 +181,7 @@ open class EdgeAgent { connectionManager: ConnectionManager, seed: Seed?, api: Api?, - logger: PrismLogger = PrismLoggerImpl(LogComponent.PRISM_AGENT), + logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.EDGE_AGENT), agentOptions: AgentOptions = AgentOptions() ) { edgeAgentScope.launch { @@ -235,7 +235,7 @@ open class EdgeAgent { seed: Seed? = null, api: Api? = null, mediatorHandler: MediationHandler, - logger: PrismLogger = PrismLoggerImpl(LogComponent.PRISM_AGENT), + logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.EDGE_AGENT), agentOptions: AgentOptions = AgentOptions() ) { edgeAgentScope.launch { diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLogger.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt similarity index 95% rename from edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLogger.kt rename to edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt index e62bf099a..14ae24276 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLogger.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt @@ -24,10 +24,10 @@ private const val METADATA_PRIVACY_STR = "------" private val hashingLog = UUID.randomUUID().toString() /** - * PrismLogger is an interface that defines methods for logging messages + * EdgeAgentLogger is an interface that defines methods for logging messages * with different log levels and metadata. */ -interface PrismLogger { +interface EdgeAgentLogger { /** * Logs a debug message with optional metadata. * @@ -66,22 +66,27 @@ interface PrismLogger { * @param error The error to be logged. * @param metadata An array of metadata objects to be included in the log message. Defaults to an empty array if not provided. * - * @see PrismLogger.error + * @see EdgeAgentLogger.error * @see Metadata */ fun error(error: Error, metadata: Array = arrayOf()) } /** - * Implementation of the PrismLogger interface. + * Implementation of the EdgeAgentLogger interface. * * @property category the LogComponent category for this logger */ -class PrismLoggerImpl(category: LogComponent) : PrismLogger { +class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel = LogLevel.INFO, tag: String? = null) : + EdgeAgentLogger { - private val log = logging("[io.prism.kmm.sdk.$category]") - - private var logLevel: LogLevel = LogLevel.INFO + private val log = logging( + if (tag != null) { + "$tag.$category" + } else { + "[org.hyperledger.identus.walletsdk.$category]" + } + ) /** * Logs a debug message with optional metadata. @@ -333,7 +338,7 @@ enum class LogLevel(val value: Int) { * - MERCURY * - PLUTO * - POLLUX - * - PRISM_AGENT + * - EDGE_AGENT */ enum class LogComponent { APOLLO, @@ -341,5 +346,5 @@ enum class LogComponent { MERCURY, PLUTO, POLLUX, - PRISM_AGENT + EDGE_AGENT } diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt index ae7d49ff1..5feeb2038 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt @@ -13,11 +13,11 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDDocument import org.hyperledger.identus.walletsdk.domain.models.KeyValue import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.PrismLogger -import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl import org.hyperledger.identus.walletsdk.mercury.forward.ForwardMessage /** @@ -55,7 +55,7 @@ constructor( private val castor: Castor, private val protocol: DIDCommProtocol, private val api: Api, - private val logger: PrismLogger = PrismLoggerImpl(LogComponent.MERCURY) + private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.MERCURY) ) : Mercury { /** diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt index af8dc6190..4bbe6e251 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt @@ -33,10 +33,10 @@ import org.hyperledger.identus.walletsdk.domain.models.AttachmentDescriptor import org.hyperledger.identus.walletsdk.domain.models.DID import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.PrismLoggerImpl import org.hyperledger.identus.walletsdk.mercury.ATTACHMENT_SEPARATOR import org.hyperledger.identus.walletsdk.mercury.BASE64 import org.hyperledger.identus.walletsdk.mercury.DIDCommProtocol @@ -44,7 +44,6 @@ import org.hyperledger.identus.walletsdk.mercury.HASH import org.hyperledger.identus.walletsdk.mercury.JSON import org.hyperledger.identus.walletsdk.mercury.LINKS import java.time.Instant.now -import kotlin.jvm.Throws /** * Wrapper class for the DIDComm functionality. @@ -57,7 +56,7 @@ class DIDCommWrapper(castor: Castor, pluto: Pluto, apollo: Apollo) : DIDCommProt private val didDocResolver = DIDCommDIDResolver(castor) private val secretsResolver = DIDCommSecretsResolver(pluto, apollo) private val didComm = DIDComm(didDocResolver, secretsResolver) - private val logger = PrismLoggerImpl(LogComponent.MERCURY) + private val logger = EdgeAgentLoggerImpl(LogComponent.MERCURY) /** * Converts a JSON element to a map. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt index 986b40b64..1ce501870 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt @@ -35,6 +35,9 @@ 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.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.LogComponent 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 @@ -55,7 +58,10 @@ import org.hyperledger.identus.walletsdk.pluto.data.StorableCredential as Storab * @property db The instance of `SdkPlutoDb` representing the connection to the database. * @property isConnected A flag to indicate whether the database connection is established or not. */ -class PlutoImpl(private val connection: DbConnection) : Pluto { +class PlutoImpl( + private val connection: DbConnection, + private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.PLUTO) +) : Pluto { private var db: SdkPlutoDb? = null init { diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt index edd3b73b9..66f471d67 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt @@ -92,6 +92,9 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsAnoncreds import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsJWT +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.pluto.RestorationID import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential import org.hyperledger.identus.walletsdk.pollux.models.AnoncredsPresentationDefinitionRequest @@ -114,7 +117,8 @@ import org.hyperledger.identus.walletsdk.pollux.utils.BitString open class PolluxImpl( val apollo: Apollo, val castor: Castor, - private val api: Api = ApiImpl(httpClient()) + private val api: Api = ApiImpl(httpClient()), + private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.POLLUX) ) : Pollux { /** diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt index 27125e8dc..52f020aa5 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt @@ -70,7 +70,7 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.Off import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.OutOfBandInvitation import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.PrismOnboardingInvitation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation -import org.hyperledger.identus.walletsdk.logger.PrismLoggerMock +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock import org.hyperledger.identus.walletsdk.mercury.ApiMock import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask @@ -184,7 +184,7 @@ class EdgeAgentTests { connectionManager = connectionManager, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -226,7 +226,7 @@ class EdgeAgentTests { connectionManager = connectionManager, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -260,7 +260,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -280,7 +280,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -302,7 +302,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -325,7 +325,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -350,7 +350,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) plutoMockOld.getPrismLastKeyPathIndexReturn = flow { emit(0) } @@ -373,7 +373,7 @@ class EdgeAgentTests { connectionManagerMock, seed, null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) ) @@ -389,7 +389,7 @@ class EdgeAgentTests { @Test fun testCreateNewPeerDID_whenUpdateMediatorFalse_thenShouldUseProvidedServices() = runTest { val apollo = ApolloImpl() - val castor = CastorImpl(apollo = apollo, logger = PrismLoggerMock()) + val castor = CastorImpl(apollo = apollo, logger = EdgeAgentLoggerMock()) val agent = EdgeAgent( apollo, castor, @@ -399,7 +399,7 @@ class EdgeAgentTests { connectionManagerOld, null, null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -435,7 +435,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val invitationString = """ { @@ -462,7 +462,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = api, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val invitationString = """ { @@ -489,7 +489,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val invitationString = """ { @@ -515,7 +515,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) plutoMockOld.getDIDPrivateKeysReturn = flow { emit(listOf(null)) } @@ -541,7 +541,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -584,7 +584,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -626,7 +626,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -667,7 +667,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -714,7 +714,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val invitationString = """ @@ -744,7 +744,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) assertEquals(EdgeAgent.State.STOPPED, agent.state) @@ -763,7 +763,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) agent.stop() @@ -783,7 +783,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) val x = agent.parseInvitation(oob) @@ -845,7 +845,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -887,7 +887,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -915,7 +915,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -961,7 +961,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = PrismLoggerMock(), + logger = EdgeAgentLoggerMock(), agentOptions = AgentOptions() ) @@ -1035,7 +1035,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val vmAuthentication = DIDDocument.VerificationMethod( @@ -1133,7 +1133,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val vmAuthentication = DIDDocument.VerificationMethod( @@ -1251,7 +1251,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val msg = Json.decodeFromString( "{\"id\":\"00000000-685c-4004-0000-000036ac64ee\",\"piuri\":\"https://didcomm.atalaprism.io/present-proof/3.0/request-presentation\",\"from\":{\"method\":\"peer\",\"methodId\":\"asdfasdf\"},\"to\":{\"method\":\"peer\",\"methodId\":\"fdsafdsa\"},\"fromPrior\":null,\"body\":\"{}\",\"createdTime\":\"2024-03-08T19:27:38.196506Z\",\"expiresTimePlus\":\"2024-03-09T19:27:38.196559Z\",\"attachments\":[{\"id\":\"00000000-9c2e-4249-0000-0000c1176949\",\"mediaType\":\"application/json\",\"data\":{\"type\":\"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64\",\"base64\":\"eyJwcmVzZW50YXRpb25fZGVmaW5pdGlvbiI6eyJpZCI6IjMyZjU0MTYzLTcxNjYtNDhmMS05M2Q4LWZmMjE3YmRiMDY1MyIsImlucHV0X2Rlc2NyaXB0b3JzIjpbeyJpZCI6IndhX2RyaXZlcl9saWNlbnNlIiwibmFtZSI6Ildhc2hpbmd0b24gU3RhdGUgQnVzaW5lc3MgTGljZW5zZSIsInB1cnBvc2UiOiJXZSBjYW4gb25seSBhbGxvdyBsaWNlbnNlZCBXYXNoaW5ndG9uIFN0YXRlIGJ1c2luZXNzIHJlcHJlc2VudGF0aXZlcyBpbnRvIHRoZSBXQSBCdXNpbmVzcyBDb25mZXJlbmNlIiwiY29uc3RyYWludHMiOnsiZmllbGRzIjpbeyJwYXRoIjpbIiQuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiIsIiQudmMuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLnZjLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiJdfV19fV0sImZvcm1hdCI6eyJqd3QiOnsiYWxnIjpbIkVTMjU2SyJdfX19LCAib3B0aW9ucyI6IHsiZG9tYWluIjogImRvbWFpbiIsICJjaGFsbGVuZ2UiOiAiY2hhbGxlbmdlIn19\"},\"format\":\"dif/presentation-exchange/fail_test@v1.0\"}],\"thid\":\"00000000-ef9d-4722-0000-00003b1bc908\",\"ack\":[]}" @@ -1291,7 +1291,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val msg = Json.decodeFromString( "{\"id\":\"00000000-685c-4004-0000-000036ac64ee\",\"piuri\":\"https://didcomm.atalaprism.io/present-proof/3.0/presentation\",\"from\":{\"method\":\"peer\",\"methodId\":\"asdfasdf\"},\"to\":{\"method\":\"peer\",\"methodId\":\"fdsafdsa\"},\"fromPrior\":null,\"body\":\"{}\",\"createdTime\":\"2024-03-08T19:27:38.196506Z\",\"expiresTimePlus\":\"2024-03-09T19:27:38.196559Z\",\"attachments\":[{\"id\":\"00000000-9c2e-4249-0000-0000c1176949\",\"mediaType\":\"application/json\",\"data\":{\"type\":\"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64\",\"base64\":\"eyJ2ZXJpZmlhYmxlUHJlc2VudGF0aW9uIjpbImV5SmhiR2NpT2lKRlV6STFOa3NpZlEuZXlKcGMzTWlPaUprYVdRNmNISnBjMjA2TWpVM01UbGhPVFppTVRVeE1qQTNNVFk1T0RGaE9EUXpNR0ZrTUdOaU9UWTRaR1ExTXpRd056TTFPVE5qT0dOa00yWXhaREkzWVRZNE1EUmxZelV3WlRwRGNHOURRM0JqUTBWc2IwdENWM1JzWlZNd2VFVkJTa05VZDI5S1l6SldhbU5FU1RGT2JYTjRSV2xCUlc5VFEyNDFkSGxFWVRaWk5uSXRTVzFUY1hCS09Ga3hiV28zU2tNelgyOVZla1V3VG5sNVJXbERRbTluYzJkT1lXVlNaR05EVWtkUWJHVTRNbFoyT1hSS1prNTNiRFp5WnpaV1kyaFNNMDl4YUdsV1lsUmhPRk5YZDI5SFdWaFdNR0ZETUhoRlFWSkRWSGR2U21NeVZtcGpSRWt4VG0xemVFVnBSRTFyUW1RMlJuUnBiMHByTTFoUFJuVXRYMk41TlZodFVpMDBkRlZSTWs1TVIybFhPR0ZKVTI5dGExSnZaelpUWkdVNVVIZHVSekJSTUZOQ1ZHMUdVMVJFWWxOTFFuWkpWalpEVkV4WWNtcEpTblIwWlVkSmJVRlRXRUZ2U0dKWFJucGtSMVo1VFVKQlFsRnJPRXREV0U1c1dUTkJlVTVVV25KTlVrbG5UemN4TUcxME1WZGZhWGhFZVZGTk0zaEpjemRVY0dwTVEwNVBSRkY0WjFab2VEVnphR1pMVGxneGIyRkpTRmRRY25jM1NWVkxiR1pwWWxGMGVEWkthelJVVTJwblkxZE9UMlpqVDNSVk9VUTVVSFZhTjFRNWRDSXNJbk4xWWlJNkltUnBaRHB3Y21semJUcGlaV1ZoTlRJek5HRm1ORFk0TURRM01UUmtPR1ZoT0dWak56ZGlOalpqWXpkbU0yVTRNVFZqTmpoaFltSTBOelZtTWpVMFkyWTVZek13TmpJMk56WXpPa056WTBKRGMxRkNSVzFSUzBReVJqRmtSMmhzWW01U2NGa3lSakJoVnpsMVRVSkJSVkZyT0V0RFdFNXNXVE5CZVU1VVduSk5Va2xuWlZObkxUSlBUekZLWkc1d2VsVlBRbWwwZWtscFkxaGtabnBsUVdOVVpsZEJUaTFaUTJWMVEySjVTV0ZKU2xFMFIxUkpNekIwWVZacGQyTm9WRE5sTUc1TVdFSlRORE5DTkdvNWFteHpiRXR2TWxwc1pGaDZha1ZzZDB0Q01qRm9Zek5TYkdOcVFWRkJWVXBRUTJkc2VscFhUbmROYWxVeVlYcEZVMGxJYTI5UWRHcHFkRk5ZV2paak1VUm5XWEpqZVVsdVJqTllPRE5uU0VVek1XZEVabTFCYm5KbmJUaHBSMmxEVlU5Q2EzbE9PVXhYYkZselNFbFZPVE4wU25reGQxVjFUbmRsU1Y5Wk5XSktVM0ZPYlZwWVZqZzBkeUlzSW01aVppSTZNVFk0TlRZek1UazVOU3dpWlhod0lqb3hOamcxTmpNMU5UazFMQ0oyWXlJNmV5SmpjbVZrWlc1MGFXRnNVM1ZpYW1WamRDSTZleUpoWkdScGRHbHZibUZzVUhKdmNESWlPaUpVWlhOME15SXNJbWxrSWpvaVpHbGtPbkJ5YVhOdE9tSmxaV0UxTWpNMFlXWTBOamd3TkRjeE5HUTRaV0U0WldNM04ySTJObU5qTjJZelpUZ3hOV00yT0dGaVlqUTNOV1l5TlRSalpqbGpNekEyTWpZM05qTTZRM05qUWtOelVVSkZiVkZMUkRKR01XUkhhR3hpYmxKd1dUSkdNR0ZYT1hWTlFrRkZVV3M0UzBOWVRteFpNMEY1VGxSYWNrMVNTV2RsVTJjdE1rOVBNVXBrYm5CNlZVOUNhWFI2U1dsaldHUm1lbVZCWTFSbVYwRk9MVmxEWlhWRFlubEpZVWxLVVRSSFZFa3pNSFJoVm1sM1kyaFVNMlV3Ymt4WVFsTTBNMEkwYWpscWJITnNTMjh5V214a1dIcHFSV3gzUzBJeU1XaGpNMUpzWTJwQlVVRlZTbEJEWjJ4NldsZE9kMDFxVlRKaGVrVlRTVWhyYjFCMGFtcDBVMWhhTm1NeFJHZFpjbU41U1c1R00xZzRNMmRJUlRNeFowUm1iVUZ1Y21kdE9HbEhhVU5WVDBKcmVVNDVURmRzV1hOSVNWVTVNM1JLZVRGM1ZYVk9kMlZKWDFrMVlrcFRjVTV0V2xoV09EUjNJbjBzSW5SNWNHVWlPbHNpVm1WeWFXWnBZV0pzWlVOeVpXUmxiblJwWVd3aVhTd2lRR052Ym5SbGVIUWlPbHNpYUhSMGNITTZYQzljTDNkM2R5NTNNeTV2Y21kY0x6SXdNVGhjTDJOeVpXUmxiblJwWVd4elhDOTJNU0pkZlgwLngwU0YxN1kwVkNEbXQ3SGNlT2RUeGZIbG9mc1ptWTE4Um42VlFiMC1yLWtfQm0zaFRpMS1rMnZrZGpCMjVoZHh5VEN2eGFtLUFrQVAtQWczQWhuNU5nIl19\"},\"format\":\"dif/presentation-exchange/definitions@v1.0\"}],\"thid\":\"00000000-ef9d-4722-0000-00003b1bc908\",\"ack\":[]}" @@ -1362,7 +1362,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val msg = Json.decodeFromString( """{"id":"00000000-685c-4004-0000-000036ac64ee","piuri":"https://didcomm.atalaprism.io/present-proof/3.0/request-presentation","from":{"method":"peer","methodId":"asdfasdf"},"to":{"method":"peer","methodId":"fdsafdsa"},"fromPrior":null,"body":"{}","createdTime":"2024-03-08T19:27:38.196506Z","expiresTimePlus":"2024-03-09T19:27:38.196559Z","attachments":[{"id":"00000000-9c2e-4249-0000-0000c1176949","mediaType":"application/json","data":{"type":"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64","base64":"eyJwcmVzZW50YXRpb25fZGVmaW5pdGlvbiI6eyJpZCI6IjMyZjU0MTYzLTcxNjYtNDhmMS05M2Q4LWZmMjE3YmRiMDY1MyIsImlucHV0X2Rlc2NyaXB0b3JzIjpbeyJpZCI6IndhX2RyaXZlcl9saWNlbnNlIiwibmFtZSI6Ildhc2hpbmd0b24gU3RhdGUgQnVzaW5lc3MgTGljZW5zZSIsInB1cnBvc2UiOiJXZSBjYW4gb25seSBhbGxvdyBsaWNlbnNlZCBXYXNoaW5ndG9uIFN0YXRlIGJ1c2luZXNzIHJlcHJlc2VudGF0aXZlcyBpbnRvIHRoZSBXQSBCdXNpbmVzcyBDb25mZXJlbmNlIiwiY29uc3RyYWludHMiOnsiZmllbGRzIjpbeyJwYXRoIjpbIiQuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiIsIiQudmMuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLnZjLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiJdfV19fV0sImZvcm1hdCI6eyJqd3QiOnsiYWxnIjpbIkVTMjU2SyJdfX19LCAib3B0aW9ucyI6IHsiZG9tYWluIjogImRvbWFpbiIsICJjaGFsbGVuZ2UiOiAiY2hhbGxlbmdlIn19"},"format":"dif/presentation-exchange/definitions@v1.0"}],"thid":"00000000-ef9d-4722-0000-00003b1bc908","ack":[]}""" @@ -1416,7 +1416,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val credential = JWTCredential.fromJwtString( @@ -1524,7 +1524,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val msgString = @@ -1647,7 +1647,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) val msgString = @@ -1668,7 +1668,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock() + logger = EdgeAgentLoggerMock() ) `when`( apolloMock.createPrivateKey( diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLoggerMock.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt similarity index 96% rename from edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLoggerMock.kt rename to edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt index cad70ab24..3448e197e 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/PrismLoggerMock.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt @@ -1,6 +1,6 @@ package org.hyperledger.identus.walletsdk.logger -class PrismLoggerMock : PrismLogger { +class EdgeAgentLoggerMock : EdgeAgentLogger { private var logLevel: LogLevel = LogLevel.NONE diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt index 5d8f5e535..41c398bc4 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt @@ -6,7 +6,7 @@ import org.hyperledger.identus.walletsdk.domain.models.DID import org.hyperledger.identus.walletsdk.domain.models.DIDDocument import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.PrismLoggerMock +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFailsWith @@ -24,7 +24,7 @@ class MercuryTests { apiMock = ApiMock(HttpStatusCode.OK, "") castorMock = CastorMock() protocolMock = ProtocolMock() - sut = MercuryImpl(castorMock, protocolMock, apiMock, PrismLoggerMock()) + sut = MercuryImpl(castorMock, protocolMock, apiMock, EdgeAgentLoggerMock()) } @Test diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt index d0be7d4b7..55febd727 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt @@ -32,7 +32,7 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey 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.logger.EdgeAgentLoggerMock 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 @@ -578,7 +578,8 @@ class BackupRestorationTests { @Test fun restoreFromTS_Swift() = runTest { val realPluto = PlutoImpl(DbConnectionInMemory()) - val logger = PrismLoggerMock() + val logger = EdgeAgentLoggerMock() + val realCastor = CastorImpl(apollo, logger) edgeAgent = EdgeAgent( diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt index 557c90a24..7a100ef9a 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt @@ -50,7 +50,7 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PrivateKey import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.AnoncredsPresentationOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.JWTPresentationOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsJWT -import org.hyperledger.identus.walletsdk.logger.PrismLogger +import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential import org.hyperledger.identus.walletsdk.pollux.models.AnoncredsPresentationDefinitionRequest import org.hyperledger.identus.walletsdk.pollux.models.JWTCredential @@ -81,7 +81,7 @@ class PolluxImplTest { lateinit var castorMock: Castor @Mock - lateinit var loggerMock: PrismLogger + lateinit var loggerMock: EdgeAgentLogger @Before fun setup() { @@ -330,7 +330,7 @@ class PolluxImplTest { @Test fun testCreatePresentationSubmission_whenAllCorrect_thenPresentationSubmissionProofWellFormed() = runTest { - val loggerMock = mock() + val loggerMock = mock() val castor: Castor = CastorImpl(apollo = ApolloImpl(), loggerMock) val issuerKeyPair = diff --git a/sampleapp/src/main/java/org/hyperledger/identus/walletsdk/sampleapp/Sdk.kt b/sampleapp/src/main/java/org/hyperledger/identus/walletsdk/sampleapp/Sdk.kt index 4d76e439e..76f38f7a5 100644 --- a/sampleapp/src/main/java/org/hyperledger/identus/walletsdk/sampleapp/Sdk.kt +++ b/sampleapp/src/main/java/org/hyperledger/identus/walletsdk/sampleapp/Sdk.kt @@ -178,7 +178,7 @@ class Sdk { mercury = mercury, pollux = pollux, seed = seed, - mediatorHandler = handler + mediatorHandler = handler, ) } From 81dd24eaea9faaf2386013f776381740cb9e7961 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 16 Sep 2024 11:19:23 -0400 Subject: [PATCH 2/4] refactor: simplify logger implementation and LogComponent to selfcontain log level Signed-off-by: Cristian G --- .../walletsdk/edgeagent/AnoncredsTests.kt | 10 +-- .../identus/walletsdk/apollo/ApolloImpl.kt | 9 ++- .../identus/walletsdk/castor/CastorImpl.kt | 6 +- .../walletsdk/castor/shared/CastorShared.kt | 4 +- .../identus/walletsdk/edgeagent/EdgeAgent.kt | 10 +-- .../logger/{EdgeAgentLogger.kt => Logger.kt} | 45 ++++++------ .../identus/walletsdk/mercury/MercuryImpl.kt | 6 +- .../mercury/resolvers/DIDCommWrapper.kt | 4 +- .../identus/walletsdk/pluto/PlutoImpl.kt | 6 +- .../identus/walletsdk/pollux/PolluxImpl.kt | 6 +- .../walletsdk/edgeagent/EdgeAgentTests.kt | 72 +++++++++---------- .../{EdgeAgentLoggerMock.kt => LoggerMock.kt} | 2 +- .../identus/walletsdk/mercury/MercuryTests.kt | 4 +- .../walletsdk/pluto/BackupRestorationTests.kt | 4 +- .../walletsdk/pollux/PolluxImplTest.kt | 6 +- 15 files changed, 97 insertions(+), 97 deletions(-) rename edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/{EdgeAgentLogger.kt => Logger.kt} (92%) rename edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/{EdgeAgentLoggerMock.kt => LoggerMock.kt} (96%) diff --git a/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt b/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt index 9a0dcfa81..b2c61a84d 100644 --- a/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt +++ b/edge-agent-sdk/src/androidInstrumentedTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/AnoncredsTests.kt @@ -40,7 +40,7 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.Off import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmission import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation import org.hyperledger.identus.walletsdk.domain.models.KeyValue -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock +import org.hyperledger.identus.walletsdk.logger.LoggerMock import org.hyperledger.identus.walletsdk.mercury.ApiMock import org.hyperledger.identus.walletsdk.pollux.PolluxImpl import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential @@ -114,7 +114,7 @@ class AnoncredsTests { connectionManager = connectionManager, seed = null, api = ApiMock(statusCode = HttpStatusCode.OK, response = "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val attachmentDescriptor = @@ -192,7 +192,7 @@ class AnoncredsTests { connectionManager = connectionManager, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val attachmentDescriptor = @@ -263,7 +263,7 @@ class AnoncredsTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val credential = AnonCredential.fromStorableData( @@ -355,7 +355,7 @@ class AnoncredsTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) ) diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt index 5708da63e..32e1c12c0 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt @@ -40,15 +40,17 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.SeedKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent +import org.hyperledger.identus.walletsdk.logger.LogLevel +import kotlin.math.log /** * Apollo defines the set of cryptographic operations that are used in the Atala PRISM. */ class ApolloImpl( - private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.APOLLO) + val logger: Logger = LoggerImpl(LogComponent.APOLLO) ) : Apollo { /** @@ -57,6 +59,7 @@ class ApolloImpl( * @return An array of mnemonic phrases. */ override fun createRandomMnemonics(): Array { + LogComponent.APOLLO.logLevel = LogLevel.INFO return MnemonicHelper.createRandomMnemonics().toTypedArray() } diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt index 136a76cd2..67a348b62 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt @@ -24,8 +24,8 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl /** * Castor is a powerful and flexible library for working with DIDs. Whether you are building a decentralised application @@ -36,7 +36,7 @@ class CastorImpl @JvmOverloads constructor( val apollo: Apollo, - private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.CASTOR) + private val logger: Logger = LoggerImpl(LogComponent.CASTOR) ) : Castor { var resolvers: Array = arrayOf( LongFormPrismDIDResolver(this.apollo), diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt index c765b6364..79d94e278 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt @@ -42,7 +42,7 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDUrl import org.hyperledger.identus.walletsdk.domain.models.OctetPublicKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.KeyPair import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata @@ -64,7 +64,7 @@ internal class CastorShared { * * @property logger The logger instance. */ - private val logger = EdgeAgentLoggerImpl(LogComponent.CASTOR) + private val logger = LoggerImpl(LogComponent.CASTOR) /** * parseDID parses a string representation of a Decentralized Identifier (DID) into a DID object. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt index 174bb10d5..73bcef5a2 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt @@ -107,8 +107,8 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.Metadata -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask import org.hyperledger.identus.walletsdk.pluto.PlutoRestoreTask import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1 @@ -153,7 +153,7 @@ open class EdgeAgent { private val edgeAgentScope: CoroutineScope = CoroutineScope(Dispatchers.Default) private val api: Api internal var connectionManager: ConnectionManager - private var logger: EdgeAgentLogger + private var logger: Logger private val agentOptions: AgentOptions /** @@ -181,7 +181,7 @@ open class EdgeAgent { connectionManager: ConnectionManager, seed: Seed?, api: Api?, - logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.EDGE_AGENT), + logger: Logger = LoggerImpl(LogComponent.EDGE_AGENT), agentOptions: AgentOptions = AgentOptions() ) { edgeAgentScope.launch { @@ -235,7 +235,7 @@ open class EdgeAgent { seed: Seed? = null, api: Api? = null, mediatorHandler: MediationHandler, - logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.EDGE_AGENT), + logger: Logger = LoggerImpl(LogComponent.EDGE_AGENT), agentOptions: AgentOptions = AgentOptions() ) { edgeAgentScope.launch { diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/Logger.kt similarity index 92% rename from edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt rename to edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/Logger.kt index 14ae24276..9412cbd2e 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLogger.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/logger/Logger.kt @@ -24,10 +24,10 @@ private const val METADATA_PRIVACY_STR = "------" private val hashingLog = UUID.randomUUID().toString() /** - * EdgeAgentLogger is an interface that defines methods for logging messages + * Logger is an interface that defines methods for logging messages * with different log levels and metadata. */ -interface EdgeAgentLogger { +interface Logger { /** * Logs a debug message with optional metadata. * @@ -66,26 +66,23 @@ interface EdgeAgentLogger { * @param error The error to be logged. * @param metadata An array of metadata objects to be included in the log message. Defaults to an empty array if not provided. * - * @see EdgeAgentLogger.error + * @see Logger.error * @see Metadata */ fun error(error: Error, metadata: Array = arrayOf()) } /** - * Implementation of the EdgeAgentLogger interface. + * Implementation of the Logger interface. * * @property category the LogComponent category for this logger */ -class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel = LogLevel.INFO, tag: String? = null) : - EdgeAgentLogger { +class LoggerImpl(private val category: LogComponent) : + Logger { private val log = logging( - if (tag != null) { - "$tag.$category" - } else { - "[org.hyperledger.identus.walletsdk.$category]" - } + "[${category::class.qualifiedName}.$category]" + ) /** @@ -95,7 +92,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @param metadata An array of metadata objects associated with the message (optional). */ override fun debug(message: String, metadata: Array) { - if (logLevel != LogLevel.NONE) { + if (category.logLevel != LogLevel.NONE) { log.debug { message } if (metadata.isNotEmpty()) { log.debug { "Metadata: ${arrayToString(metadata)}" } @@ -110,7 +107,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @param metadata An array of metadata objects to be associated with the information message. */ override fun info(message: String, metadata: Array) { - if (logLevel != LogLevel.NONE) { + if (category.logLevel != LogLevel.NONE) { log.info { message } if (metadata.isNotEmpty()) { log.info { "Metadata: ${arrayToString(metadata)}" } @@ -125,7 +122,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @param metadata An array of metadata objects associated with the warning message. */ override fun warning(message: String, metadata: Array) { - if (logLevel != LogLevel.NONE) { + if (category.logLevel != LogLevel.NONE) { log.warn { message } if (metadata.isNotEmpty()) { log.warn { "Metadata: ${arrayToString(metadata)}" } @@ -140,7 +137,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @param metadata An array of metadata objects to be associated with the error message (optional). */ override fun error(message: String, metadata: Array) { - if (logLevel != LogLevel.NONE) { + if (category.logLevel != LogLevel.NONE) { log.error { message } if (metadata.isNotEmpty()) { log.error { "Metadata: ${arrayToString(metadata)}" } @@ -155,7 +152,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @param metadata An array of metadata objects associated with the error (optional). */ override fun error(error: Error, metadata: Array) { - if (logLevel != LogLevel.NONE) { + if (category.logLevel != LogLevel.NONE) { log.error { error.message } if (metadata.isNotEmpty()) { log.error { "Metadata: ${arrayToString(metadata)}" } @@ -170,7 +167,7 @@ class EdgeAgentLoggerImpl(category: LogComponent, private var logLevel: LogLevel * @return The converted String representation of the Metadata objects, with each object's value separated by a new line. */ private fun arrayToString(array: Array): String { - return array.joinToString { "${it.getValue(logLevel)}\n" } + return array.joinToString { "${it.getValue(category.logLevel)}\n" } } } @@ -340,11 +337,11 @@ enum class LogLevel(val value: Int) { * - POLLUX * - EDGE_AGENT */ -enum class LogComponent { - APOLLO, - CASTOR, - MERCURY, - PLUTO, - POLLUX, - EDGE_AGENT +enum class LogComponent(var logLevel: LogLevel) { + APOLLO(LogLevel.DEBUG), + CASTOR(LogLevel.DEBUG), + MERCURY(LogLevel.DEBUG), + PLUTO(LogLevel.DEBUG), + POLLUX(LogLevel.DEBUG), + EDGE_AGENT(LogLevel.DEBUG) } diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt index 5feeb2038..88c56a883 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt @@ -13,8 +13,8 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDDocument import org.hyperledger.identus.walletsdk.domain.models.KeyValue import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata @@ -55,7 +55,7 @@ constructor( private val castor: Castor, private val protocol: DIDCommProtocol, private val api: Api, - private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.MERCURY) + private val logger: Logger = LoggerImpl(LogComponent.MERCURY) ) : Mercury { /** diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt index 4bbe6e251..735451e9b 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt @@ -33,7 +33,7 @@ import org.hyperledger.identus.walletsdk.domain.models.AttachmentDescriptor import org.hyperledger.identus.walletsdk.domain.models.DID import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Metadata @@ -56,7 +56,7 @@ class DIDCommWrapper(castor: Castor, pluto: Pluto, apollo: Apollo) : DIDCommProt private val didDocResolver = DIDCommDIDResolver(castor) private val secretsResolver = DIDCommSecretsResolver(pluto, apollo) private val didComm = DIDComm(didDocResolver, secretsResolver) - private val logger = EdgeAgentLoggerImpl(LogComponent.MERCURY) + private val logger = LoggerImpl(LogComponent.MERCURY) /** * Converts a JSON element to a map. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt index 1ce501870..b20485109 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pluto/PlutoImpl.kt @@ -35,8 +35,8 @@ 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.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.pluto.models.backup.BackupV0_0_1 import org.hyperledger.identus.walletsdk.pluto.data.DbConnection @@ -60,7 +60,7 @@ import org.hyperledger.identus.walletsdk.pluto.data.StorableCredential as Storab */ class PlutoImpl( private val connection: DbConnection, - private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.PLUTO) + private val logger: Logger = LoggerImpl(LogComponent.PLUTO) ) : Pluto { private var db: SdkPlutoDb? = null diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt index 66f471d67..dbc7f9305 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImpl.kt @@ -92,8 +92,8 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsAnoncreds import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsJWT -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerImpl +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.pluto.RestorationID import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential @@ -118,7 +118,7 @@ open class PolluxImpl( val apollo: Apollo, val castor: Castor, private val api: Api = ApiImpl(httpClient()), - private val logger: EdgeAgentLogger = EdgeAgentLoggerImpl(LogComponent.POLLUX) + private val logger: Logger = LoggerImpl(LogComponent.POLLUX) ) : Pollux { /** diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt index 52f020aa5..7dc3fd974 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt @@ -70,7 +70,7 @@ import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.Off import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.OutOfBandInvitation import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.PrismOnboardingInvitation import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock +import org.hyperledger.identus.walletsdk.logger.LoggerMock import org.hyperledger.identus.walletsdk.mercury.ApiMock import org.hyperledger.identus.walletsdk.pluto.CredentialRecovery import org.hyperledger.identus.walletsdk.pluto.PlutoBackupTask @@ -184,7 +184,7 @@ class EdgeAgentTests { connectionManager = connectionManager, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -226,7 +226,7 @@ class EdgeAgentTests { connectionManager = connectionManager, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -260,7 +260,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -280,7 +280,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -302,7 +302,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -325,7 +325,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -350,7 +350,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) plutoMockOld.getPrismLastKeyPathIndexReturn = flow { emit(0) } @@ -373,7 +373,7 @@ class EdgeAgentTests { connectionManagerMock, seed, null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) ) @@ -389,7 +389,7 @@ class EdgeAgentTests { @Test fun testCreateNewPeerDID_whenUpdateMediatorFalse_thenShouldUseProvidedServices() = runTest { val apollo = ApolloImpl() - val castor = CastorImpl(apollo = apollo, logger = EdgeAgentLoggerMock()) + val castor = CastorImpl(apollo = apollo, logger = LoggerMock()) val agent = EdgeAgent( apollo, castor, @@ -399,7 +399,7 @@ class EdgeAgentTests { connectionManagerOld, null, null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -435,7 +435,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val invitationString = """ { @@ -462,7 +462,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = api, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val invitationString = """ { @@ -489,7 +489,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val invitationString = """ { @@ -515,7 +515,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) plutoMockOld.getDIDPrivateKeysReturn = flow { emit(listOf(null)) } @@ -541,7 +541,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -584,7 +584,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -626,7 +626,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -667,7 +667,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -714,7 +714,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val invitationString = """ @@ -744,7 +744,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) assertEquals(EdgeAgent.State.STOPPED, agent.state) @@ -763,7 +763,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) agent.stop() @@ -783,7 +783,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = null, - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) val x = agent.parseInvitation(oob) @@ -845,7 +845,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -887,7 +887,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -915,7 +915,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = seed, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -961,7 +961,7 @@ class EdgeAgentTests { connectionManager = connectionManagerOld, seed = null, api = ApiMock(HttpStatusCode.OK, "{\"success\":\"true\"}"), - logger = EdgeAgentLoggerMock(), + logger = LoggerMock(), agentOptions = AgentOptions() ) @@ -1035,7 +1035,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val vmAuthentication = DIDDocument.VerificationMethod( @@ -1133,7 +1133,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val vmAuthentication = DIDDocument.VerificationMethod( @@ -1251,7 +1251,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val msg = Json.decodeFromString( "{\"id\":\"00000000-685c-4004-0000-000036ac64ee\",\"piuri\":\"https://didcomm.atalaprism.io/present-proof/3.0/request-presentation\",\"from\":{\"method\":\"peer\",\"methodId\":\"asdfasdf\"},\"to\":{\"method\":\"peer\",\"methodId\":\"fdsafdsa\"},\"fromPrior\":null,\"body\":\"{}\",\"createdTime\":\"2024-03-08T19:27:38.196506Z\",\"expiresTimePlus\":\"2024-03-09T19:27:38.196559Z\",\"attachments\":[{\"id\":\"00000000-9c2e-4249-0000-0000c1176949\",\"mediaType\":\"application/json\",\"data\":{\"type\":\"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64\",\"base64\":\"eyJwcmVzZW50YXRpb25fZGVmaW5pdGlvbiI6eyJpZCI6IjMyZjU0MTYzLTcxNjYtNDhmMS05M2Q4LWZmMjE3YmRiMDY1MyIsImlucHV0X2Rlc2NyaXB0b3JzIjpbeyJpZCI6IndhX2RyaXZlcl9saWNlbnNlIiwibmFtZSI6Ildhc2hpbmd0b24gU3RhdGUgQnVzaW5lc3MgTGljZW5zZSIsInB1cnBvc2UiOiJXZSBjYW4gb25seSBhbGxvdyBsaWNlbnNlZCBXYXNoaW5ndG9uIFN0YXRlIGJ1c2luZXNzIHJlcHJlc2VudGF0aXZlcyBpbnRvIHRoZSBXQSBCdXNpbmVzcyBDb25mZXJlbmNlIiwiY29uc3RyYWludHMiOnsiZmllbGRzIjpbeyJwYXRoIjpbIiQuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiIsIiQudmMuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLnZjLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiJdfV19fV0sImZvcm1hdCI6eyJqd3QiOnsiYWxnIjpbIkVTMjU2SyJdfX19LCAib3B0aW9ucyI6IHsiZG9tYWluIjogImRvbWFpbiIsICJjaGFsbGVuZ2UiOiAiY2hhbGxlbmdlIn19\"},\"format\":\"dif/presentation-exchange/fail_test@v1.0\"}],\"thid\":\"00000000-ef9d-4722-0000-00003b1bc908\",\"ack\":[]}" @@ -1291,7 +1291,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val msg = Json.decodeFromString( "{\"id\":\"00000000-685c-4004-0000-000036ac64ee\",\"piuri\":\"https://didcomm.atalaprism.io/present-proof/3.0/presentation\",\"from\":{\"method\":\"peer\",\"methodId\":\"asdfasdf\"},\"to\":{\"method\":\"peer\",\"methodId\":\"fdsafdsa\"},\"fromPrior\":null,\"body\":\"{}\",\"createdTime\":\"2024-03-08T19:27:38.196506Z\",\"expiresTimePlus\":\"2024-03-09T19:27:38.196559Z\",\"attachments\":[{\"id\":\"00000000-9c2e-4249-0000-0000c1176949\",\"mediaType\":\"application/json\",\"data\":{\"type\":\"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64\",\"base64\":\"eyJ2ZXJpZmlhYmxlUHJlc2VudGF0aW9uIjpbImV5SmhiR2NpT2lKRlV6STFOa3NpZlEuZXlKcGMzTWlPaUprYVdRNmNISnBjMjA2TWpVM01UbGhPVFppTVRVeE1qQTNNVFk1T0RGaE9EUXpNR0ZrTUdOaU9UWTRaR1ExTXpRd056TTFPVE5qT0dOa00yWXhaREkzWVRZNE1EUmxZelV3WlRwRGNHOURRM0JqUTBWc2IwdENWM1JzWlZNd2VFVkJTa05VZDI5S1l6SldhbU5FU1RGT2JYTjRSV2xCUlc5VFEyNDFkSGxFWVRaWk5uSXRTVzFUY1hCS09Ga3hiV28zU2tNelgyOVZla1V3VG5sNVJXbERRbTluYzJkT1lXVlNaR05EVWtkUWJHVTRNbFoyT1hSS1prNTNiRFp5WnpaV1kyaFNNMDl4YUdsV1lsUmhPRk5YZDI5SFdWaFdNR0ZETUhoRlFWSkRWSGR2U21NeVZtcGpSRWt4VG0xemVFVnBSRTFyUW1RMlJuUnBiMHByTTFoUFJuVXRYMk41TlZodFVpMDBkRlZSTWs1TVIybFhPR0ZKVTI5dGExSnZaelpUWkdVNVVIZHVSekJSTUZOQ1ZHMUdVMVJFWWxOTFFuWkpWalpEVkV4WWNtcEpTblIwWlVkSmJVRlRXRUZ2U0dKWFJucGtSMVo1VFVKQlFsRnJPRXREV0U1c1dUTkJlVTVVV25KTlVrbG5UemN4TUcxME1WZGZhWGhFZVZGTk0zaEpjemRVY0dwTVEwNVBSRkY0WjFab2VEVnphR1pMVGxneGIyRkpTRmRRY25jM1NWVkxiR1pwWWxGMGVEWkthelJVVTJwblkxZE9UMlpqVDNSVk9VUTVVSFZhTjFRNWRDSXNJbk4xWWlJNkltUnBaRHB3Y21semJUcGlaV1ZoTlRJek5HRm1ORFk0TURRM01UUmtPR1ZoT0dWak56ZGlOalpqWXpkbU0yVTRNVFZqTmpoaFltSTBOelZtTWpVMFkyWTVZek13TmpJMk56WXpPa056WTBKRGMxRkNSVzFSUzBReVJqRmtSMmhzWW01U2NGa3lSakJoVnpsMVRVSkJSVkZyT0V0RFdFNXNXVE5CZVU1VVduSk5Va2xuWlZObkxUSlBUekZLWkc1d2VsVlBRbWwwZWtscFkxaGtabnBsUVdOVVpsZEJUaTFaUTJWMVEySjVTV0ZKU2xFMFIxUkpNekIwWVZacGQyTm9WRE5sTUc1TVdFSlRORE5DTkdvNWFteHpiRXR2TWxwc1pGaDZha1ZzZDB0Q01qRm9Zek5TYkdOcVFWRkJWVXBRUTJkc2VscFhUbmROYWxVeVlYcEZVMGxJYTI5UWRHcHFkRk5ZV2paak1VUm5XWEpqZVVsdVJqTllPRE5uU0VVek1XZEVabTFCYm5KbmJUaHBSMmxEVlU5Q2EzbE9PVXhYYkZselNFbFZPVE4wU25reGQxVjFUbmRsU1Y5Wk5XSktVM0ZPYlZwWVZqZzBkeUlzSW01aVppSTZNVFk0TlRZek1UazVOU3dpWlhod0lqb3hOamcxTmpNMU5UazFMQ0oyWXlJNmV5SmpjbVZrWlc1MGFXRnNVM1ZpYW1WamRDSTZleUpoWkdScGRHbHZibUZzVUhKdmNESWlPaUpVWlhOME15SXNJbWxrSWpvaVpHbGtPbkJ5YVhOdE9tSmxaV0UxTWpNMFlXWTBOamd3TkRjeE5HUTRaV0U0WldNM04ySTJObU5qTjJZelpUZ3hOV00yT0dGaVlqUTNOV1l5TlRSalpqbGpNekEyTWpZM05qTTZRM05qUWtOelVVSkZiVkZMUkRKR01XUkhhR3hpYmxKd1dUSkdNR0ZYT1hWTlFrRkZVV3M0UzBOWVRteFpNMEY1VGxSYWNrMVNTV2RsVTJjdE1rOVBNVXBrYm5CNlZVOUNhWFI2U1dsaldHUm1lbVZCWTFSbVYwRk9MVmxEWlhWRFlubEpZVWxLVVRSSFZFa3pNSFJoVm1sM1kyaFVNMlV3Ymt4WVFsTTBNMEkwYWpscWJITnNTMjh5V214a1dIcHFSV3gzUzBJeU1XaGpNMUpzWTJwQlVVRlZTbEJEWjJ4NldsZE9kMDFxVlRKaGVrVlRTVWhyYjFCMGFtcDBVMWhhTm1NeFJHZFpjbU41U1c1R00xZzRNMmRJUlRNeFowUm1iVUZ1Y21kdE9HbEhhVU5WVDBKcmVVNDVURmRzV1hOSVNWVTVNM1JLZVRGM1ZYVk9kMlZKWDFrMVlrcFRjVTV0V2xoV09EUjNJbjBzSW5SNWNHVWlPbHNpVm1WeWFXWnBZV0pzWlVOeVpXUmxiblJwWVd3aVhTd2lRR052Ym5SbGVIUWlPbHNpYUhSMGNITTZYQzljTDNkM2R5NTNNeTV2Y21kY0x6SXdNVGhjTDJOeVpXUmxiblJwWVd4elhDOTJNU0pkZlgwLngwU0YxN1kwVkNEbXQ3SGNlT2RUeGZIbG9mc1ptWTE4Um42VlFiMC1yLWtfQm0zaFRpMS1rMnZrZGpCMjVoZHh5VEN2eGFtLUFrQVAtQWczQWhuNU5nIl19\"},\"format\":\"dif/presentation-exchange/definitions@v1.0\"}],\"thid\":\"00000000-ef9d-4722-0000-00003b1bc908\",\"ack\":[]}" @@ -1362,7 +1362,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val msg = Json.decodeFromString( """{"id":"00000000-685c-4004-0000-000036ac64ee","piuri":"https://didcomm.atalaprism.io/present-proof/3.0/request-presentation","from":{"method":"peer","methodId":"asdfasdf"},"to":{"method":"peer","methodId":"fdsafdsa"},"fromPrior":null,"body":"{}","createdTime":"2024-03-08T19:27:38.196506Z","expiresTimePlus":"2024-03-09T19:27:38.196559Z","attachments":[{"id":"00000000-9c2e-4249-0000-0000c1176949","mediaType":"application/json","data":{"type":"org.hyperledger.identus.walletsdk.domain.models.AttachmentBase64","base64":"eyJwcmVzZW50YXRpb25fZGVmaW5pdGlvbiI6eyJpZCI6IjMyZjU0MTYzLTcxNjYtNDhmMS05M2Q4LWZmMjE3YmRiMDY1MyIsImlucHV0X2Rlc2NyaXB0b3JzIjpbeyJpZCI6IndhX2RyaXZlcl9saWNlbnNlIiwibmFtZSI6Ildhc2hpbmd0b24gU3RhdGUgQnVzaW5lc3MgTGljZW5zZSIsInB1cnBvc2UiOiJXZSBjYW4gb25seSBhbGxvdyBsaWNlbnNlZCBXYXNoaW5ndG9uIFN0YXRlIGJ1c2luZXNzIHJlcHJlc2VudGF0aXZlcyBpbnRvIHRoZSBXQSBCdXNpbmVzcyBDb25mZXJlbmNlIiwiY29uc3RyYWludHMiOnsiZmllbGRzIjpbeyJwYXRoIjpbIiQuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiIsIiQudmMuY3JlZGVudGlhbFN1YmplY3QuZGF0ZU9mQmlydGgiLCIkLnZjLmNyZWRlbnRpYWxTdWJqZWN0LmRvYiJdfV19fV0sImZvcm1hdCI6eyJqd3QiOnsiYWxnIjpbIkVTMjU2SyJdfX19LCAib3B0aW9ucyI6IHsiZG9tYWluIjogImRvbWFpbiIsICJjaGFsbGVuZ2UiOiAiY2hhbGxlbmdlIn19"},"format":"dif/presentation-exchange/definitions@v1.0"}],"thid":"00000000-ef9d-4722-0000-00003b1bc908","ack":[]}""" @@ -1416,7 +1416,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val credential = JWTCredential.fromJwtString( @@ -1524,7 +1524,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val msgString = @@ -1647,7 +1647,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = apiMock, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) val msgString = @@ -1668,7 +1668,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = EdgeAgentLoggerMock() + logger = LoggerMock() ) `when`( apolloMock.createPrivateKey( diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/LoggerMock.kt similarity index 96% rename from edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt rename to edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/LoggerMock.kt index 3448e197e..5a6eaa2cd 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/EdgeAgentLoggerMock.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/logger/LoggerMock.kt @@ -1,6 +1,6 @@ package org.hyperledger.identus.walletsdk.logger -class EdgeAgentLoggerMock : EdgeAgentLogger { +class LoggerMock : Logger { private var logLevel: LogLevel = LogLevel.NONE diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt index 41c398bc4..eb42ae62a 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryTests.kt @@ -6,7 +6,7 @@ import org.hyperledger.identus.walletsdk.domain.models.DID import org.hyperledger.identus.walletsdk.domain.models.DIDDocument import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLoggerMock +import org.hyperledger.identus.walletsdk.logger.LoggerMock import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFailsWith @@ -24,7 +24,7 @@ class MercuryTests { apiMock = ApiMock(HttpStatusCode.OK, "") castorMock = CastorMock() protocolMock = ProtocolMock() - sut = MercuryImpl(castorMock, protocolMock, apiMock, EdgeAgentLoggerMock()) + sut = MercuryImpl(castorMock, protocolMock, apiMock, LoggerMock()) } @Test diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt index 55febd727..ad678b453 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pluto/BackupRestorationTests.kt @@ -32,7 +32,7 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey 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.EdgeAgentLoggerMock +import org.hyperledger.identus.walletsdk.logger.LoggerMock 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 @@ -578,7 +578,7 @@ class BackupRestorationTests { @Test fun restoreFromTS_Swift() = runTest { val realPluto = PlutoImpl(DbConnectionInMemory()) - val logger = EdgeAgentLoggerMock() + val logger = LoggerMock() val realCastor = CastorImpl(apollo, logger) diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt index 7a100ef9a..c35f6f868 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/pollux/PolluxImplTest.kt @@ -50,7 +50,7 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PrivateKey import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.AnoncredsPresentationOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.JWTPresentationOptions import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.PresentationSubmissionOptionsJWT -import org.hyperledger.identus.walletsdk.logger.EdgeAgentLogger +import org.hyperledger.identus.walletsdk.logger.Logger import org.hyperledger.identus.walletsdk.pollux.models.AnonCredential import org.hyperledger.identus.walletsdk.pollux.models.AnoncredsPresentationDefinitionRequest import org.hyperledger.identus.walletsdk.pollux.models.JWTCredential @@ -81,7 +81,7 @@ class PolluxImplTest { lateinit var castorMock: Castor @Mock - lateinit var loggerMock: EdgeAgentLogger + lateinit var loggerMock: Logger @Before fun setup() { @@ -330,7 +330,7 @@ class PolluxImplTest { @Test fun testCreatePresentationSubmission_whenAllCorrect_thenPresentationSubmissionProofWellFormed() = runTest { - val loggerMock = mock() + val loggerMock = mock() val castor: Castor = CastorImpl(apollo = ApolloImpl(), loggerMock) val issuerKeyPair = From fc3cb2df2ea1e430616975f6d8350f68cb2a937d Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 16 Sep 2024 11:30:03 -0400 Subject: [PATCH 3/4] fix: lingint Signed-off-by: Cristian G --- .../org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt | 5 ++--- .../identus/walletsdk/castor/shared/CastorShared.kt | 2 +- .../org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt | 4 ++-- .../identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt index 32e1c12c0..11c67a738 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt @@ -40,11 +40,10 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.SeedKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey -import org.hyperledger.identus.walletsdk.logger.Logger -import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel -import kotlin.math.log +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl /** * Apollo defines the set of cryptographic operations that are used in the Atala PRISM. diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt index 79d94e278..bfc976a57 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/shared/CastorShared.kt @@ -42,9 +42,9 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDUrl import org.hyperledger.identus.walletsdk.domain.models.OctetPublicKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.KeyPair import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey -import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.Metadata import org.kotlincrypto.hash.sha2.SHA256 import pbandk.decodeFromByteArray diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt index 88c56a883..d6a1c74a7 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/MercuryImpl.kt @@ -13,10 +13,10 @@ import org.hyperledger.identus.walletsdk.domain.models.DIDDocument import org.hyperledger.identus.walletsdk.domain.models.KeyValue import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.Logger -import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel +import org.hyperledger.identus.walletsdk.logger.Logger +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.Metadata import org.hyperledger.identus.walletsdk.mercury.forward.ForwardMessage diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt index 735451e9b..c0d5566ad 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/mercury/resolvers/DIDCommWrapper.kt @@ -33,9 +33,9 @@ import org.hyperledger.identus.walletsdk.domain.models.AttachmentDescriptor import org.hyperledger.identus.walletsdk.domain.models.DID import org.hyperledger.identus.walletsdk.domain.models.MercuryError import org.hyperledger.identus.walletsdk.domain.models.Message -import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel +import org.hyperledger.identus.walletsdk.logger.LoggerImpl import org.hyperledger.identus.walletsdk.logger.Metadata import org.hyperledger.identus.walletsdk.mercury.ATTACHMENT_SEPARATOR import org.hyperledger.identus.walletsdk.mercury.BASE64 From a8c2b74d9ee835a2a8652e138cfea14974edcaa1 Mon Sep 17 00:00:00 2001 From: Cristian G Date: Mon, 16 Sep 2024 11:40:54 -0400 Subject: [PATCH 4/4] fix: unresolved reference Signed-off-by: Cristian G --- .../hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt index 9c3d013b1..a11936bd4 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt @@ -1868,7 +1868,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock() + logger = LoggerMock() ) ) @@ -1896,7 +1896,7 @@ class EdgeAgentTests { connectionManager = connectionManagerMock, seed = seed, api = null, - logger = PrismLoggerMock() + logger = LoggerMock() ) )