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

tests: add present-proof rejection scenario #451

Merged
merged 1 commit into from
Mar 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class PresentProofSteps {
faber.remember("presentationId", lastResponseObject("", PresentationProof::class).presentationId)
}

@When("{actor} makes the presentation of the proof to {actor}")
fun bobMakesThePresentationOfTheProof(bob: Actor, faber: Actor) {
@When("{actor} receives the request")
fun bobReceivesTheRequest(bob: Actor) {
wait(
{
bob.attemptsTo(
Expand All @@ -74,8 +74,13 @@ class PresentProofSteps {
val presentationId = lastResponseList("contents", PresentationProof::class).findLast {
it.status == "RequestReceived"
}!!.presentationId
bob.remember("presentationId", presentationId)
}

@When("{actor} makes the presentation of the proof to {actor}")
fun bobMakesThePresentationOfTheProof(bob: Actor, faber: Actor) {
bob.attemptsTo(
Patch.to("/present-proof/presentations/$presentationId").with {
Patch.to("/present-proof/presentations/${bob.recall<String>("presentationId")}").with {
it.body(
"""
{ "action": "request-accept", "proofId": ["${bob.recall<Credential>("issuedCredential").recordId}"] }
Expand All @@ -85,23 +90,47 @@ class PresentProofSteps {
)
}

@When("{actor} rejects the proof")
fun bobRejectsProof(bob: Actor) {
bob.attemptsTo(
Patch.to("/present-proof/presentations/${bob.recall<String>("presentationId")}").with {
it.body("""{ "action": "request-reject" }""")
},
)
}

@Then("{actor} sees the proof is rejected")
fun bobSeesProofIsRejected(actor: Actor) {
wait(
{
actor.attemptsTo(
Get.resource("/present-proof/presentations/${actor.recall<String>("presentationId")}"),
)
actor.should(
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
},
)
lastResponseObject("", PresentationProof::class).status == "RequestRejected"
},
"ERROR: Faber did not receive presentation from Bob!",
)
}

@When("{actor} acknowledges the proof")
fun faberAcknowledgesTheProof(faber: Actor) {
wait(
{
faber.attemptsTo(
Get.resource("/present-proof/presentations"),
Get.resource("/present-proof/presentations/${faber.recall<String>("presentationId")}"),
)
faber.should(
ResponseConsequence.seeThatResponse("Get presentations") {
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
},
)
val presentation = lastResponseList("contents", PresentationProof::class).find {
it.presentationId == faber.recall<String>("presentationId")
}
presentation != null &&
(presentation.status == "PresentationReceived" || presentation.status == "PresentationVerified")
lastResponseObject("", PresentationProof::class).status == "PresentationReceived" ||
lastResponseObject("", PresentationProof::class).status == "PresentationVerified"
},
"ERROR: Faber did not receive presentation from Bob!",
)
Expand All @@ -112,17 +141,14 @@ class PresentProofSteps {
wait(
{
faber.attemptsTo(
Get.resource("/present-proof/presentations"),
Get.resource("/present-proof/presentations/${faber.recall<String>("presentationId")}"),
)
faber.should(
ResponseConsequence.seeThatResponse("Get presentations") {
ResponseConsequence.seeThatResponse {
it.statusCode(SC_OK)
},
)
val presentation = lastResponseList("contents", PresentationProof::class).find {
it.presentationId == faber.recall<String>("presentationId")
}
presentation != null && presentation.status == "PresentationVerified"
lastResponseObject("", PresentationProof::class).status == "PresentationVerified"
},
"ERROR: presentation did not achieve PresentationVerified state!",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
@AIP20 @RFC0037
Feature: Present Proof Protocol

@TEST_ATL-3850
Scenario: Holder presents credential proof to verifier
Given Faber and Bob have an existing connection
And Bob has an issued credential from Acme
When Faber sends a request for proof presentation to Bob
And Bob receives the request
And Bob makes the presentation of the proof to Faber
And Faber acknowledges the proof
Then Faber has the proof verified

@TEST_ATL-3881
Scenario: Verifier rejects holder proof
Given Faber and Bob have an existing connection
And Bob has an issued credential from Acme
When Faber sends a request for proof presentation to Bob
And Bob receives the request
And Bob rejects the proof
Then Bob sees the proof is rejected