Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
- Loading branch information
1 parent
9a38cc9
commit bffec03
Showing
4 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/integration-tests/src/test/kotlin/models/JwtCredential.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package models | ||
|
||
import com.jayway.jsonpath.DocumentContext | ||
import com.jayway.jsonpath.JsonPath | ||
import java.util.Base64 | ||
|
||
|
||
class JwtCredential(base64: String) { | ||
private val payload: DocumentContext | ||
|
||
init { | ||
val jwt = String(Base64.getDecoder().decode(base64)) | ||
val parts = jwt.split(".") | ||
payload = JsonPath.parse(String(Base64.getUrlDecoder().decode(parts[1]))) | ||
} | ||
|
||
fun getList() { | ||
println(payload.jsonString()) | ||
} | ||
|
||
fun statusListCredential(): String { | ||
return payload.read("$.vc.credentialStatus.statusListCredential") | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
tests/integration-tests/src/test/kotlin/steps/credentials/RevokeCredentialSteps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package steps.credentials | ||
|
||
import interactions.* | ||
import io.cucumber.java.en.Given | ||
import io.cucumber.java.en.Then | ||
import io.cucumber.java.en.When | ||
import io.iohk.atala.automation.extensions.get | ||
import io.iohk.atala.automation.utils.Wait | ||
import io.iohk.atala.prism.models.IssueCredentialRecord | ||
import io.restassured.RestAssured | ||
import models.JwtCredential | ||
import net.serenitybdd.rest.SerenityRest | ||
import net.serenitybdd.screenplay.Actor | ||
import steps.common.CommonSteps | ||
import steps.did.PublishDidSteps | ||
|
||
class RevokeCredentialSteps { | ||
|
||
@Given("{actor} has issued a revocable credential to {actor}") | ||
fun issuerHasIssuedARevocableCredentialToHolder(issuer: Actor, holder: Actor) { | ||
CommonSteps().holderHasIssuedCredentialFromIssuer(holder, issuer) | ||
val credential = holder.forget<IssueCredentialRecord>("issuedCredential") | ||
holder.remember("revocableCredential", credential) | ||
} | ||
|
||
@When("{actor} revokes the credential from {actor}") | ||
fun revokesCredential(issuer: Actor, holder: Actor) { | ||
val revocableCredential = holder.recall<IssueCredentialRecord>("revocableCredential") | ||
val jwtCred = JwtCredential(revocableCredential.credential!!) | ||
val statusListUrl = jwtCred.statusListCredential() | ||
issuer.remember("statusList", statusListUrl) | ||
|
||
val statusList = RestAssured.get(statusListUrl).thenReturn().jsonPath() | ||
val encodedList = statusList.get<String>("credentialSubject.encodedList") | ||
issuer.remember("statusListBit", encodedList) | ||
|
||
|
||
// issuer.attemptsTo( | ||
// Patch.to("/credential-status/revoke-credential/$recordId") | ||
// ) | ||
// SerenityRest.lastResponse().prettyPrint() | ||
|
||
} | ||
|
||
@Then("{actor} should see the credential was revoked") | ||
fun credentialShouldBeRevoked(issuer: Actor) { | ||
Wait.until { | ||
val recordId = issuer.recall<String>("revokeRecordId") | ||
val encodedList = issuer.recall<String>("statusEncodedList") | ||
|
||
issuer.attemptsTo( | ||
Get.resource("/credential-status/$recordId") | ||
) | ||
SerenityRest.lastResponse().prettyPrint() | ||
|
||
val actualEncodedList = SerenityRest.lastResponse().jsonPath().get<String>("credentialSubject.encodedList") | ||
|
||
actualEncodedList == encodedList | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/integration-tests/src/test/resources/features/revocation/jwt.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@revocation @jwt | ||
Feature: Credential revocation - JWT | ||
|
||
Background: | ||
Given Issuer and Holder have an existing connection | ||
And Issuer has issued a revocable credential to Holder | ||
|
||
Scenario: Revoke issued credential | ||
When Issuer revokes the credential from Holder | ||
Then Issuer should see the credential was revoked | ||
When Issuer sends a request for proof presentation to Holder | ||
And Holder receives the request | ||
And Holder makes the presentation of the proof to Issuer | ||
Then Holder sees the proof is rejected | ||
|