Skip to content

Commit

Permalink
test: partial
Browse files Browse the repository at this point in the history
Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
  • Loading branch information
amagyar-iohk committed Mar 27, 2024
1 parent 9a38cc9 commit bffec03
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/integration-tests/README.md
Expand Up @@ -46,9 +46,9 @@ The project structure is represented below:
│ ├── abilities -> contains the abilities of the actors
│ ├── common -> contains the common classes (test constants and helper functions)
│ ├── config -> contains the configuration classes (Hoplite)
│ ├── features -> contains the features implementation steps
│ ├── interactions -> contains the interactions of the actors
│ └── runners -> contains the test runners to execute the tests
│ ├── models -> contains the models
│ ├── steps -> contains the features implementation steps
└── resources -> contains the test resources
├── configs -> contains the test configuration files
├── containers -> contains the Docker Compose files to start the test environment
Expand Down
24 changes: 24 additions & 0 deletions tests/integration-tests/src/test/kotlin/models/JwtCredential.kt
@@ -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")
}
}
@@ -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
}
}
}
@@ -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

0 comments on commit bffec03

Please sign in to comment.