diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/VcVerificationEndpoints.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/VcVerificationEndpoints.scala index e32d445485..cff7629230 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/VcVerificationEndpoints.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/VcVerificationEndpoints.scala @@ -18,7 +18,7 @@ object VcVerificationEndpoints { List[http.VcVerificationResponse], Any ] = - endpoint.get + endpoint.post .tag("Verifiable Credentials Verification") .name("verify") .summary("As a Verifier, verify a set of credentials") diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationRequest.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationRequest.scala index 2fbbfa57ec..fb5b30bbfb 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationRequest.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationRequest.scala @@ -7,12 +7,14 @@ import sttp.tapir.Schema.annotations.{description, encodedExample} import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} import zio.{IO, *} +import java.time.OffsetDateTime + final case class VcVerificationRequest( @description(VcVerificationRequest.annotations.credential.description) @encodedExample(VcVerificationRequest.annotations.credential.example) credential: String, - @description(VcVerificationRequest.annotations.vcVerification.description) - @encodedExample(VcVerificationRequest.annotations.vcVerification.example) + @description(VcVerificationRequest.annotations.parameterizableVcVerifications.description) + @encodedExample(VcVerificationRequest.annotations.parameterizableVcVerifications.example) verifications: List[ParameterizableVcVerification] ) @@ -26,22 +28,28 @@ object VcVerificationRequest { "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ) - object vcVerification - extends Annotation[List[VcVerification]]( + object parameterizableVcVerifications + extends Annotation[List[ParameterizableVcVerification]]( description = "The list of Verifications to verify. All verifications run if Verifications left empty", example = List( - VcVerification.SignatureVerification, - VcVerification.IssuerIdentification, - VcVerification.ExpirationCheck, - VcVerification.NotBeforeCheck, - VcVerification.AudienceCheck, - VcVerification.SubjectVerification, - VcVerification.IntegrityOfClaims, - VcVerification.ComplianceWithStandards, - VcVerification.RevocationCheck, - VcVerification.AlgorithmVerification, - VcVerification.SchemaCheck, - VcVerification.SemanticCheckOfClaims, + ParameterizableVcVerification(VcVerification.SignatureVerification, None), + ParameterizableVcVerification(VcVerification.IssuerIdentification, Some(DidParameter("did:prism:issuer"))), + ParameterizableVcVerification( + VcVerification.ExpirationCheck, + Some(DateTimeParameter(OffsetDateTime.parse("2022-03-10T12:00:00Z"))) + ), + ParameterizableVcVerification( + VcVerification.NotBeforeCheck, + Some(DateTimeParameter(OffsetDateTime.parse("2022-03-10T12:00:00Z"))) + ), + ParameterizableVcVerification(VcVerification.AudienceCheck, Some(DidParameter("did:prism:holder"))), + ParameterizableVcVerification(VcVerification.SubjectVerification, None), + ParameterizableVcVerification(VcVerification.IntegrityOfClaims, None), + ParameterizableVcVerification(VcVerification.ComplianceWithStandards, None), + ParameterizableVcVerification(VcVerification.RevocationCheck, None), + ParameterizableVcVerification(VcVerification.AlgorithmVerification, None), + ParameterizableVcVerification(VcVerification.SchemaCheck, None), + ParameterizableVcVerification(VcVerification.SemanticCheckOfClaims, None) ) ) } diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationResponse.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationResponse.scala index 99b25d7170..f8c71f335e 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationResponse.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/verification/controller/http/VcVerificationResponse.scala @@ -9,8 +9,8 @@ final case class VcVerificationResponse( @description(VcVerificationResponse.annotations.credential.description) @encodedExample(VcVerificationResponse.annotations.credential.example) credential: String, - @description(VcVerificationResponse.annotations.checks.description) - @encodedExample(VcVerificationResponse.annotations.checks.example) + @description(VcVerificationResponse.annotations.vcVerificationResults.description) + @encodedExample(VcVerificationResponse.annotations.vcVerificationResults.example) result: List[VcVerificationResult], ) @@ -25,79 +25,22 @@ object VcVerificationResponse { "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ) - object checks - extends Annotation[List[VcVerification]]( + object vcVerificationResults + extends Annotation[List[VcVerificationResult]]( description = "The list executed Verifications", example = List( - VcVerification.SignatureVerification, - VcVerification.IssuerIdentification, - VcVerification.ExpirationCheck, - VcVerification.NotBeforeCheck, - VcVerification.AudienceCheck, - VcVerification.SubjectVerification, - VcVerification.IntegrityOfClaims, - VcVerification.ComplianceWithStandards, - VcVerification.RevocationCheck, - VcVerification.AlgorithmVerification, - VcVerification.SchemaCheck, - VcVerification.SemanticCheckOfClaims, - ) - ) - - object successfulChecks - extends Annotation[List[VcVerification]]( - description = "The list of successful Verifications", - example = List( - VcVerification.SignatureVerification, - VcVerification.IssuerIdentification, - VcVerification.ExpirationCheck, - VcVerification.NotBeforeCheck, - VcVerification.AudienceCheck, - VcVerification.SubjectVerification, - VcVerification.IntegrityOfClaims, - VcVerification.ComplianceWithStandards, - VcVerification.RevocationCheck, - VcVerification.AlgorithmVerification, - VcVerification.SchemaCheck, - VcVerification.SemanticCheckOfClaims, - ) - ) - - object failedChecks - extends Annotation[List[VcVerification]]( - description = "The list of failed Verifications.", - example = List( - VcVerification.SignatureVerification, - VcVerification.IssuerIdentification, - VcVerification.ExpirationCheck, - VcVerification.NotBeforeCheck, - VcVerification.AudienceCheck, - VcVerification.SubjectVerification, - VcVerification.IntegrityOfClaims, - VcVerification.ComplianceWithStandards, - VcVerification.RevocationCheck, - VcVerification.AlgorithmVerification, - VcVerification.SchemaCheck, - VcVerification.SemanticCheckOfClaims, - ) - ) - - object failedAsWarningChecks - extends Annotation[List[VcVerification]]( - description = "The list of failed Verifications as warning", - example = List( - VcVerification.SignatureVerification, - VcVerification.IssuerIdentification, - VcVerification.ExpirationCheck, - VcVerification.NotBeforeCheck, - VcVerification.AudienceCheck, - VcVerification.SubjectVerification, - VcVerification.IntegrityOfClaims, - VcVerification.ComplianceWithStandards, - VcVerification.RevocationCheck, - VcVerification.AlgorithmVerification, - VcVerification.SchemaCheck, - VcVerification.SemanticCheckOfClaims, + VcVerificationResult(VcVerification.SignatureVerification, true), + VcVerificationResult(VcVerification.IssuerIdentification, true), + VcVerificationResult(VcVerification.ExpirationCheck, true), + VcVerificationResult(VcVerification.NotBeforeCheck, true), + VcVerificationResult(VcVerification.AudienceCheck, true), + VcVerificationResult(VcVerification.SubjectVerification, true), + VcVerificationResult(VcVerification.IntegrityOfClaims, true), + VcVerificationResult(VcVerification.ComplianceWithStandards, true), + VcVerificationResult(VcVerification.RevocationCheck, true), + VcVerificationResult(VcVerification.AlgorithmVerification, true), + VcVerificationResult(VcVerification.SchemaCheck, true), + VcVerificationResult(VcVerification.SemanticCheckOfClaims, true), ) ) } diff --git a/cloud-agent/service/server/src/test/scala/org/hyperledger/identus/verification/controller/VcVerificationControllerImplSpec.scala b/cloud-agent/service/server/src/test/scala/org/hyperledger/identus/verification/controller/VcVerificationControllerImplSpec.scala index 1efbe9e153..1bbb9282ab 100644 --- a/cloud-agent/service/server/src/test/scala/org/hyperledger/identus/verification/controller/VcVerificationControllerImplSpec.scala +++ b/cloud-agent/service/server/src/test/scala/org/hyperledger/identus/verification/controller/VcVerificationControllerImplSpec.scala @@ -74,7 +74,7 @@ object VcVerificationControllerImplSpec extends ZIOSpecDefault with VcVerificati backend = httpBackend(vcVerificationController, authenticator) response: Response[Either[DeserializationException[String], List[VcVerificationResponse]]] <- basicRequest - .get(uri"${vcVerificationUriBase}") + .post(uri"${vcVerificationUriBase}") .body( List( VcVerificationRequest( diff --git a/tests/integration-tests/src/test/kotlin/common/CredentialSchema.kt b/tests/integration-tests/src/test/kotlin/common/CredentialSchema.kt index 926027faab..d635b71f80 100644 --- a/tests/integration-tests/src/test/kotlin/common/CredentialSchema.kt +++ b/tests/integration-tests/src/test/kotlin/common/CredentialSchema.kt @@ -19,7 +19,7 @@ enum class CredentialSchema { "name" to JsonSchemaProperty(type = "string"), "age" to JsonSchemaProperty(type = "integer"), ), - required = listOf("name", "age") + required = listOf("name", "age"), ) override val credentialSchema: CredentialSchemaInput = CredentialSchemaInput( author = "did:prism:agent", @@ -30,7 +30,7 @@ enum class CredentialSchema { tags = listOf("school", "students"), version = "1.0.0", ) - }; + }, ; abstract val credentialSchema: CredentialSchemaInput abstract val schema: JsonSchema diff --git a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt index 91b028d64c..9c3b1901f1 100644 --- a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt +++ b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt @@ -1,10 +1,7 @@ package common import io.iohk.atala.prism.models.* -import models.JsonSchema -import models.JsonSchemaProperty import java.time.Duration -import java.util.UUID object TestConstants { val TESTS_CONFIG = System.getProperty("TESTS_CONFIG") ?: "/configs/basic.conf" diff --git a/tests/integration-tests/src/test/kotlin/config/VaultAuthType.kt b/tests/integration-tests/src/test/kotlin/config/VaultAuthType.kt index 0bda8e5904..d19428ae07 100644 --- a/tests/integration-tests/src/test/kotlin/config/VaultAuthType.kt +++ b/tests/integration-tests/src/test/kotlin/config/VaultAuthType.kt @@ -2,5 +2,5 @@ package config enum class VaultAuthType { APP_ROLE, - TOKEN + TOKEN, } diff --git a/tests/integration-tests/src/test/kotlin/config/services/ServiceBase.kt b/tests/integration-tests/src/test/kotlin/config/services/ServiceBase.kt index 8b3bbf97ca..af1b7b0b0d 100644 --- a/tests/integration-tests/src/test/kotlin/config/services/ServiceBase.kt +++ b/tests/integration-tests/src/test/kotlin/config/services/ServiceBase.kt @@ -17,7 +17,6 @@ interface ServiceBase : Startable { } fun postStart() { - } override fun stop() { diff --git a/tests/integration-tests/src/test/kotlin/config/services/Vault.kt b/tests/integration-tests/src/test/kotlin/config/services/Vault.kt index 2053e82c91..ebd7234de6 100644 --- a/tests/integration-tests/src/test/kotlin/config/services/Vault.kt +++ b/tests/integration-tests/src/test/kotlin/config/services/Vault.kt @@ -22,7 +22,7 @@ data class Vault( mapOf( "VAULT_PORT" to httpPort.toString(), - ), + ), ).waitingFor( "vault", Wait.forHealthcheck(), diff --git a/tests/integration-tests/src/test/kotlin/steps/Setup.kt b/tests/integration-tests/src/test/kotlin/steps/Setup.kt index 35811e293b..22c867ae05 100644 --- a/tests/integration-tests/src/test/kotlin/steps/Setup.kt +++ b/tests/integration-tests/src/test/kotlin/steps/Setup.kt @@ -167,6 +167,7 @@ object Setup { config.services?.vault?.stop() } } + @BeforeAll fun init() { Setup.initServices() diff --git a/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt b/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt index a65e9f052f..93824e027d 100644 --- a/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt @@ -1,8 +1,5 @@ package steps.common -import steps.connection.ConnectionSteps -import steps.credentials.IssueCredentialsSteps -import steps.did.PublishDidSteps import interactions.Get import io.cucumber.java.ParameterType import io.cucumber.java.en.Given @@ -16,6 +13,9 @@ import net.serenitybdd.rest.SerenityRest import net.serenitybdd.screenplay.Actor import net.serenitybdd.screenplay.actors.OnStage import org.apache.http.HttpStatus +import steps.connection.ConnectionSteps +import steps.credentials.IssueCredentialsSteps +import steps.did.PublishDidSteps class CommonSteps { @ParameterType(".*") diff --git a/tests/integration-tests/src/test/kotlin/steps/credentials/IssueCredentialsSteps.kt b/tests/integration-tests/src/test/kotlin/steps/credentials/IssueCredentialsSteps.kt index cdcb7af3d5..cc69b8f247 100644 --- a/tests/integration-tests/src/test/kotlin/steps/credentials/IssueCredentialsSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/credentials/IssueCredentialsSteps.kt @@ -26,7 +26,7 @@ class IssueCredentialsSteps { holder: Actor, didForm: String, schemaGuid: String?, - claims: Map + claims: Map, ) { val did: String = if (didForm == "short") { issuer.recall("shortFormDid") @@ -85,12 +85,12 @@ class IssueCredentialsSteps { issuer: Actor, holder: Actor, format: String, - schema: CredentialSchema + schema: CredentialSchema, ) { val schemaGuid = issuer.recall(schema.name)!! val claims = linkedMapOf( "name" to "Name", - "age" to 18 + "age" to 18, ) sendCredentialOffer(issuer, holder, format, schemaGuid, claims) saveCredentialOffer(issuer, holder) @@ -101,12 +101,12 @@ class IssueCredentialsSteps { issuer: Actor, holder: Actor, format: String, - schema: CredentialSchema + schema: CredentialSchema, ) { val schemaGuid = issuer.recall(schema.name)!! val claims = linkedMapOf( "name" to "Name", - "surname" to "Surname" + "surname" to "Surname", ) sendCredentialOffer(issuer, holder, "short", schemaGuid, claims) } @@ -210,10 +210,10 @@ class IssueCredentialsSteps { it.data.thid == holder.recall("thid") } credentialEvent != null && - credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.OFFER_RECEIVED + credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.OFFER_RECEIVED }, "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.", ) val recordId = ListenToEvents.`as`(holder).credentialEvents.last().data.recordId @@ -258,7 +258,7 @@ class IssueCredentialsSteps { it.data.thid == issuer.recall("thid") } credentialEvent != null && - credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.REQUEST_RECEIVED + credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.REQUEST_RECEIVED }, "Issuer was unable to receive the credential request from Holder! Protocol state did not achieve RequestReceived state.", ) @@ -276,10 +276,10 @@ class IssueCredentialsSteps { it.data.thid == issuer.recall("thid") } credentialEvent != null && - credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT + credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_SENT }, "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.", ) } @@ -291,10 +291,10 @@ class IssueCredentialsSteps { it.data.thid == holder.recall("thid") } credentialEvent != null && - credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED + credentialEvent!!.data.protocolState == IssueCredentialRecord.ProtocolState.CREDENTIAL_RECEIVED }, "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.", ) holder.remember("issuedCredential", ListenToEvents.`as`(holder).credentialEvents.last().data) } @@ -302,7 +302,7 @@ class IssueCredentialsSteps { @Then("{actor} should see that credential issuance has failed") fun issuerShouldSeeThatCredentialIssuanceHasFailed(issuer: Actor) { issuer.attemptsTo( - Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_BAD_REQUEST) + Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_BAD_REQUEST), ) } } diff --git a/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt b/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt index 094dd8817c..5abb2cab40 100644 --- a/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt @@ -94,8 +94,9 @@ class PublishDidSteps { if (agent.recallAll().containsKey("hasPublishedDid")) { return } - if (!agent.recallAll().containsKey("shortFormDid") - && !agent.recallAll().containsKey("longFormDid")) { + if (!agent.recallAll().containsKey("shortFormDid") && + !agent.recallAll().containsKey("longFormDid") + ) { createsUnpublishedDid(agent) } hePublishesDidToLedger(agent) @@ -103,8 +104,9 @@ class PublishDidSteps { @Given("{actor} has an unpublished DID") fun agentHasAnUnpublishedDID(agent: Actor) { - if (agent.recallAll().containsKey("shortFormDid") - || agent.recallAll().containsKey("longFormDid")) { + if (agent.recallAll().containsKey("shortFormDid") || + agent.recallAll().containsKey("longFormDid") + ) { // is not published if (!agent.recallAll().containsKey("hasPublishedDid")) { return diff --git a/tests/integration-tests/src/test/kotlin/steps/proofs/AnoncredsPresentProofSteps.kt b/tests/integration-tests/src/test/kotlin/steps/proofs/AnoncredsPresentProofSteps.kt index 148d80aab8..3bdc9fd0b0 100644 --- a/tests/integration-tests/src/test/kotlin/steps/proofs/AnoncredsPresentProofSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/proofs/AnoncredsPresentProofSteps.kt @@ -35,39 +35,39 @@ class AnoncredsPresentProofSteps { restrictions = listOf( mapOf( ("attr::sex::value" to "M"), - ("cred_def_id" to credentialDefinitionId) - ) - ) - ) + ("cred_def_id" to credentialDefinitionId), + ), + ), + ), ), requestedPredicates = mapOf( "age" to AnoncredRequestedPredicateV1( name = "age", pType = ">=", pValue = 18, - restrictions = emptyList() - ) + restrictions = emptyList(), + ), ), name = "proof_req_1", nonce = "1103253414365527824079144", - version = "0.1" + version = "0.1", ) val presentationRequest = RequestPresentationInput( connectionId = faber.recall("connection-with-${bob.name}").connectionId, credentialFormat = "AnonCreds", anoncredPresentationRequest = anoncredsPresentationRequestV1, - proofs = emptyList() + proofs = emptyList(), ) faber.attemptsTo( Post.to("/present-proof/presentations") .with { it.body( - presentationRequest + presentationRequest, ) - } + }, ) faber.attemptsTo( - Ensure.thatTheLastResponse().apply { println(this.contentType()) }.statusCode().isEqualTo(SC_CREATED) + Ensure.thatTheLastResponse().apply { println(this.contentType()) }.statusCode().isEqualTo(SC_CREATED), ) val presentationStatus = SerenityRest.lastResponse().get() faber.remember("thid", presentationStatus.thid) @@ -84,7 +84,7 @@ class AnoncredsPresentProofSteps { proofEvent != null && proofEvent!!.data.status == PresentationStatus.Status.REQUEST_RECEIVED }, - "ERROR: Bob did not achieve any presentation request!" + "ERROR: Bob did not achieve any presentation request!", ) bob.remember("presentationId", proofEvent!!.data.presentationId) } @@ -98,19 +98,19 @@ class AnoncredsPresentProofSteps { AnoncredCredentialProofV1( bob.recall("issuedCredential").recordId, listOf("sex"), - listOf("age") - ) - ) + listOf("age"), + ), + ), ), - action = RequestPresentationAction.Action.REQUEST_MINUS_ACCEPT + action = RequestPresentationAction.Action.REQUEST_MINUS_ACCEPT, ) bob.attemptsTo( Patch.to("/present-proof/presentations/${bob.recall("presentationId")}").with { it.body( - requestPresentationAction + requestPresentationAction, ) - } + }, ) } } diff --git a/tests/integration-tests/src/test/kotlin/steps/schemas/CredentialSchemasSteps.kt b/tests/integration-tests/src/test/kotlin/steps/schemas/CredentialSchemasSteps.kt index ec3d2d9ce4..f9b77328d4 100644 --- a/tests/integration-tests/src/test/kotlin/steps/schemas/CredentialSchemasSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/schemas/CredentialSchemasSteps.kt @@ -114,7 +114,7 @@ class CredentialSchemasSteps { @Then("{actor} should see the schema creation failed") fun schemaCreationShouldFail(agent: Actor) { agent.attemptsTo( - Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_BAD_REQUEST) + Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_BAD_REQUEST), ) } } @@ -135,7 +135,7 @@ enum class SchemaErrorTemplate { }, "required": ["name"] } - """.trimIndent() + """.trimIndent() } }, CUSTOM_WORDS_NOT_DEFINED { @@ -174,7 +174,7 @@ enum class SchemaErrorTemplate { } """ } - }; + }, ; abstract fun inner_schema(): String diff --git a/tests/integration-tests/src/test/kotlin/steps/verification/VcVerificationSteps.kt b/tests/integration-tests/src/test/kotlin/steps/verification/VcVerificationSteps.kt new file mode 100644 index 0000000000..02902c2835 --- /dev/null +++ b/tests/integration-tests/src/test/kotlin/steps/verification/VcVerificationSteps.kt @@ -0,0 +1,74 @@ +package steps.verification + +import interactions.Post +import io.cucumber.java.en.When +import io.iohk.atala.automation.extensions.get +import io.iohk.atala.automation.serenity.ensure.Ensure +import io.iohk.atala.prism.models.* +import net.serenitybdd.rest.SerenityRest +import net.serenitybdd.screenplay.Actor +import org.apache.http.HttpStatus.SC_OK +import java.time.OffsetDateTime + +class VcVerificationSteps { + + @When("{actor} verifies VcVerificationRequest") + fun agentVerifiesVerifiableCredential(actor: Actor) { + val signedJwtCredential = + "eyJhbGciOiJFUzI1NksifQ.eyJhdWQiOiJkaWQ6cHJpc206dmVyaWZpZXIiLCJuYmYiOjEyNjIzMDQwMDAsImlzcyI6ImRpZDpwcmlzbTo3NzYxMjBlZWIxMjhjZTdkZmQ5NDUwZmZhMTg4MWU5OTYxOWFhMGM5MDRiMDBjODJiYjE3YjU2ODE3Y2IwMmFlIiwiZXhwIjoxMjYzMjU0NDAwLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL2V4YW1wbGVzL3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJVbml2ZXJzaXR5RGVncmVlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU2NoZW1hIjp7ImlkIjoiZGlkOndvcms6TURQOEFzRmhIemh3VXZHTnVZa1g3VDtpZD0wNmUxMjZkMS1mYTQ0LTQ4ODItYTI0My0xZTMyNmZiZTIxZGI7dmVyc2lvbj0xLjAiLCJ0eXBlIjoiSnNvblNjaGVtYVZhbGlkYXRvcjIwMTgifSwiY3JlZGVudGlhbFN1YmplY3QiOnsidXNlck5hbWUiOiJCb2IiLCJhZ2UiOjQyLCJlbWFpbCI6ImVtYWlsIn0sImNyZWRlbnRpYWxTdGF0dXMiOnsiaWQiOiJkaWQ6d29yazpNRFA4QXNGaEh6aHdVdkdOdVlrWDdUO2lkPTA2ZTEyNmQxLWZhNDQtNDg4Mi1hMjQzLTFlMzI2ZmJlMjFkYjt2ZXJzaW9uPTEuMCIsInR5cGUiOiJTdGF0dXNMaXN0MjAyMUVudHJ5Iiwic3RhdHVzUHVycG9zZSI6IlJldm9jYXRpb24iLCJzdGF0dXNMaXN0SW5kZXgiOjAsInN0YXR1c0xpc3RDcmVkZW50aWFsIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9jcmVkZW50aWFscy9zdGF0dXMvMyJ9LCJyZWZyZXNoU2VydmljZSI6eyJpZCI6Imh0dHBzOi8vZXhhbXBsZS5lZHUvcmVmcmVzaC8zNzMyIiwidHlwZSI6Ik1hbnVhbFJlZnJlc2hTZXJ2aWNlMjAxOCJ9fSwianRpIjoiaHR0cDovL2V4YW1wbGUuZWR1L2NyZWRlbnRpYWxzLzM3MzIifQ.JCHIAQdjmOxOdZ1SIf5Nd8FObiARXT6cDcGM3UyQ961Kv4Rb3ZtgpNM-cf2aj5ZFyFko-t7uCsSvrVrYKUYcWg" + val request = + listOf( + VcVerificationRequest( + signedJwtCredential, + listOf( + ParameterizableVcVerification(VcVerification.SIGNATURE_VERIFICATION), + ParameterizableVcVerification( + VcVerification.NOT_BEFORE_CHECK, + DateTimeParameter(OffsetDateTime.now()) as VcVerificationParameter, + ), + ParameterizableVcVerification( + VcVerification.EXPIRATION_CHECK, + DateTimeParameter(OffsetDateTime.now()) as VcVerificationParameter, + ), + ), + ), + VcVerificationRequest( + signedJwtCredential, + listOf( + ParameterizableVcVerification( + VcVerification.AUDIENCE_CHECK, + DidParameter("did:prism:verifier") as VcVerificationParameter, + ), + ), + ), + ) + actor.attemptsTo( + Post.to("/verification/credential").with { + it.body(request) + }, + ) + val vcVerificationResponses = SerenityRest.lastResponse().get>() + + actor.attemptsTo( + Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK), + Ensure.that(vcVerificationResponses).containsExactlyInAnyOrderElementsFrom( + listOf( + VcVerificationResponse( + signedJwtCredential, + listOf( + VcVerificationResult(VcVerification.SIGNATURE_VERIFICATION, false), + VcVerificationResult(VcVerification.NOT_BEFORE_CHECK, true), + VcVerificationResult(VcVerification.EXPIRATION_CHECK, true), + ), + ), + VcVerificationResponse( + signedJwtCredential, + listOf( + VcVerificationResult(VcVerification.AUDIENCE_CHECK, true), + ), + ), + ), + ), + ) + } +} diff --git a/tests/integration-tests/src/test/kotlin/steps/verificationpolicies/VerificationPoliciesSteps.kt b/tests/integration-tests/src/test/kotlin/steps/verificationpolicies/VerificationPoliciesSteps.kt index ab891702a5..0c3c0e1e5a 100644 --- a/tests/integration-tests/src/test/kotlin/steps/verificationpolicies/VerificationPoliciesSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/verificationpolicies/VerificationPoliciesSteps.kt @@ -8,8 +8,8 @@ import io.cucumber.java.en.Then import io.cucumber.java.en.When import io.iohk.atala.automation.extensions.get import io.iohk.atala.automation.serenity.ensure.Ensure -import io.iohk.atala.prism.models.VerificationPolicyResponse import io.iohk.atala.prism.models.VerificationPolicyInput +import io.iohk.atala.prism.models.VerificationPolicyResponse import net.serenitybdd.rest.SerenityRest import net.serenitybdd.screenplay.Actor import org.apache.http.HttpStatus diff --git a/tests/integration-tests/src/test/resources/features/verification/vc_verification.feature b/tests/integration-tests/src/test/resources/features/verification/vc_verification.feature new file mode 100644 index 0000000000..fa84cdf553 --- /dev/null +++ b/tests/integration-tests/src/test/resources/features/verification/vc_verification.feature @@ -0,0 +1,8 @@ +@credential_schema +Feature: Credential schemas + + Background: + When Issuer creates unpublished DID + + Scenario: Successful Verifies VcVerificationRequest + When Issuer verifies VcVerificationRequest