Skip to content

Commit

Permalink
chore: AnonCred linting (#162)
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <ahmed.moussa@iohk.io>
  • Loading branch information
hamada147 authored Jun 12, 2024
1 parent f21df25 commit 454e4e7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions edge-agent-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ kotlin {
}
val androidInstrumentedTest by getting {
dependencies {
dependsOn(commonTest)
implementation(kotlin("test"))
implementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("androidx.test.ext:junit:1.1.5")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.hyperledger.identus.walletsdk.edgeagent

import org.junit.Ignore

actual typealias AndroidIgnore = Ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.hyperledger.identus.walletsdk.logger.PrismLoggerMock
import org.hyperledger.identus.walletsdk.mercury.ApiMock
import org.hyperledger.identus.walletsdk.pollux.PolluxImpl
import org.hyperledger.identus.walletsdk.pollux.models.CredentialRequestMeta
import org.hyperledger.identus.walletsdk.pollux.models.LinkSecretBlindingData
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.CredentialPreview
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.IssueCredential
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.OfferCredential
Expand All @@ -23,7 +22,11 @@ import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertTrue
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -52,7 +55,14 @@ class AnoncredsTests {
polluxMock = PolluxMock()
mediationHandlerMock = MediationHandlerMock()
// Pairing will be removed in the future
connectionManager = ConnectionManagerImpl(mercuryMock, castorMock, plutoMock, mediationHandlerMock, mutableListOf())
connectionManager = ConnectionManagerImpl(
mercuryMock,
castorMock,
plutoMock,
mediationHandlerMock,
mutableListOf(),
polluxMock
)
json = Json {
ignoreUnknownKeys = true
prettyPrint = true
Expand Down Expand Up @@ -97,7 +107,11 @@ class AnoncredsTests {
body = OfferCredential.Body(
credentialPreview = CredentialPreview(
attributes = arrayOf(
CredentialPreview.Attribute(name = "Name", value = "Value", mediaType = "application/json")
CredentialPreview.Attribute(
name = "Name",
value = "Value",
mediaType = "application/json"
)
)
)
),
Expand All @@ -106,7 +120,8 @@ class AnoncredsTests {
from = fromDID,
to = toDID
)
val requestCredential = agent.prepareRequestCredentialWithIssuer(did = toDID, offer = offerCredential)
val requestCredential =
agent.prepareRequestCredentialWithIssuer(did = toDID, offer = offerCredential)

assertEquals(offerCredential.from, requestCredential.to)
assertEquals(offerCredential.to, requestCredential.from)
Expand All @@ -127,12 +142,21 @@ class AnoncredsTests {
val pollux = PolluxImpl(castorMock, apiMock)
plutoMock.getLinkSecretReturn = flow { emit(LinkSecret().getValue()) }
val meta = CredentialRequestMeta(
linkSecretBlindingData = LinkSecretBlindingData(
vPrime = "25640768589781180388780947458530942508097609060195936083325202836425537796105863532996457182896416190370043209557677698887790935151362153536943154068082466343529339252470449056527102073900035205398743827912718037139005903291819127500631482122295491777147526837712271367909449810555177615439256541701422814752128559601153332207720895418174855363389532697304935246097129194680107532713993463598420823365761867328806906368762890406604820633668919158697683127114469035627228895027952792675790305070772499052052690434104276748788760647551842035459213572765697025729553350526825112536685989553872204362324245819081933885546131268965572563884162204",
vrPrime = null
),
linkSecretName = "1",
nonce = "519571990522308752875135"
json = Json.encodeToString(
JsonObject(
mapOf(
"linkSecretBlindingData" to JsonObject(
mapOf(
"vPrime" to JsonPrimitive("25640768589781180388780947458530942508097609060195936083325202836425537796105863532996457182896416190370043209557677698887790935151362153536943154068082466343529339252470449056527102073900035205398743827912718037139005903291819127500631482122295491777147526837712271367909449810555177615439256541701422814752128559601153332207720895418174855363389532697304935246097129194680107532713993463598420823365761867328806906368762890406604820633668919158697683127114469035627228895027952792675790305070772499052052690434104276748788760647551842035459213572765697025729553350526825112536685989553872204362324245819081933885546131268965572563884162204"),
"vrPrime" to JsonNull
)
),
"linkSecretName" to JsonPrimitive("1"),
"nonce" to JsonPrimitive("519571990522308752875135")
)
)
)
)
plutoMock.getCredentialMetadataReturn = flow { emit(meta) }

Expand Down

0 comments on commit 454e4e7

Please sign in to comment.