Skip to content

Commit

Permalink
feat(prism-agent): allow published and unpublished DIDs in the issuin…
Browse files Browse the repository at this point in the history
…gDID field (#454)

* feat(prism-agent): Allow both published and unpublished DIDs in the issuingDID field (ATL-3892)

* tests: update e2e tests with long form issuing scenario

---------

Co-authored-by: Anton Baliasnikov <[email protected]>
  • Loading branch information
FabioPinheiro and Anton Baliasnikov authored Mar 17, 2023
1 parent fd87a73 commit ec107ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e-tests/src/test/kotlin/features/CommonSteps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,10 +30,9 @@ class IssueCredentialsSteps {
"firstName" to "FirstName",
"lastName" to "LastName",
),
issuingDID = issuer.recall("shortFormDid"),
issuingDID = did,
connectionId = issuer.recall<Connection>("connection-with-${holder.name}").connectionId,
)

issuer.attemptsTo(
Post.to("/issue-credentials/credential-offers")
.with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ec107ad

Please sign in to comment.