Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add connectionless end-to-end tests #342

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions integration-tests/e2e-tests/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MEDIATOR_OOB_URL=
AGENT_URL=
APIKEY=
MEDIATOR_OOB_URL=https://mediator.mydomain.com/invitationOOB
AGENT_URL=https://issuer.mydomain.com/cloud-agent/
APIKEY=myDomainAPIKey
PUBLISHED_DID=
JWT_SCHEMA_GUID=
ANONCRED_DEFINITION_GUID=
16 changes: 8 additions & 8 deletions integration-tests/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ This guide shows you how to run the end-to-end tests
- Copy `.env.example` to `.env`
- Fill the required properties

| Property | Description |
| ------------------------ | ----------------------------------------------------------- |
| MEDIATOR_OOB_URL | URL that returns the OOB url |
| AGENT_URL | URL for Cloud Agent - should end with a forward slash ("/") |
| APIKEY | (Optional) Apikey authentication |
| PUBLISHED_DID | (Optional) Existing DID |
| JWT_SCHEMA_GUID | (Optional) Existing jwt schema guid |
| ANONCRED_DEFINITION_GUID | (Optional) Existing anoncred definition guid |
| Property | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------------------|
| MEDIATOR_OOB_URL | URL that returns the OOB url (e.g. https://mediator.mydomain.com/invitationOOB) |
| AGENT_URL | URL for Cloud Agent - should end with a forward slash ("/") (e.g. https://issuer.mydomain.com/cloud-agent/) |
| APIKEY | (Optional) Apikey authentication |
| PUBLISHED_DID | (Optional) Existing DID |
| JWT_SCHEMA_GUID | (Optional) Existing jwt schema guid |
| ANONCRED_DEFINITION_GUID | (Optional) Existing anoncred definition guid |

### Compile the SDK

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@connectionless
Feature: connectionless
The Edge Agent should receive and present a credential connectionless

Scenario: Receive and verify a credential (connectionless)
Given Cloud Agent is not connected to Edge Agent
When Cloud Agent has a connectionless credential offer invitation
And Cloud Agent shares invitation to Edge Agent
Then Edge Agent accepts the connectionless credential offer invitation
And Edge Agent should receive the connectionless credential offer
Then Edge Agent accepts the connectionless credential offer
And Edge Agent should receive the connectionless credential
Then Edge Agent processes the issued connectionless credential from Cloud Agent
When Cloud Agent has a connectionless presentation invitation
And Cloud Agent shares invitation to Edge Agent
Then Edge Agent accepts the connectionless presentation invitation
And Edge Agent should receive the connectionless presentation request
When Edge Agent sends the present-proof
Then Cloud Agent should see the present-proof is verified
2 changes: 1 addition & 1 deletion integration-tests/e2e-tests/src/abilities/WalletSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class MessageQueue {
} else if (piUri === SDK.ProtocolType.DidcommPresentation) {
this.presentationMessagesStack.push(message)
} else {
console.log(piUri)
console.warn('Unhandled messaged with piuri', piUri)
}
} else {
clearInterval(this.processingId!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export class CloudAgentConfiguration {
try {
assert(this.anoncredDefinitionGuid != null)
assert(this.anoncredDefinitionGuid != "")

await axiosInstance.get(
`credential-definition-registry/definitions/${this.anoncredDefinitionGuid}`
)
Expand Down
16 changes: 15 additions & 1 deletion integration-tests/e2e-tests/src/steps/CloudAgentSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Given("{actor} has a connection invitation with '{}', '{}' and '{}' parameters",
const goalCode = rawGoalCode == "null" ? undefined : rawGoalCode
const goal = rawGoal == "null" ? undefined : rawGoal
await CloudAgentWorkflow.createConnection(cloudAgent, label, goalCode, goal)
})
}
)

Given("{actor} is connected to {actor}", async function (cloudAgent: Actor, edgeAgent: Actor) {
await CloudAgentWorkflow.createConnection(cloudAgent)
Expand Down Expand Up @@ -92,9 +93,22 @@ Then("{actor} should see the present-proof is not verified", async (cloudAgent:
await CloudAgentWorkflow.verifyPresentProof(cloudAgent, "PresentationFailed")
})


Then("{actor} should see all credentials were accepted", async (cloudAgent: Actor) => {
const recordIdList = await cloudAgent.answer<string[]>(Notepad.notes().get("recordIdList"))
for (const recordId of recordIdList) {
await CloudAgentWorkflow.verifyCredentialState(cloudAgent, recordId, "CredentialSent")
}
})

Given("{actor} is not connected to Edge Agent", async function (cloudAgent: Actor) {
await CloudAgentWorkflow.verifyNoConnection(cloudAgent)
})

Given("{actor} has a connectionless credential offer invitation", async function (cloudAgent: Actor) {
await CloudAgentWorkflow.createConnectionlessCredentialOfferInvitation(cloudAgent)
})

Given("{actor} has a connectionless presentation invitation", async function (cloudAgent: Actor) {
await CloudAgentWorkflow.createConnectionlessPresentationInvitation(cloudAgent)
})
51 changes: 51 additions & 0 deletions integration-tests/e2e-tests/src/steps/EdgeAgentSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,54 @@ Then("{actor} should see the verification proof is verified false", async (edgeA
await EdgeAgentWorkflow.waitForPresentationMessage(edgeAgent)
await EdgeAgentWorkflow.verifyPresentation(edgeAgent, false)
})


When("{actor} accepts the connectionless credential offer invitation",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.acceptCredentialOfferInvitation(edgeAgent)
}
)

When("{actor} accepts the connectionless presentation invitation",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.acceptPresentationInvitation(edgeAgent)
}
)

Then("{actor} should receive the connectionless credential offer",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.waitForCredentialOffer(edgeAgent, 1)
}
)

Then("{actor} should receive the connectionless presentation request",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.waitForProofRequest(edgeAgent)
}
)

When("{actor} accepts the connectionless credential offer",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.acceptCredential(edgeAgent)
}
)


Then("{actor} should receive the connectionless credential",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.waitToReceiveCredentialIssuance(edgeAgent, 1)
}
)

Then("{actor} processes the issued connectionless credential from {actor}",
async function (edgeAgent: Actor, cloudAgent: Actor) {
const recordId = await cloudAgent.answer<string>(Notepad.notes().get("recordId"))
await EdgeAgentWorkflow.processIssuedCredential(edgeAgent, recordId)
}
)

Then("{actor} should receive the verification proof",
async function (edgeAgent: Actor) {
await EdgeAgentWorkflow.waitForPresentationMessage(edgeAgent, 1)
}
)
74 changes: 74 additions & 0 deletions integration-tests/e2e-tests/src/workflow/CloudAgentWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export class CloudAgentWorkflow {
)
}

static async verifyNoConnection(cloudAgent: Actor) {
const connectionId = await cloudAgent.answer(
Notepad.notes().get("connectionId")
).catch(() => null)

await cloudAgent.attemptsTo(
Ensure.that(connectionId, equals(null))
)
}

static async verifyCredentialState(cloudAgent: Actor, recordId: string, state: string) {
await cloudAgent.attemptsTo(
Wait.upTo(Duration.ofSeconds(60)).until(
Expand All @@ -75,6 +85,70 @@ export class CloudAgentWorkflow {
)
}

static async createConnectionlessCredentialOfferInvitation(cloudAgent: Actor) {
const credentialOffer = {
claims: {
emailAddress: "sampleEmail",
familyName: "",
dateOfIssuance: "2023-01-01T02:02:02Z",
drivingLicenseID: "",
drivingClass: 1,
},
goalCode: "issue-vc",
goal: "Request issuance",
credentialFormat: "JWT",
issuingDID: CloudAgentConfiguration.publishedDid,
automaticIssuance: true
}

await cloudAgent.attemptsTo(
Send.a(PostRequest.to("issue-credentials/credential-offers/invitation").with(credentialOffer)),
Ensure.that(LastResponse.status(), equals(HttpStatusCode.Created)),
Notepad.notes().set(
"invitation",
LastResponse.body().invitation.invitationUrl
),
Notepad.notes().set(
"recordId",
LastResponse.body().recordId
)
)
}

static async createConnectionlessPresentationInvitation(cloudAgent: Actor) {
const proof = new ProofRequestAux()
proof.schemaId = "https://schema.org/Person"
proof.trustIssuers = [CloudAgentConfiguration.publishedDid]

const presentProofRequest = {
options: {
challenge: randomUUID(), // random seed prover has to sign to prevent replay attacks
domain: CloudAgentConfiguration.agentUrl
},
goalCode: 'present-vp',
goal: 'Request presentation',
credentialFormat: 'JWT',
proofs: [
proof
]
}

await cloudAgent.attemptsTo(
Send.a(PostRequest.to("present-proof/presentations/invitation").with(presentProofRequest)),
Ensure.that(LastResponse.status(), equals(HttpStatusCode.Created)),
Notepad.notes().set(
"invitation",
LastResponse.body().invitation.invitationUrl
),
Notepad.notes().set(
"presentationId",
LastResponse.body().presentationId
)
)
}



static async offerCredential(cloudAgent: Actor) {
const credential = new CreateIssueCredentialRecordRequest()
credential.claims = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class EdgeAgentWorkflow {
)
}

static acceptCredentialOfferInvitation = this.connect
static acceptPresentationInvitation = this.connect

static async waitForCredentialOffer(edgeAgent: Actor, numberOfCredentialOffer: number) {
await edgeAgent.attemptsTo(
Wait.upTo(Duration.ofSeconds(60)).until(
Expand Down Expand Up @@ -154,9 +157,11 @@ export class EdgeAgentWorkflow {
WalletSdk.execute(async (sdk, messages) => {
const credentials = await sdk.verifiableCredentials()
const credential = credentials[0]

const requestPresentationMessage = RequestPresentation.fromMessage(
messages.proofRequestStack.shift()!,
)

const presentation = await sdk.createPresentationForRequestProof(
requestPresentationMessage,
credential,
Expand All @@ -166,8 +171,7 @@ export class EdgeAgentWorkflow {
} catch (e) {
//
}
}
)
})
)
}

Expand Down
Loading