diff --git a/tests/e2e-tests/src/test/kotlin/features/present_proof/PresentProofSteps.kt b/tests/e2e-tests/src/test/kotlin/features/present_proof/PresentProofSteps.kt index 53af7272d3..2347bbf3d6 100644 --- a/tests/e2e-tests/src/test/kotlin/features/present_proof/PresentProofSteps.kt +++ b/tests/e2e-tests/src/test/kotlin/features/present_proof/PresentProofSteps.kt @@ -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( @@ -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("presentationId")}").with { it.body( """ { "action": "request-accept", "proofId": ["${bob.recall("issuedCredential").recordId}"] } @@ -85,23 +90,47 @@ class PresentProofSteps { ) } + @When("{actor} rejects the proof") + fun bobRejectsProof(bob: Actor) { + bob.attemptsTo( + Patch.to("/present-proof/presentations/${bob.recall("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("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("presentationId")}"), ) faber.should( - ResponseConsequence.seeThatResponse("Get presentations") { + ResponseConsequence.seeThatResponse { it.statusCode(SC_OK) }, ) - val presentation = lastResponseList("contents", PresentationProof::class).find { - it.presentationId == faber.recall("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!", ) @@ -112,17 +141,14 @@ class PresentProofSteps { wait( { faber.attemptsTo( - Get.resource("/present-proof/presentations"), + Get.resource("/present-proof/presentations/${faber.recall("presentationId")}"), ) faber.should( - ResponseConsequence.seeThatResponse("Get presentations") { + ResponseConsequence.seeThatResponse { it.statusCode(SC_OK) }, ) - val presentation = lastResponseList("contents", PresentationProof::class).find { - it.presentationId == faber.recall("presentationId") - } - presentation != null && presentation.status == "PresentationVerified" + lastResponseObject("", PresentationProof::class).status == "PresentationVerified" }, "ERROR: presentation did not achieve PresentationVerified state!", ) diff --git a/tests/e2e-tests/src/test/resources/features/present_proof/present_proof.feature b/tests/e2e-tests/src/test/resources/features/present_proof/present_proof.feature index 39934b05f3..973d3ea708 100644 --- a/tests/e2e-tests/src/test/resources/features/present_proof/present_proof.feature +++ b/tests/e2e-tests/src/test/resources/features/present_proof/present_proof.feature @@ -1,4 +1,3 @@ -@AIP20 @RFC0037 Feature: Present Proof Protocol @TEST_ATL-3850 @@ -6,6 +5,16 @@ 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