diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/BackgroundJobs.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/BackgroundJobs.scala index 7b8c8cf374..a05728a6d3 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/BackgroundJobs.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/BackgroundJobs.scala @@ -274,7 +274,7 @@ object BackgroundJobs { // Set PublicationState to PublicationPending for { credentialService <- ZIO.service[CredentialService] - longFormPrismDID <- getLongForm(issuerDID, false) + longFormPrismDID <- getLongForm(issuerDID, true) jwtIssuer <- createJwtIssuer(longFormPrismDID, VerificationRelationship.AssertionMethod) w3Credential <- credentialService.createCredentialPayloadFromRecord( record, @@ -402,9 +402,8 @@ object BackgroundJobs { .mapError(e => RuntimeException(s"Error occurred while getting did from wallet: ${e.toString}")) .someOrFail(RuntimeException(s"Issuer DID does not exist in the wallet: $did")) .flatMap { - case s: ManagedDIDState.Published => ZIO.succeed(s) - case s if allowUnpublishedIssuingDID => ZIO.succeed(s) - case _ => ZIO.fail(RuntimeException(s"Issuer DID must be published: $did")) + case s: ManagedDIDState.Published => ZIO.succeed(s) + case s => ZIO.cond(allowUnpublishedIssuingDID, s, RuntimeException(s"Issuer DID must be published: $did")) } longFormPrismDID = PrismDID.buildLongFormFromOperation(didState.createOperation) } yield longFormPrismDID diff --git a/tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt b/tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt index a242901540..9d54b304cf 100644 --- a/tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt +++ b/tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt @@ -68,7 +68,7 @@ class CommonSteps { publishDidSteps.createsUnpublishedDid(holder) publishDidSteps.createsUnpublishedDid(issuer) publishDidSteps.hePublishesDidToLedger(issuer) - issueSteps.acmeOffersACredential(issuer, holder) + issueSteps.acmeOffersACredential(issuer, holder, "short") issueSteps.bobRequestsTheCredential(holder) issueSteps.acmeIssuesTheCredential(issuer) issueSteps.bobHasTheCredentialIssued(holder) diff --git a/tests/e2e-tests/src/test/kotlin/features/issue_credentials/IssueCredentialsSteps.kt b/tests/e2e-tests/src/test/kotlin/features/issue_credentials/IssueCredentialsSteps.kt index 66c0d2a2d6..c6355b3dfb 100644 --- a/tests/e2e-tests/src/test/kotlin/features/issue_credentials/IssueCredentialsSteps.kt +++ b/tests/e2e-tests/src/test/kotlin/features/issue_credentials/IssueCredentialsSteps.kt @@ -15,8 +15,12 @@ import org.apache.http.HttpStatus.SC_CREATED import org.apache.http.HttpStatus.SC_OK class IssueCredentialsSteps { - @When("{actor} offers a credential to {actor}") - fun acmeOffersACredential(issuer: Actor, holder: Actor) { + @When("{actor} offers a credential to {actor} with {string} form DID") + fun acmeOffersACredential(issuer: Actor, holder: Actor, didForm: String) { + + val did: String = if (didForm == "short") + issuer.recall("shortFormDid") else issuer.recall("longFormDid") + val newCredential = Credential( schemaId = "schema:1234", validityPeriod = 3600, @@ -26,10 +30,9 @@ class IssueCredentialsSteps { "firstName" to "FirstName", "lastName" to "LastName", ), - issuingDID = issuer.recall("shortFormDid"), + issuingDID = did, connectionId = issuer.recall("connection-with-${holder.name}").connectionId, ) - issuer.attemptsTo( Post.to("/issue-credentials/credential-offers") .with { diff --git a/tests/e2e-tests/src/test/resources/features/issue_credentials/issue_credentials.feature b/tests/e2e-tests/src/test/resources/features/issue_credentials/issue_credentials.feature index f45b492ff7..527e4fa667 100644 --- a/tests/e2e-tests/src/test/resources/features/issue_credentials/issue_credentials.feature +++ b/tests/e2e-tests/src/test/resources/features/issue_credentials/issue_credentials.feature @@ -7,7 +7,17 @@ Scenario: Issuing credential with published PRISM DID to unpublished PRISM DID When Acme creates unpublished DID And He publishes DID to ledger And Bob creates unpublished DID - And Acme offers a credential to Bob + And Acme offers a credential to Bob with "short" form DID + And Bob receives the credential offer and accepts + And Acme issues the credential + Then Bob receives the issued credential + +@TEST_ATL-3894 +Scenario: Issuing credential with unpublished PRISM DID to unpublished PRISM DID + Given Acme and Bob have an existing connection + When Acme creates unpublished DID + And Bob creates unpublished DID + And Acme offers a credential to Bob with "long" form DID And Bob receives the credential offer and accepts And Acme issues the credential Then Bob receives the issued credential