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 test connectionless verification #1418

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package steps.connectionless

import com.google.gson.JsonObject
import interactions.Post
import interactions.body
import io.cucumber.java.en.*
Expand Down Expand Up @@ -78,4 +79,94 @@ class ConnectionLessSteps {
holder.remember("recordId", holderIssueCredentialRecord.recordId)
holder.remember("thid", holderIssueCredentialRecord.thid)
}

@When("{actor} creates a OOB Invitation request for JWT proof presentation")
fun verifierCreatesARequestForJwtProofPresentationOfferInvitation(verifier: Actor) {
val presentationRequest = RequestPresentationInput(
goalCode = "present-vp",
goal = "Request proof of vaccine",
options = Options(
challenge = "11c91493-01b3-4c4d-ac36-b336bab5bddf",
domain = "https://example-verifier.com",
),
proofs = listOf(
ProofRequestAux(
schemaId = "https://schema.org/Person",
trustIssuers = listOf("did:web:atalaprism.io/users/testUser"),
),
),
)

verifier.attemptsTo(
Post.to("/present-proof/presentations/invitation").body(presentationRequest),
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED),
)
val presentationStatus = SerenityRest.lastResponse().get<PresentationStatus>()

verifier.attemptsTo(
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED),
Ensure.that(presentationStatus.status).isEqualTo(PresentationStatus.Status.INVITATION_GENERATED),
Ensure.that(presentationStatus.role).isEqualTo(PresentationStatus.Role.VERIFIER),
)

verifier.remember("presentationStatus", presentationStatus)
verifier.remember("thid", presentationStatus.thid)
}

@And("{actor} accepts the OOB invitation request for JWT proof presentation from {actor}")
fun holderAcceptsJwtProofPresentationOfferInvitation(holder: Actor, verifier: Actor) {
val verifierPresentationStatusRecord = verifier.recall<PresentationStatus>("presentationStatus")
holder.attemptsTo(
Post.to("/present-proof/presentations/accept-invitation")
.with {
it.body(
AcceptRequestPresentationInvitation(
verifierPresentationStatusRecord.invitation?.invitationUrl?.split("=")?.getOrNull(1)
?: throw IllegalStateException("Invalid invitation URL format"),
),
)
},
)
val holderPresentationStatusRecord = SerenityRest.lastResponse().get<PresentationStatus>()

holder.attemptsTo(
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK),
Ensure.that(holderPresentationStatusRecord.status).isEqualTo(PresentationStatus.Status.REQUEST_RECEIVED),
Ensure.that(holderPresentationStatusRecord.role).isEqualTo(PresentationStatus.Role.PROVER),
)
holder.remember("recordId", holderPresentationStatusRecord.presentationId)
holder.remember("thid", holderPresentationStatusRecord.thid)
}

@When("{actor} creates a OOB Invitation request for sd-jwt proof presentation requesting [{}] claims")
fun verifierCreatesARequestForSdJwtProofPresentationInvitation(verifier: Actor, keys: String) {
val claims = JsonObject()
for (key in keys.split(",")) {
claims.addProperty(key, "{}")
}
val presentationRequest = RequestPresentationInput(
options = Options(
challenge = "11c91493-01b3-4c4d-ac36-b336bab5bddf",
domain = "https://example-verifier.com",
),
proofs = listOf(),
credentialFormat = "SDJWT",
claims = claims,
)

verifier.attemptsTo(
Post.to("/present-proof/presentations/invitation").body(presentationRequest),
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED),
)
val presentationStatus = SerenityRest.lastResponse().get<PresentationStatus>()

verifier.attemptsTo(
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED),
Ensure.that(presentationStatus.status).isEqualTo(PresentationStatus.Status.INVITATION_GENERATED),
Ensure.that(presentationStatus.role).isEqualTo(PresentationStatus.Role.VERIFIER),
)

verifier.remember("presentationStatus", presentationStatus)
verifier.remember("thid", presentationStatus.thid)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ Feature: Present Proof Protocol
And Holder rejects the proof
Then Holder sees the proof is rejected

Scenario: Connectionless Verification Holder presents jwt credential proof to verifier
Given Holder has a jwt issued credential from Issuer
When Verifier creates a OOB Invitation request for JWT proof presentation
And Holder accepts the OOB invitation request for JWT proof presentation from Verifier
And Holder receives the presentation proof request
And Holder makes the jwt presentation of the proof
Then Verifier has the proof verified
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Feature: Present SD-JWT Proof Protocol
| Verifier |
| Issuer |

Scenario Outline: Holder presents sd-jwt proof to <verifier>
Given Holder has a sd-jwt issued credential from Issuer
When <verifier> creates a OOB Invitation request for sd-jwt proof presentation requesting [firstName] claims
And Holder accepts the OOB invitation request for JWT proof presentation from <verifier>
And Holder receives the presentation proof request
And Holder makes the sd-jwt presentation of the proof disclosing [firstName] claims
Then <verifier> has the proof verified
Examples:
| verifier |
| Verifier |
| Issuer |

# Scenario: Holder presents sd-jwt proof with different claims from requested
# Given Verifier and Holder have an existing connection
# And Holder has a bound sd-jwt issued credential from Issuer
Expand Down
Loading