Skip to content

Commit

Permalink
test(sdk): integration tests for VC model 2.0 support
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Holovko <[email protected]>
  • Loading branch information
aholovko committed Oct 24, 2024
1 parent 433a09a commit e24c12f
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/testutil/contexts/examples_v2.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": [
{
"@vocab": "https://www.w3.org/ns/credentials/examples#"
}
]
}
6 changes: 6 additions & 0 deletions internal/testutil/document_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (
credentialExamples []byte
//go:embed contexts/examples_v1.jsonld
vcExamples []byte
//go:embed contexts/examples_v2.jsonld
vcExamplesV2 []byte
//go:embed contexts/odrl.jsonld
odrl []byte
//go:embed contexts/citizenship_v1.jsonld
Expand Down Expand Up @@ -62,6 +64,10 @@ func DocumentLoader(t *testing.T, extraContexts ...ldcontext.Document) *lddocloa
URL: "https://trustbloc.github.io/context/vc/examples-v1.jsonld",
Content: vcExamples,
},
{
URL: "https://www.w3.org/ns/credentials/examples/v2",
Content: vcExamplesV2,
},
{
URL: "https://www.w3.org/ns/odrl.jsonld",
Content: odrl,
Expand Down
104 changes: 104 additions & 0 deletions test/integration/expecteddisplaydata/university_degree_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"issuer_display": {
"name": "University Degree Issuer 2.0",
"locale": "en-US"
},
"credential_displays": [
{
"overview": {
"name": "University Degree Credential",
"locale": "en-US",
"logo": {
"uri": "https://example.com/public/logo.png",
"alt_text": "a square logo of a degree verification"
},
"background_color": "#12107c",
"text_color": "#FFFFFF"
},
"claims": [
{
"raw_id": "familyName",
"label": "Family Name",
"value_type": "string",
"raw_value": "John Doe",
"locale": "en-US"
},
{
"raw_id": "givenName",
"label": "Given Name",
"value_type": "string",
"raw_value": "John",
"locale": "en-US"
},
{
"raw_id": "degree",
"label": "Degree",
"value_type": "string",
"raw_value": "MIT",
"locale": "en-US"
},
{
"raw_id": "degreeSchool",
"label": "Degree School",
"value_type": "string",
"raw_value": "MIT school",
"locale": "en-US"
},
{
"raw_id": "photo",
"label": "Photo",
"value_type": "image",
"raw_value": "binary data"
}
]
},
{
"overview": {
"name": "University Degree Credential",
"locale": "en-US",
"logo": {
"uri": "https://example.com/public/logo.png",
"alt_text": "a square logo of a degree verification"
},
"background_color": "#12107c",
"text_color": "#FFFFFF"
},
"claims": [
{
"raw_id": "familyName",
"label": "Family Name",
"value_type": "string",
"raw_value": "John Doe",
"locale": "en-US"
},
{
"raw_id": "givenName",
"label": "Given Name",
"value_type": "string",
"raw_value": "John",
"locale": "en-US"
},
{
"raw_id": "degree",
"label": "Degree",
"value_type": "string",
"raw_value": "MS",
"locale": "en-US"
},
{
"raw_id": "degreeSchool",
"label": "Degree School",
"value_type": "string",
"raw_value": "Stanford",
"locale": "en-US"
},
{
"raw_id": "photo",
"label": "Photo",
"value_type": "image",
"raw_value": "binary data"
}
]
}
]
}
10 changes: 10 additions & 0 deletions test/integration/fixtures/file-server/ld-contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@
}]
}
},
{
"url": "https://www.w3.org/ns/credentials/examples/v2",
"content" : {
"@context": [
{
"@vocab": "https://www.w3.org/ns/credentials/examples#"
}
]
}
},
{
"url": "https://www.w3.org/ns/odrl.jsonld",
"content": {
Expand Down
139 changes: 139 additions & 0 deletions test/integration/fixtures/profile/profiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,145 @@
},
"createDID": true
},
{
"issuer": {
"id": "university_degree_issuer_v2",
"version": "v1.0",
"groupID": "group_university_degree_issuer_v2",
"name": "University Degree Issuer 2.0",
"organizationID": "f13d1va9lp403pb9lyj89vk55",
"url": "http://localhost:8075",
"active": true,
"vcConfig": {
"model": "w3c-vc-2.0",
"refreshServiceEnabled": false,
"signingAlgorithm": "JsonWebSignature2020",
"signatureRepresentation": 0,
"keyType": "ED25519",
"format": "ldp",
"didMethod": "ion",
"status": {
"type": "BitstringStatusListEntry"
}
},
"dataIntegrityProof": {
"enable": true,
"suiteType": "ecdsa-2019"
},
"oidcConfig": {
"client_id": "7d4u50e7w6nfq8tfayhzplgjf",
"client_secret_handle": "282ks4fkuqfosus5k0x30abnv",
"issuer_well_known": "http://cognito-mock.trustbloc.local:9229/local_5a9GzRvB/.well-known/openid-configuration",
"scopes_supported": [
"openid",
"profile"
],
"grant_types_supported": [
"authorization_code",
"urn:ietf:params:oauth:grant-type:pre-authorized_code"
],
"response_types_supported": [
"code"
],
"token_endpoint_auth_methods_supported": [
"none"
],
"pre-authorized_grant_anonymous_access_supported": true
},
"credentialTemplates": [
{
"contexts": [
"https://www.w3.org/ns/credentials/v2",
"https://www.w3.org/ns/credentials/examples/v2"
],
"type": "UniversityDegreeCredential",
"id": "universityDegreeTemplateID",
"issuer": "did:orb:bank_issuer_v2",
"checks": {
"strict": true
}
}
],
"credentialMetadata": {
"credential_configurations_supported": {
"UniversityDegreeCredential_ldp_vc_v1": {
"format": "ldp_vc",
"credential_definition": {
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"credentialSubject": {
"familyName": {
"display": [
{
"name": "Family Name",
"locale": "en-US"
}
],
"value_type": "string"
},
"givenName": {
"display": [
{
"name": "Given Name",
"locale": "en-US"
}
],
"value_type": "string"
},
"degree": {
"display": [
{
"name": "Degree",
"locale": "en-US"
}
],
"value_type": "string"
},
"photo": {
"display": [
{
"name": "Photo"
}
],
"value_type": "image"
},
"degreeSchool": {
"display": [
{
"name": "Degree School",
"locale": "en-US"
}
],
"value_type": "string"
}
}
},
"cryptographic_binding_methods_supported": [
"did"
],
"credential_signing_alg_values_supported": [
"Ed25519Signature2018"
],
"display": [
{
"name": "University Degree Credential",
"locale": "en-US",
"logo": {
"uri": "https://example.com/public/logo.png",
"alt_text": "a square logo of a degree verification"
},
"background_color": "#12107c",
"text_color": "#FFFFFF"
}
]
}
}
}
},
"createDID": true
},
{
"issuer": {
"id": "did_ion_issuer",
Expand Down
18 changes: 18 additions & 0 deletions test/integration/openid4ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ var (

//go:embed expecteddisplaydata/university_degree_multi.json
expectedUniversityDegreeMulti string

//go:embed expecteddisplaydata/university_degree_v2.json
expectedUniversityDegreeV2 string
)

const (
Expand Down Expand Up @@ -231,6 +234,21 @@ func doPreAuthCodeFlowTest(t *testing.T) {
expectedDisplayData: helpers.ParseDisplayData(t, expectedUniversityDegreeMulti),
expectedIssuerURI: "http://localhost:8075/oidc/idp/university_degree_issuer/v1.0",
},
{
issuerProfileID: "university_degree_issuer_v2",
issuerDIDMethod: "ion",
walletDIDMethod: "ion",
claims: []*claimEntry{
{
Data: universityDegreeClaims,
},
{
Data: universityDegreeClaims2,
},
},
expectedDisplayData: helpers.ParseDisplayData(t, expectedUniversityDegreeV2),
expectedIssuerURI: "http://localhost:8075/oidc/idp/university_degree_issuer_v2/v1.0",
},
}

oidc4ciSetup, err := oidc4ci.NewSetup(testenv.NewHttpRequest())
Expand Down
6 changes: 6 additions & 0 deletions test/integration/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ func TestOpenID4VPFullFlow(t *testing.T) {
verifierProfileID: "v_myprofile_jwt_verified_employee",
acknowledgeNoConsent: true,
},
{
issuerProfileIDs: []string{"university_degree_issuer_v2"},
claimData: []claimData{universityDegreeClaims},
walletDIDMethod: "ion",
verifierProfileID: "v_ldp_university_degree",
},
}

var traceIDs []string
Expand Down

0 comments on commit e24c12f

Please sign in to comment.