Skip to content

Commit

Permalink
fix: draft 11 metadata structure
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Nov 16, 2023
1 parent eef72b6 commit d829292
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
14 changes: 7 additions & 7 deletions oid4vci/oid4vci/v1_0/models/supported_cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def __init__(
self.display = display
self.format_data = format_data

# @property
# def supported_cred_id(self):
# """Accessor for the ID associated with this record."""
# return self._id
@property
def supported_cred_id(self):
"""Accessor for the ID associated with this record."""
return self._id

@property
def record_value(self) -> dict:
Expand Down Expand Up @@ -88,7 +88,7 @@ def to_issuer_metadata(self) -> dict:
prop: getattr(self, prop)
for prop in (
"format",
# "identifier",
"identifier",
"cryptographic_binding_methods_supported",
"cryptographic_suites_supported",
"display",
Expand All @@ -99,7 +99,7 @@ def to_issuer_metadata(self) -> dict:
**issuer_metadata,
**(self.format_data or {}),
}
return {self.identifier: issuer_metadata}
return issuer_metadata


class SupportedCredentialSchema(BaseRecordSchema):
Expand All @@ -116,7 +116,7 @@ class Meta:
)
format = fields.Str(required=True, metadata={"example": "jwt_vc_json"})
identifier = fields.Str(
data_key="id", required=True, metadata={"example": "UniversityDegreeCredential"}
required=True, metadata={"example": "UniversityDegreeCredential"}
)
cryptographic_binding_methods_supported = fields.List(
fields.Str(), metadata={"example": []}
Expand Down
33 changes: 33 additions & 0 deletions oid4vci/tests/models/test_supported_cred.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from aries_cloudagent.core.profile import Profile
import pytest

from oid4vci.v1_0.models.supported_cred import SupportedCredential


@pytest.fixture
def record():
yield SupportedCredential(
format="jwt_vc_json",
identifier="MyCredential",
cryptographic_suites_supported=["EdDSA"],
format_data={
"credentialSubject": {"name": "alice"},
},
)


def test_serde(record: SupportedCredential):
record._id = "123"
serialized = record.serialize()
deserialized = SupportedCredential.deserialize(serialized)
assert record == deserialized


@pytest.mark.asyncio
async def test_save(profile: Profile, record: SupportedCredential):
async with profile.session() as session:
await record.save(session)
loaded = await SupportedCredential.retrieve_by_id(
session, record.supported_cred_id
)
assert loaded == record

0 comments on commit d829292

Please sign in to comment.