diff --git a/infrastructure/local/.env b/infrastructure/local/.env index 4363e2f955..adadbb14f5 100644 --- a/infrastructure/local/.env +++ b/infrastructure/local/.env @@ -1,3 +1,3 @@ AGENT_VERSION=1.33.1 -PRISM_NODE_VERSION=2.2.1 +PRISM_NODE_VERSION=2.3.0 VAULT_DEV_ROOT_TOKEN_ID=root diff --git a/tests/integration-tests/build.gradle.kts b/tests/integration-tests/build.gradle.kts index b9d606a6e1..e5735a9910 100644 --- a/tests/integration-tests/build.gradle.kts +++ b/tests/integration-tests/build.gradle.kts @@ -33,7 +33,7 @@ dependencies { testImplementation("io.ktor:ktor-server-netty:2.3.0") testImplementation("io.ktor:ktor-client-apache:2.3.0") // RestAPI client - testImplementation("org.hyperledger.identus:cloud-agent-client-kotlin:1.32.1") + testImplementation("org.hyperledger.identus:cloud-agent-client-kotlin:1.33.1") // Test helpers library testImplementation("io.iohk.atala:atala-automation:0.4.0") // Hoplite for configuration diff --git a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt index c5a9275432..a81f89afdc 100644 --- a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt +++ b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt @@ -21,7 +21,7 @@ object TestConstants { val DID_UPDATE_PUBLISH_MAX_WAIT_5_MIN = Duration.ofSeconds(60L) val PRISM_DID_AUTH_KEY = ManagedDIDKeyTemplate("auth-1", Purpose.AUTHENTICATION) - val PRISM_DID_UPDATE_NEW_AUTH_KEY = ManagedDIDKeyTemplate("auth-2", Purpose.AUTHENTICATION) + val PRISM_DID_UPDATE_NEW_AUTH_KEY = ManagedDIDKeyTemplate("auth-42", Purpose.AUTHENTICATION) val PRISM_DID_SERVICE_FOR_UPDATE = Service( "https://update.com", listOf("LinkedDomains"), 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 a4df15c5ed..1158745211 100644 --- a/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/common/CommonSteps.kt @@ -9,13 +9,11 @@ import net.serenitybdd.rest.SerenityRest import net.serenitybdd.screenplay.Actor 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 org.hyperledger.identus.client.models.* import steps.connection.ConnectionSteps import steps.credentials.IssueCredentialsSteps import steps.did.PublishDidSteps +import java.lang.IllegalArgumentException class CommonSteps { @ParameterType(".*") @@ -23,6 +21,16 @@ class CommonSteps { return OnStage.theActorCalled(actorName) } + @ParameterType(".*") + fun curve(value: String): Curve { + return Curve.decode(value) ?: throw IllegalArgumentException("$value is not a valid Curve value") + } + + @ParameterType(".*") + fun purpose(value: String): Purpose { + return Purpose.decode(value) ?: throw IllegalArgumentException("$value is not a valid Purpose value") + } + @Given("{actor} has an issued credential from {actor}") fun holderHasIssuedCredentialFromIssuer(holder: Actor, issuer: Actor) { holder.attemptsTo( diff --git a/tests/integration-tests/src/test/kotlin/steps/did/ManageDidSteps.kt b/tests/integration-tests/src/test/kotlin/steps/did/ManageDidSteps.kt index df87418e20..5469a7f4a1 100644 --- a/tests/integration-tests/src/test/kotlin/steps/did/ManageDidSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/did/ManageDidSteps.kt @@ -10,28 +10,27 @@ import io.iohk.atala.automation.serenity.ensure.Ensure import net.serenitybdd.rest.SerenityRest import net.serenitybdd.screenplay.Actor import org.apache.http.HttpStatus.SC_CREATED -import org.hyperledger.identus.client.models.CreateManagedDidRequest -import org.hyperledger.identus.client.models.CreateManagedDidRequestDocumentTemplate -import org.hyperledger.identus.client.models.Json -import org.hyperledger.identus.client.models.ManagedDID -import org.hyperledger.identus.client.models.ManagedDIDKeyTemplate -import org.hyperledger.identus.client.models.ManagedDIDPage -import org.hyperledger.identus.client.models.Purpose -import org.hyperledger.identus.client.models.Service +import org.apache.http.HttpStatus.SC_UNPROCESSABLE_ENTITY +import org.hyperledger.identus.client.models.* class ManageDidSteps { @Given("{actor} creates {int} PRISM DIDs") fun createsMultipleManagedDids(actor: Actor, number: Int) { repeat(number) { - createManageDid(actor) + createManageDidWithSecp256k1Key(actor) } actor.remember("number", number) } @When("{actor} creates PRISM DID") - fun createManageDid(actor: Actor) { - val createDidRequest = createPrismDidRequest() + fun createManageDidWithSecp256k1Key(actor: Actor) { + createManageDid(actor, Curve.SECP256K1, Purpose.AUTHENTICATION) + } + + @When("{actor} creates PRISM DID with {curve} key having {purpose} purpose") + fun createManageDid(actor: Actor, curve: Curve, purpose: Purpose) { + val createDidRequest = createPrismDidRequest(curve, purpose) actor.attemptsTo( Post.to("/did-registrar/dids") @@ -40,19 +39,17 @@ class ManageDidSteps { }, ) - actor.attemptsTo( - Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_CREATED), - ) + if (SerenityRest.lastResponse().statusCode() == SC_CREATED) { + var createdDids = actor.recall>("createdDids") + if (createdDids == null) { + createdDids = mutableListOf() + } - var createdDids = actor.recall>("createdDids") - if (createdDids == null) { - createdDids = mutableListOf() - } + val managedDid = SerenityRest.lastResponse().get() - val managedDid = SerenityRest.lastResponse().get() - - createdDids.add(managedDid.longFormDid!!) - actor.remember("createdDids", createdDids) + createdDids.add(managedDid.longFormDid!!) + actor.remember("createdDids", createdDids) + } } @When("{actor} lists all PRISM DIDs") @@ -71,6 +68,15 @@ class ManageDidSteps { ) } + @Then("{actor} sees PRISM DID was not successfully created") + fun theDidShouldNotBeRegisteredSuccessfully(actor: Actor) { + val error = SerenityRest.lastResponse().get() + actor.attemptsTo( + Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_UNPROCESSABLE_ENTITY), + Ensure.that(error.detail ?: "").isNotEmpty(), + ) + } + @Then("{actor} sees the list contains all created DIDs") fun seeTheListContainsAllCreatedDids(actor: Actor) { val expectedDids = actor.recall>("createdDids") @@ -81,9 +87,9 @@ class ManageDidSteps { ) } - private fun createPrismDidRequest(): CreateManagedDidRequest = CreateManagedDidRequest( + private fun createPrismDidRequest(curve: Curve, purpose: Purpose): CreateManagedDidRequest = CreateManagedDidRequest( CreateManagedDidRequestDocumentTemplate( - publicKeys = listOf(ManagedDIDKeyTemplate("auth-1", Purpose.AUTHENTICATION)), + publicKeys = listOf(ManagedDIDKeyTemplate("auth-1", purpose, curve)), services = listOf( Service("https://foo.bar.com", listOf("LinkedDomains"), Json("https://foo.bar.com/")), ), 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 cd04a6e14f..0793e8b2f0 100644 --- a/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/did/PublishDidSteps.kt @@ -50,8 +50,10 @@ class PublishDidSteps { val createDidRequest = CreateManagedDidRequest( CreateManagedDidRequestDocumentTemplate( publicKeys = listOf( - ManagedDIDKeyTemplate("auth-1", Purpose.AUTHENTICATION), - ManagedDIDKeyTemplate("assertion-1", Purpose.ASSERTION_METHOD), + ManagedDIDKeyTemplate("auth-1", Purpose.AUTHENTICATION, Curve.SECP256K1), + ManagedDIDKeyTemplate("auth-2", Purpose.AUTHENTICATION, Curve.ED25519), + ManagedDIDKeyTemplate("assertion-1", Purpose.ASSERTION_METHOD, Curve.SECP256K1), + ManagedDIDKeyTemplate("comm-1", Purpose.KEY_AGREEMENT, Curve.X25519), ), services = listOf( Service("https://foo.bar.com", listOf("LinkedDomains"), Json("https://foo.bar.com/")), diff --git a/tests/integration-tests/src/test/kotlin/steps/did/UpdateDidSteps.kt b/tests/integration-tests/src/test/kotlin/steps/did/UpdateDidSteps.kt index 0f4517d15d..9ff4b5e207 100644 --- a/tests/integration-tests/src/test/kotlin/steps/did/UpdateDidSteps.kt +++ b/tests/integration-tests/src/test/kotlin/steps/did/UpdateDidSteps.kt @@ -15,10 +15,7 @@ import org.hyperledger.identus.client.models.ActionType import org.hyperledger.identus.client.models.DIDOperationResponse import org.hyperledger.identus.client.models.DIDResolutionResult import org.hyperledger.identus.client.models.Json -import org.hyperledger.identus.client.models.ManagedDIDKeyTemplate -import org.hyperledger.identus.client.models.Purpose import org.hyperledger.identus.client.models.RemoveEntryById -import org.hyperledger.identus.client.models.Service import org.hyperledger.identus.client.models.UpdateManagedDIDRequest import org.hyperledger.identus.client.models.UpdateManagedDIDRequestAction import org.hyperledger.identus.client.models.UpdateManagedDIDServiceAction @@ -29,7 +26,7 @@ class UpdateDidSteps { fun actorUpdatesPrismDidByAddingNewKeys(actor: Actor) { val updatePrismDidAction = UpdateManagedDIDRequestAction( actionType = ActionType.ADD_KEY, - ManagedDIDKeyTemplate("auth-2", Purpose.AUTHENTICATION), + addKey = TestConstants.PRISM_DID_UPDATE_NEW_AUTH_KEY, ) actor.remember("updatePrismDidAction", updatePrismDidAction) } @@ -38,7 +35,7 @@ class UpdateDidSteps { fun actorUpdatesPrismDidByRemovingKeys(actor: Actor) { val updatePrismDidAction = UpdateManagedDIDRequestAction( actionType = ActionType.REMOVE_KEY, - removeKey = RemoveEntryById("auth-1"), + removeKey = RemoveEntryById(TestConstants.PRISM_DID_AUTH_KEY.id), ) actor.remember("updatePrismDidAction", updatePrismDidAction) } @@ -47,11 +44,7 @@ class UpdateDidSteps { fun actorUpdatesPrismDidWithNewServices(actor: Actor) { val updatePrismDidAction = UpdateManagedDIDRequestAction( actionType = ActionType.ADD_SERVICE, - addService = Service( - "https://new.service.com", - listOf("LinkedDomains"), - Json("https://new.service.com/"), - ), + addService = TestConstants.PRISM_DID_UPDATE_NEW_SERVICE, ) actor.remember("updatePrismDidAction", updatePrismDidAction) } @@ -60,7 +53,7 @@ class UpdateDidSteps { fun actorUpdatesPrismDidByRemovingServices(actor: Actor) { val updatePrismDidAction = UpdateManagedDIDRequestAction( actionType = ActionType.REMOVE_SERVICE, - removeService = RemoveEntryById("https://new.service.com"), + removeService = RemoveEntryById(TestConstants.PRISM_DID_UPDATE_NEW_SERVICE.id), ) actor.remember("updatePrismDidAction", updatePrismDidAction) } diff --git a/tests/integration-tests/src/test/resources/features/did/create_did.feature b/tests/integration-tests/src/test/resources/features/did/create_did.feature index e5177d5669..bc135ac68c 100644 --- a/tests/integration-tests/src/test/resources/features/did/create_did.feature +++ b/tests/integration-tests/src/test/resources/features/did/create_did.feature @@ -1,8 +1,25 @@ +@dev Feature: Create and publish DID -Scenario: Create PRISM DID - When Issuer creates PRISM DID +Scenario Outline: Create PRISM DID + When Issuer creates PRISM DID with key having purpose Then He sees PRISM DID was created successfully +Examples: + | curve | purpose | + | secp256k1 | authentication | + | secp256k1 | assertionMethod | + | Ed25519 | authentication | + | Ed25519 | assertionMethod | + | X25519 | keyAgreement | + +Scenario Outline: Create PRISM DID with disallowed key purpose + When Issuer creates PRISM DID with key having purpose + Then He sees PRISM DID was not successfully created + Examples: + | curve | purpose | + | Ed25519 | keyAgreement | + | X25519 | authentication | + | X25519 | assertionMethod | Scenario: Successfully publish DID to ledger When Issuer creates unpublished DID