Skip to content

Commit

Permalink
style: apply linters automatic fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Hyperledger Bot <hyperledger-bot@hyperledger.org>
  • Loading branch information
hyperledger-bot committed May 7, 2024
1 parent 8684124 commit 2290a7c
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 64 deletions.
67 changes: 48 additions & 19 deletions tests/integration-tests/src/test/kotlin/models/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,60 @@ data class PresentationEvent(
)

data class PresentationStatusAdapter( // FIXME: delete this class when PresentationStatus.Status is fixed
@SerializedName("presentationId") val presentationId: String,
@SerializedName("thid") val thid: String,
@SerializedName("presentationId") val presentationId: String,
@SerializedName("thid") val thid: String,
@SerializedName("role") val role: PresentationStatus.Role,
@SerializedName("status") val status: Status,
@SerializedName("status") val status: Status,
@SerializedName("metaRetries") val metaRetries: Int,
@SerializedName("proofs") val proofs: List<ProofRequestAux>? = null,
@SerializedName("data") val `data`: List<String>? = null,
@SerializedName("connectionId") val connectionId: String? = null
@SerializedName("connectionId") val connectionId: String? = null,
) {
enum class Status(val value: String) {
@SerializedName(value = "RequestPending") REQUEST_PENDING("RequestPending"),
@SerializedName(value = "RequestSent") REQUEST_SENT("RequestSent"),
@SerializedName(value = "RequestReceived") REQUEST_RECEIVED("RequestReceived"),
@SerializedName(value = "RequestRejected") REQUEST_REJECTED("RequestRejected"),
@SerializedName(value = "PresentationPending") PRESENTATION_PENDING("PresentationPending"),
@SerializedName(value = "PresentationGenerated") PRESENTATION_GENERATED("PresentationGenerated"),
@SerializedName(value = "PresentationSent") PRESENTATION_SENT("PresentationSent"),
@SerializedName(value = "PresentationReceived") PRESENTATION_RECEIVED("PresentationReceived"),
@SerializedName(value = "PresentationVerified") PRESENTATION_VERIFIED("PresentationVerified"),
@SerializedName(value = "PresentationAccepted") PRESENTATION_ACCEPTED("PresentationAccepted"),
@SerializedName(value = "PresentationRejected") PRESENTATION_REJECTED("PresentationRejected"),
@SerializedName(value = "ProblemReportPending") PROBLEM_REPORT_PENDING("ProblemReportPending"),
@SerializedName(value = "ProblemReportSent") PROBLEM_REPORT_SENT("ProblemReportSent"),
@SerializedName(value = "ProblemReportReceived") PROBLEM_REPORT_RECEIVED("ProblemReportReceived"),
@SerializedName(value = "PresentationVerificationFailed") PRESENTATION_VERIFICATION_FAILED("PresentationVerificationFailed");
@SerializedName(value = "RequestPending")
REQUEST_PENDING("RequestPending"),

@SerializedName(value = "RequestSent")
REQUEST_SENT("RequestSent"),

@SerializedName(value = "RequestReceived")
REQUEST_RECEIVED("RequestReceived"),

@SerializedName(value = "RequestRejected")
REQUEST_REJECTED("RequestRejected"),

@SerializedName(value = "PresentationPending")
PRESENTATION_PENDING("PresentationPending"),

@SerializedName(value = "PresentationGenerated")
PRESENTATION_GENERATED("PresentationGenerated"),

@SerializedName(value = "PresentationSent")
PRESENTATION_SENT("PresentationSent"),

@SerializedName(value = "PresentationReceived")
PRESENTATION_RECEIVED("PresentationReceived"),

@SerializedName(value = "PresentationVerified")
PRESENTATION_VERIFIED("PresentationVerified"),

@SerializedName(value = "PresentationAccepted")
PRESENTATION_ACCEPTED("PresentationAccepted"),

@SerializedName(value = "PresentationRejected")
PRESENTATION_REJECTED("PresentationRejected"),

@SerializedName(value = "ProblemReportPending")
PROBLEM_REPORT_PENDING("ProblemReportPending"),

@SerializedName(value = "ProblemReportSent")
PROBLEM_REPORT_SENT("ProblemReportSent"),

@SerializedName(value = "ProblemReportReceived")
PROBLEM_REPORT_RECEIVED("ProblemReportReceived"),

@SerializedName(value = "PresentationVerificationFailed")
PRESENTATION_VERIFICATION_FAILED("PresentationVerificationFailed"),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.jayway.jsonpath.DocumentContext
import com.jayway.jsonpath.JsonPath
import java.util.Base64


class JwtCredential(base64: String) {
private val payload: DocumentContext

Expand All @@ -18,5 +17,4 @@ class JwtCredential(base64: String) {
val listUrl = payload.read<String>("$.vc.credentialStatus.statusListCredential")
return listUrl.split("/credential-status/")[1]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import net.serenitybdd.screenplay.actors.OnStage
import org.apache.http.HttpStatus
import org.hyperledger.identus.client.models.Connection
import org.hyperledger.identus.client.models.ConnectionsPage
import org.hyperledger.identus.client.models.IssueCredentialRecord
import org.hyperledger.identus.client.models.IssueCredentialRecordPage
import steps.connection.ConnectionSteps
import steps.credentials.IssueCredentialsSteps
import steps.did.PublishDidSteps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ConnectionSteps {
@When("{actor} receives the connection request and sends back the response")
fun inviterReceivesTheConnectionRequest(inviter: Actor) {
Wait.until(
errorMessage = "Inviter connection didn't reach ${Connection.State.CONNECTION_RESPONSE_SENT} state"
errorMessage = "Inviter connection didn't reach ${Connection.State.CONNECTION_RESPONSE_SENT} state",
) {
val lastEvent = ListenToEvents.with(inviter).connectionEvents.lastOrNull {
it.data.thid == inviter.recall<Connection>("connection").thid
Expand All @@ -89,13 +89,13 @@ class ConnectionSteps {
@When("{actor} receives the connection response")
fun inviteeReceivesTheConnectionResponse(invitee: Actor) {
Wait.until(
errorMessage = "Invitee connection didn't reach ${Connection.State.CONNECTION_RESPONSE_RECEIVED} state."
errorMessage = "Invitee connection didn't reach ${Connection.State.CONNECTION_RESPONSE_RECEIVED} state.",
) {
val lastEvent = ListenToEvents.with(invitee).connectionEvents.lastOrNull {
it.data.thid == invitee.recall<Connection>("connection").thid
}
lastEvent != null &&
lastEvent.data.state == Connection.State.CONNECTION_RESPONSE_RECEIVED
lastEvent.data.state == Connection.State.CONNECTION_RESPONSE_RECEIVED
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ class IssueCredentialsSteps {
fun holderReceivesCredentialOffer(holder: Actor) {
Wait.until(
errorMessage = "Holder was unable to receive the credential offer from Issuer! " +
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.OFFER_RECEIVED} state.",
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.OFFER_RECEIVED} state.",
) {
credentialEvent = ListenToEvents.with(holder).credentialEvents.lastOrNull {
it.data.thid == holder.recall<String>("thid")
}
credentialEvent != null &&
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.OFFER_RECEIVED
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.OFFER_RECEIVED
}

val recordId = ListenToEvents.with(holder).credentialEvents.last().data.recordId
Expand Down Expand Up @@ -191,13 +191,13 @@ class IssueCredentialsSteps {
@When("{actor} issues the credential")
fun acmeIssuesTheCredential(issuer: Actor) {
Wait.until(
errorMessage = "Issuer was unable to receive the credential request from Holder! Protocol state did not achieve RequestReceived state."
errorMessage = "Issuer was unable to receive the credential request from Holder! Protocol state did not achieve RequestReceived state.",
) {
credentialEvent = ListenToEvents.with(issuer).credentialEvents.lastOrNull {
it.data.thid == issuer.recall<String>("thid")
}
credentialEvent != null &&
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.REQUEST_RECEIVED
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.REQUEST_RECEIVED
}
val recordId = credentialEvent!!.data.recordId
issuer.attemptsTo(
Expand All @@ -209,28 +209,28 @@ class IssueCredentialsSteps {

Wait.until(
errorMessage = "Issuer was unable to issue the credential! " +
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT} state."
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT} state.",
) {
credentialEvent = ListenToEvents.with(issuer).credentialEvents.lastOrNull {
it.data.thid == issuer.recall<String>("thid")
}
issuer.remember("issuedCredential", credentialEvent!!.data)
credentialEvent != null &&
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT
}
}

@Then("{actor} receives the issued credential")
fun bobHasTheCredentialIssued(holder: Actor) {
Wait.until(
errorMessage = "Holder was unable to receive the credential from Issuer! " +
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED} state."
"Protocol state did not achieve ${IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED} state.",
) {
credentialEvent = ListenToEvents.with(holder).credentialEvents.lastOrNull {
it.data.thid == holder.recall<String>("thid")
}
credentialEvent != null &&
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED
credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED
}
holder.remember("issuedCredential", ListenToEvents.with(holder).credentialEvents.last().data)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class RevokeCredentialSteps {
issuer.remember("statusListId", statusListId)

issuer.attemptsTo(
Get.resource("/credential-status/${statusListId}")
Get.resource("/credential-status/$statusListId"),
)
val encodedList = SerenityRest.lastResponse().get<String>("credentialSubject.encodedList")
issuer.remember("encodedStatusList", encodedList)

issuer.attemptsTo(
Patch.to("/credential-status/revoke-credential/${issuedCredential.recordId}"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK)
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_OK),
)
}

Expand All @@ -39,24 +39,24 @@ class RevokeCredentialSteps {
val receivedCredential = holder.recall<IssueCredentialRecord>("issuedCredential")
holder.attemptsTo(
Patch.to("/credential-status/revoke-credential/${issuedCredential.recordId}"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_NOT_FOUND)
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_NOT_FOUND),
)
holder.attemptsTo(
Patch.to("/credential-status/revoke-credential/${receivedCredential.recordId}"),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_NOT_FOUND)
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_NOT_FOUND),
)
}

@Then("{actor} should see the credential was revoked")
fun credentialShouldBeRevoked(issuer: Actor) {
Wait.until(
timeout = 60.seconds,
errorMessage = "Encoded Status List didn't change after revoking."
errorMessage = "Encoded Status List didn't change after revoking.",
) {
val statusListId: String = issuer.recall("statusListId")
val encodedStatusList: String = issuer.recall("encodedStatusList")
issuer.attemptsTo(
Get.resource("/credential-status/$statusListId")
Get.resource("/credential-status/$statusListId"),
)
val actualEncodedList: String = SerenityRest.lastResponse().jsonPath().get("credentialSubject.encodedList")
println("actual encoded $actualEncodedList | before encoded $encodedStatusList")
Expand All @@ -72,7 +72,7 @@ class RevokeCredentialSteps {
issuer.remember("statusListId", statusListId)

issuer.attemptsTo(
Get.resource("/credential-status/${statusListId}")
Get.resource("/credential-status/$statusListId"),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class DeactivateDidSteps {
val deactivatedDid = actor.forget<String>("shortFormDid")
actor.forget<String>("longFormDid")
actor.remember("deactivatedDid", deactivatedDid)

}

@Then("{actor} sees that PRISM DID is successfully deactivated")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class PublishDidSteps {

Wait.until(
timeout = 30.seconds,
errorMessage = "ERROR: DID was not published to ledger!"
errorMessage = "ERROR: DID was not published to ledger!",
) {
val didEvent = ListenToEvents.with(actor).didEvents.lastOrNull {
it.data.did == actor.recall<String>("shortFormDid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class UpdateDidSteps {
@Then("{actor} sees PRISM DID was successfully updated with new keys")
fun actorSeesDidSuccessfullyUpdatedWithNewKeys(actor: Actor) {
Wait.until(
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!"
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!",
) {
actor.attemptsTo(
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
Expand All @@ -109,7 +109,7 @@ class UpdateDidSteps {
@Then("{actor} sees PRISM DID was successfully updated and keys removed")
fun actorSeesDidSuccessfullyUpdatedAndKeysRemoved(actor: Actor) {
Wait.until(
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!"
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!",
) {
actor.attemptsTo(
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
Expand All @@ -128,7 +128,7 @@ class UpdateDidSteps {
@Then("{actor} sees PRISM DID was successfully updated with new services")
fun actorSeesDidSuccessfullyUpdatedWithNewServices(actor: Actor) {
Wait.until(
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!"
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!",
) {
actor.attemptsTo(
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
Expand All @@ -144,7 +144,7 @@ class UpdateDidSteps {
@Then("{actor} sees PRISM DID was successfully updated by removing services")
fun actorSeesDidSuccessfullyUpdatedByRemovingServices(actor: Actor) {
Wait.until(
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!"
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!",
) {
actor.attemptsTo(
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
Expand All @@ -160,7 +160,7 @@ class UpdateDidSteps {
@Then("{actor} sees PRISM DID was successfully updated by updating services")
fun actorSeesDidSuccessfullyUpdatedByUpdatingServices(actor: Actor) {
Wait.until(
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!"
errorMessage = "ERROR: DID UPDATE operation did not succeed on the ledger!",
) {
actor.attemptsTo(
Get.resource("/dids/${actor.recall<String>("shortFormDid")}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class AnoncredsPresentProofSteps {
val anoncredsPresentationRequestV1 = AnoncredPresentationRequestV1(
requestedAttributes = mapOf(
"sex" to
AnoncredRequestedAttributeV1(
name = "sex",
restrictions = listOf(
mapOf(
("attr::sex::value" to "M"),
("cred_def_id" to credentialDefinitionId),
),
AnoncredRequestedAttributeV1(
name = "sex",
restrictions = listOf(
mapOf(
("attr::sex::value" to "M"),
("cred_def_id" to credentialDefinitionId),
),
),
),
),
requestedPredicates = mapOf(
"age" to AnoncredRequestedPredicateV1(
Expand Down Expand Up @@ -68,7 +68,7 @@ class AnoncredsPresentProofSteps {
},
)
faber.attemptsTo(
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED)
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED),
)
val presentationStatus = SerenityRest.lastResponse().get<PresentationStatus>()
faber.remember("thid", presentationStatus.thid)
Expand All @@ -78,14 +78,13 @@ class AnoncredsPresentProofSteps {
@When("{actor} receives the anoncreds request")
fun bobReceivesTheAnoncredsRequest(bob: Actor) {
Wait.until(
errorMessage = "ERROR: Bob did not achieve any presentation request!"
)
{
errorMessage = "ERROR: Bob did not achieve any presentation request!",
) {
proofEvent = ListenToEvents.with(bob).presentationEvents.lastOrNull {
it.data.thid == bob.recall<String>("thid")
}
proofEvent != null &&
proofEvent!!.data.status == PresentationStatusAdapter.Status.REQUEST_RECEIVED
proofEvent!!.data.status == PresentationStatusAdapter.Status.REQUEST_RECEIVED
}
bob.remember("presentationId", proofEvent!!.data.presentationId)
}
Expand Down

0 comments on commit 2290a7c

Please sign in to comment.