Skip to content

Commit

Permalink
merging with latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
todorkoleviohk committed Jun 11, 2024
2 parents d436a25 + 654da15 commit be54220
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 69 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Pods/
dependinces.log
node_modules
megalinter-reports
tests/end-to-end/target
4 changes: 2 additions & 2 deletions tests/end-to-end/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Duplicate `local.properties.example` file from `test/resources` and rename the c
Setup properties:

| Property | Explanation |
|--------------------------|------------------------------------|
| ------------------------ | ---------------------------------- |
| MEDIATOR_OOB_URL | Mediator OOB url invitation |
| PRISM_AGENT_URL | Open enterprise agent url |
| AGENT_URL | Agent url |
| PUBLISHED_DID | Existing published DID |
| JWT_SCHEMA_GUID | Existing JWT schema guid |
| ANONCRED_DEFINITION_GUID | Existing Anoncred definition guid |
Expand Down
5 changes: 2 additions & 3 deletions tests/end-to-end/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id("net.serenity-bdd.serenity-gradle-plugin") version "4.0.1"
}

group = "io.iohk.atala.prism"
group = "org.hyperledger.identus"
version = "1.0-SNAPSHOT"

repositories {
Expand All @@ -28,8 +28,7 @@ repositories {
}

dependencies {
//testImplementation("io.iohk.atala.prism.walletsdk:atala-prism-sdk:3.0.0-todor")
testImplementation("org.hyperledger.identus:edge-agent-sdk:3.0.0-todor")
testImplementation("org.hyperledger.identus:edge-agent-sdk:3.0.0")
testImplementation("io.iohk.atala.prism:prism-kotlin-client:1.31.0")
testImplementation("io.iohk.atala:atala-automation:0.3.2")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism
package org.hyperledger.identus.walletsdk

import io.cucumber.junit.CucumberOptions
import net.serenitybdd.cucumber.CucumberWithSerenity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
package io.iohk.atala.prism.abilities
package org.hyperledger.identus.walletsdk.abilities

import com.jayway.jsonpath.JsonPath
import io.iohk.atala.automation.utils.Logger
import io.iohk.atala.prism.configuration.Environment
import io.iohk.atala.prism.walletsdk.apollo.ApolloImpl
import io.iohk.atala.prism.walletsdk.castor.CastorImpl
import io.iohk.atala.prism.walletsdk.domain.models.ApiImpl
import io.iohk.atala.prism.walletsdk.domain.models.DID
import io.iohk.atala.prism.walletsdk.domain.models.Message
import io.iohk.atala.prism.walletsdk.domain.models.httpClient
import io.iohk.atala.prism.walletsdk.mercury.MercuryImpl
import io.iohk.atala.prism.walletsdk.mercury.resolvers.DIDCommWrapper
import io.iohk.atala.prism.walletsdk.pluto.PlutoImpl
import io.iohk.atala.prism.walletsdk.pluto.data.DbConnection
import io.iohk.atala.prism.walletsdk.pollux.PolluxImpl
import io.iohk.atala.prism.walletsdk.prismagent.PrismAgent
import io.iohk.atala.prism.walletsdk.prismagent.mediation.BasicMediatorHandler
import io.iohk.atala.prism.walletsdk.prismagent.protocols.ProtocolType
import io.iohk.atala.prism.workflow.EdgeAgentWorkflow
import org.hyperledger.identus.walletsdk.configuration.Environment

import org.hyperledger.identus.walletsdk.workflow.EdgeAgentWorkflow
import io.restassured.RestAssured
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand All @@ -27,6 +14,20 @@ import net.serenitybdd.screenplay.Ability
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.Question
import net.serenitybdd.screenplay.SilentInteraction
import org.hyperledger.identus.walletsdk.apollo.ApolloImpl
import org.hyperledger.identus.walletsdk.castor.CastorImpl
import org.hyperledger.identus.walletsdk.domain.models.ApiImpl
import org.hyperledger.identus.walletsdk.domain.models.DID
import org.hyperledger.identus.walletsdk.domain.models.Message
import org.hyperledger.identus.walletsdk.domain.models.httpClient
import org.hyperledger.identus.walletsdk.edgeagent.EdgeAgent
import org.hyperledger.identus.walletsdk.edgeagent.mediation.BasicMediatorHandler
import org.hyperledger.identus.walletsdk.edgeagent.protocols.ProtocolType
import org.hyperledger.identus.walletsdk.mercury.MercuryImpl
import org.hyperledger.identus.walletsdk.mercury.resolvers.DIDCommWrapper
import org.hyperledger.identus.walletsdk.pluto.PlutoImpl
import org.hyperledger.identus.walletsdk.pluto.data.DbConnection
import org.hyperledger.identus.walletsdk.pollux.PolluxImpl
import java.util.*


Expand Down Expand Up @@ -104,7 +105,7 @@ class UseWalletSdk : Ability {
val handler = BasicMediatorHandler(mediatorDid, mercury, store)
val seed = apollo.createRandomSeed().seed

val sdk = PrismAgent(
val sdk = EdgeAgent(
apollo,
castor,
pluto,
Expand Down Expand Up @@ -153,7 +154,7 @@ class UseWalletSdk : Ability {
}

data class SdkContext(
val sdk: PrismAgent,
val sdk: EdgeAgent,
val credentialOfferStack: MutableList<Message> = Collections.synchronizedList(mutableListOf()),
val proofRequestStack: MutableList<Message> = Collections.synchronizedList(mutableListOf()),
val issuedCredentialStack: MutableList<Message> = Collections.synchronizedList(mutableListOf()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package io.iohk.atala.prism.configuration
package org.hyperledger.identus.walletsdk.configuration

import io.cucumber.java.BeforeAll
import io.iohk.atala.automation.utils.Logger
import io.iohk.atala.automation.utils.Wait
import io.iohk.atala.prism.models.*
import io.iohk.atala.prism.utils.Notes
import org.hyperledger.identus.walletsdk.utils.Notes
import io.restassured.RestAssured
import io.restassured.builder.RequestSpecBuilder
import io.restassured.response.Response
import net.serenitybdd.rest.SerenityRest
import org.apache.http.HttpStatus
import org.assertj.core.api.Assertions.assertThat
import org.hyperledger.identus.walletsdk.models.AnoncredSchema
import org.hyperledger.identus.walletsdk.models.JwtSchema
import org.hyperledger.identus.walletsdk.models.JwtSchemaProperty
import java.io.File
import java.util.*
import kotlin.time.Duration.Companion.seconds

object Environment {
private val logger = Logger.get<Environment>()

lateinit var agentUrl: String
lateinit var mediatorOobUrl: String
lateinit var publishedDid: String
Expand All @@ -43,7 +42,7 @@ object Environment {
properties.putAll(System.getenv())

mediatorOobUrl = properties.getProperty("MEDIATOR_OOB_URL")
agentUrl = properties.getProperty("PRISM_AGENT_URL")
agentUrl = properties.getProperty("AGENT_URL")

// set base uri for rest assured
RestAssured.baseURI = agentUrl
Expand Down Expand Up @@ -72,20 +71,20 @@ object Environment {
private fun getSdkVersion(): String {
val file = File("build.gradle.kts")
val input = file.readText()
val regex = Regex("prism-sdk:(.*)(?=\")")
val regex = Regex("edge-agent-sdk:(.*)(?=\")")
return regex.find(input)!!.groups[1]!!.value
}

/**
* Checks if the environment PUBLISHED_DID variable exists in prism-agent, otherwise it creates a new one.
* Checks if the environment PUBLISHED_DID variable exists in cloud-agent, otherwise it creates a new one.
*/
private fun preparePublishedDid(publishedDid: String?) {
try {
assertThat(publishedDid).isNotEmpty()
RestAssured
.given().get("did-registrar/dids/$publishedDid")
.then().assertThat().statusCode(200)
this.publishedDid = publishedDid!!
Environment.publishedDid = publishedDid!!
return
} catch (e: AssertionError) {
Notes.appendMessage("DID [${publishedDid}] not found. Creating a new one.")
Expand Down Expand Up @@ -124,19 +123,19 @@ object Environment {
.thenReturn()
response.body.jsonPath().getString("status") == "PUBLISHED"
}
this.publishedDid = response.body.jsonPath().getString("did")
Environment.publishedDid = response.body.jsonPath().getString("did")
}

/**
* Checks if the environment variable exists in prism-agent, otherwise it creates a new one.
* Checks if the environment variable exists in cloud-agent, otherwise it creates a new one.
*/
private fun checkJwtSchema(schemaGuid: String?) {
try {
assertThat(schemaGuid).isNotEmpty()
RestAssured
.given().get("schema-registry/schemas/$schemaGuid")
.then().assertThat().statusCode(200)
this.jwtSchemaGuid = schemaGuid!!
jwtSchemaGuid = schemaGuid!!
return
} catch (e: AssertionError) {
Notes.appendMessage("JWT schema [${schemaGuid}] not found. Creating a new one.")
Expand All @@ -154,7 +153,7 @@ object Environment {
jwtSchema.properties["automation-optional"] = JwtSchemaProperty("string")

val credentialSchemaInput = CredentialSchemaInput(
author = this.publishedDid,
author = publishedDid,
description = "Some description to automation generated schema",
name = schemaName,
tags = listOf("automation"),
Expand All @@ -168,7 +167,7 @@ object Environment {
.post("/schema-registry/schemas")
.thenReturn()

this.jwtSchemaGuid = schemaCreationResponse.body.jsonPath().getString("guid")
jwtSchemaGuid = schemaCreationResponse.body.jsonPath().getString("guid")
}

private fun checkAnonCredSchema(definitionId: String?) {
Expand All @@ -178,7 +177,7 @@ object Environment {
.given().get("credential-definition-registry/definitions/${definitionId}")
.then().assertThat().statusCode(200)

this.anoncredDefinitionId = definitionId!!
anoncredDefinitionId = definitionId!!
return
} catch (e: AssertionError) {
Notes.appendMessage("Anoncred Definition not found for [${definitionId}]. Creating a new one.")
Expand All @@ -189,11 +188,11 @@ object Environment {
val anoncredSchema = AnoncredSchema()
anoncredSchema.name = "Automation Anoncred"
anoncredSchema.version = "1.0"
anoncredSchema.issuerId = this.publishedDid
anoncredSchema.issuerId = publishedDid
anoncredSchema.attrNames = mutableListOf("name", "age", "gender")

val credentialSchemaInput = CredentialSchemaInput(
author = this.publishedDid,
author = publishedDid,
description = "Some description to automation generated schema",
name = schemaName,
tags = listOf("automation"),
Expand All @@ -217,7 +216,7 @@ object Environment {
version = "1.0.0",
tag = "automation-test",
author = publishedDid,
schemaId = "${agentUrl}/schema-registry/schemas/${newSchemaGuid}/schema",
schemaId = "$agentUrl/schema-registry/schemas/${newSchemaGuid}/schema",
signatureType = "CL",
supportRevocation = false,
description = "Test Automation Auto-Generated"
Expand All @@ -228,6 +227,6 @@ object Environment {
.then().assertThat().statusCode(201)
.extract().`as`(CredentialDefinitionResponse::class.java)

this.anoncredDefinitionId = credentialDefinition.guid.toString()
anoncredDefinitionId = credentialDefinition.guid.toString()
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.iohk.atala.prism.configuration
package org.hyperledger.identus.walletsdk.configuration

import io.cucumber.java.Before
import io.cucumber.java.BeforeAll
import io.cucumber.java.ParameterType
import io.iohk.atala.prism.abilities.UseWalletSdk
import org.hyperledger.identus.walletsdk.abilities.UseWalletSdk
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.actors.Cast
import net.serenitybdd.screenplay.actors.OnStage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism.models
package org.hyperledger.identus.walletsdk.models

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism.models
package org.hyperledger.identus.walletsdk.models

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism.models
package org.hyperledger.identus.walletsdk.models

import com.google.gson.annotations.SerializedName

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.iohk.atala.prism.steps
package org.hyperledger.identus.walletsdk.steps

import io.cucumber.java.en.Given
import io.cucumber.java.en.Then
import io.cucumber.java.en.When
import io.iohk.atala.prism.workflow.CloudAgentWorkflow
import io.iohk.atala.prism.workflow.EdgeAgentWorkflow
import org.hyperledger.identus.walletsdk.workflow.CloudAgentWorkflow
import org.hyperledger.identus.walletsdk.workflow.EdgeAgentWorkflow
import net.serenitybdd.screenplay.Actor
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism.utils
package org.hyperledger.identus.walletsdk.utils

import io.iohk.atala.automation.utils.Logger
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.iohk.atala.prism.utils
package org.hyperledger.identus.walletsdk.utils

import java.security.SecureRandom

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.iohk.atala.prism.workflow
package org.hyperledger.identus.walletsdk.workflow

import io.iohk.atala.automation.extensions.body
import io.iohk.atala.automation.extensions.get
import io.iohk.atala.automation.matchers.RestAssuredJsonProperty
import io.iohk.atala.automation.serenity.ensure.Ensure
import io.iohk.atala.automation.serenity.interactions.PollingWait
import io.iohk.atala.automation.serenity.questions.HttpRequest
import io.iohk.atala.prism.configuration.Environment
import org.hyperledger.identus.walletsdk.configuration.Environment
import io.iohk.atala.prism.models.AnoncredPresentationRequestV1
import io.iohk.atala.prism.models.AnoncredRequestedAttributeV1
import io.iohk.atala.prism.models.AnoncredRequestedPredicateV1
Expand All @@ -15,7 +15,7 @@ import io.iohk.atala.prism.models.CreateIssueCredentialRecordRequest
import io.iohk.atala.prism.models.Options
import io.iohk.atala.prism.models.ProofRequestAux
import io.iohk.atala.prism.models.RequestPresentationInput
import io.iohk.atala.prism.utils.Utils
import org.hyperledger.identus.walletsdk.utils.Utils
import net.serenitybdd.rest.SerenityRest.lastResponse
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.rest.interactions.Patch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package io.iohk.atala.prism.workflow
package org.hyperledger.identus.walletsdk.workflow

import com.google.gson.GsonBuilder
import io.iohk.atala.automation.serenity.interactions.PollingWait
import io.iohk.atala.automation.utils.Logger
import io.iohk.atala.prism.abilities.UseWalletSdk
import io.iohk.atala.prism.walletsdk.domain.models.CastorError
import io.iohk.atala.prism.walletsdk.prismagent.protocols.issueCredential.IssueCredential
import io.iohk.atala.prism.walletsdk.prismagent.protocols.issueCredential.OfferCredential
import io.iohk.atala.prism.walletsdk.prismagent.protocols.outOfBand.OutOfBandInvitation
import io.iohk.atala.prism.walletsdk.prismagent.protocols.proofOfPresentation.RequestPresentation
import org.hyperledger.identus.walletsdk.abilities.UseWalletSdk
import kotlinx.coroutines.flow.first
import net.serenitybdd.screenplay.Actor
import org.hamcrest.CoreMatchers.equalTo
import org.hyperledger.identus.walletsdk.domain.models.CastorError
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.IssueCredential
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.OfferCredential
import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.OutOfBandInvitation
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation

class EdgeAgentWorkflow {
private val logger = Logger.get<EdgeAgentWorkflow>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MEDIATOR_OOB_URL=
PRISM_AGENT_URL=
AGENT_URL=
PUBLISHED_DID=
JWT_SCHEMA_ID=
ANONCRED_SCHEMA_ID=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@connection
Feature: Create connection
The Edge Agent should be able to create a connection to prism-agent
The Edge Agent should be able to create a connection to Cloud Agent

Scenario Outline: Create connection
Given Cloud Agent has a connection invitation with '<label>', '<goalCode>' and '<goal>' parameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@credential @jwt @blap
@credential @jwt
Feature: Receive verifiable credential
The Edge Agent should be able to receive a verifiable credential from Cloud Agent

Expand All @@ -9,4 +9,19 @@ Feature: Receive verifiable credential
When Edge Agent accepts the credential
And Cloud Agent should see the credential was accepted
Then Edge Agent wait to receive 1 issued credentials
And Edge Agent process 1 issued credentials
And Edge Agent process 1 issued credentials
And Edge Agent should have 1 credentials

Scenario: Receive multiple verifiable credentials sequentially
Given Cloud Agent is connected to Edge Agent
When Edge Agent accepts 3 credential offer sequentially from Cloud Agent
Then Cloud Agent should see all credentials were accepted
And Edge Agent wait to receive 3 issued credentials
And Edge Agent process 3 issued credentials

Scenario: Receive multiple verifiable credentials at once
Given Cloud Agent is connected to Edge Agent
When Edge Agent accepts 3 credentials offer at once from Cloud Agent
Then Cloud Agent should see all credentials were accepted
And Edge Agent wait to receive 3 issued credentials
And Edge Agent process 3 issued credentials

0 comments on commit be54220

Please sign in to comment.