Skip to content

Commit

Permalink
Add new keyid test for JWT with ED25519 signed credential
Browse files Browse the repository at this point in the history
Signed-off-by: mineme0110 <[email protected]>
  • Loading branch information
mineme0110 committed Oct 30, 2024
1 parent 91baa36 commit 39489ed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class DidPurpose {
ManagedDIDKeyTemplate("auth-1", Purpose.AUTHENTICATION, Curve.SECP256K1),
ManagedDIDKeyTemplate("auth-2", Purpose.AUTHENTICATION, Curve.ED25519),
ManagedDIDKeyTemplate("assertion-1", Purpose.ASSERTION_METHOD, Curve.SECP256K1),
ManagedDIDKeyTemplate("assertion-2", Purpose.ASSERTION_METHOD, Curve.ED25519),
)
override val services = mutableListOf<Service>()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ConnectionLessSteps {
val credentialOfferRequest = CreateIssueCredentialRecordRequest(
claims = claims,
issuingDID = did,
issuingKid = "assertion-1",
validityPeriod = 3600.0,
credentialFormat = credentialFormat,
automaticIssuance = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class JwtCredentialSteps {
didForm: String,
schemaGuid: String?,
claims: Map<String, Any>,
issuingKid :String?
) {
val did: String = if (didForm == "short") {
issuer.recall("shortFormDid")
Expand All @@ -38,7 +39,7 @@ class JwtCredentialSteps {
schemaId = schemaId?.let { listOf(it) },
claims = claims,
issuingDID = did,
issuingKid = "assertion-1",
issuingKid = issuingKid,
connectionId = issuer.recall<Connection>("connection-with-${holder.name}").connectionId,
validityPeriod = 3600.0,
credentialFormat = "JWT",
Expand Down Expand Up @@ -67,7 +68,17 @@ class JwtCredentialSteps {
"firstName" to "FirstName",
"lastName" to "LastName",
)
sendCredentialOffer(issuer, holder, format, null, claims)
sendCredentialOffer(issuer, holder, format, null, claims, "assertion-1")
saveCredentialOffer(issuer, holder)
}

@When("{actor} offers a jwt credential to {actor} with {string} form DID using issuingKid {string}")
fun issuerOffersAJwtCredentialWithIssuingKeyId(issuer: Actor, holder: Actor, format: String, issuingKid: String?) {
val claims = linkedMapOf(
"firstName" to "FirstName",
"lastName" to "LastName",
)
sendCredentialOffer(issuer, holder, format, null, claims, issuingKid)
saveCredentialOffer(issuer, holder)
}

Expand All @@ -80,7 +91,7 @@ class JwtCredentialSteps {
) {
val schemaGuid = issuer.recall<String>(schema.name)
val claims = schema.claims
sendCredentialOffer(issuer, holder, format, schemaGuid, claims)
sendCredentialOffer(issuer, holder, format, schemaGuid, claims, "assertion-1")
saveCredentialOffer(issuer, holder)
}

Expand All @@ -96,7 +107,7 @@ class JwtCredentialSteps {
"name" to "Name",
"surname" to "Surname",
)
sendCredentialOffer(issuer, holder, format, schemaGuid, claims)
sendCredentialOffer(issuer, holder, format, schemaGuid, claims, "assertion-1")
}

@When("{actor} accepts jwt credential offer")
Expand All @@ -108,4 +119,14 @@ class JwtCredentialSteps {
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK),
)
}

@When("{actor} accepts jwt credential offer with keyId {string}")
fun holderAcceptsJwtCredentialOfferForJwtWithKeyId(holder: Actor, keyId: String?) {
val recordId = holder.recall<String>("recordId")
holder.attemptsTo(
Post.to("/issue-credentials/records/$recordId/accept-offer")
.body(AcceptCredentialOfferRequest(holder.recall("longFormDid"), keyId)),
Ensure.thatTheLastResponse().statusCode().isEqualTo(SC_OK),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ Feature: Issue JWT credential
And Issuer issues the credential
Then Holder receives the issued credential

Scenario: Issuing jwt credential with published PRISM DID using Ed25519
Given Issuer and Holder have an existing connection
And Issuer has a published DID for JWT
And Holder has an unpublished DID for JWT
When Issuer offers a jwt credential to Holder with "short" form DID using issuingKid "assertion-2"
And Holder receives the credential offer
And Holder accepts jwt credential offer with keyId "auth-2"
And Issuer issues the credential
Then Holder receives the issued credential

Scenario: Issuing jwt credential with a schema
Given Issuer and Holder have an existing connection
And Issuer has a published DID for JWT
Expand Down

0 comments on commit 39489ed

Please sign in to comment.