Skip to content

Commit

Permalink
seperate test fixtures, lint
Browse files Browse the repository at this point in the history
Signed-off-by: PatStLouis <patrick.st-louis@opsecid.ca>
  • Loading branch information
PatStLouis committed Jan 10, 2025
1 parent 9879a4a commit 262ae0a
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
TEST_DID_SOV = "did:sov:LjgpST2rjsoxYegQDRm7EL"
TEST_DID_KEY = "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL"

LD_PROOF_VC_DETAIL = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2018",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_BBS = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "BbsBlsSignature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_ED25519_2020 = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
"proof": {
"proofPurpose": "assertionMethod",
"created": "2019-12-11T03:50:55",
"type": "Ed25519Signature2018",
"verificationMethod": "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL#z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL",
"jws": "eyJhbGciOiAiRWREU0EiLCAiYjY0IjogZmFsc2UsICJjcml0IjogWyJiNjQiXX0..Q6amIrxGiSbM7Ce6DxlfwLCjVcYyclas8fMxaecspXFUcFW9DAAxKzgHx93FWktnlZjM_biitkMgZdStgvivAQ",
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,75 +43,12 @@
from ..handler import LOGGER as LD_PROOF_LOGGER
from ..handler import LDProofCredFormatHandler
from ..models.cred_detail import LDProofVCDetail

TEST_DID_SOV = "did:sov:LjgpST2rjsoxYegQDRm7EL"
TEST_DID_KEY = "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL"

LD_PROOF_VC_DETAIL = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2018",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_BBS = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "BbsBlsSignature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC_DETAIL_ED25519_2020 = {
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
},
"options": {
"proofType": "Ed25519Signature2020",
"created": "2019-12-11T03:50:55",
},
}
LD_PROOF_VC = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {"test": "key"},
"issuanceDate": "2021-04-12",
"issuer": TEST_DID_KEY,
"proof": {
"proofPurpose": "assertionMethod",
"created": "2019-12-11T03:50:55",
"type": "Ed25519Signature2018",
"verificationMethod": "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL#z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL",
"jws": "eyJhbGciOiAiRWREU0EiLCAiYjY0IjogZmFsc2UsICJjcml0IjogWyJiNjQiXX0..Q6amIrxGiSbM7Ce6DxlfwLCjVcYyclas8fMxaecspXFUcFW9DAAxKzgHx93FWktnlZjM_biitkMgZdStgvivAQ",
},
}
from .fixtures import (
LD_PROOF_VC_DETAIL,
LD_PROOF_VC_DETAIL_BBS,
LD_PROOF_VC_DETAIL_ED25519_2020,
LD_PROOF_VC,
)


class TestV20LDProofCredFormatHandler(IsolatedAsyncioTestCase):
Expand Down
8 changes: 4 additions & 4 deletions acapy_agent/vc/vc_ld/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ async def prepare_credential(
# How should this be handled?
if isinstance(subject, list):
subject = subject[0]

if (
not credential.issuance_date
not credential.issuance_date
and credential.context_urls[0] == CREDENTIALS_CONTEXT_V1_URL
):
credential.issuance_date = str(
datetime.now(timezone.utc).isoformat('T', 'seconds')
datetime.now(timezone.utc).isoformat("T", "seconds")
)

if not subject:
raise VcLdpManagerError("Credential subject is required")

Expand Down
2 changes: 0 additions & 2 deletions acapy_agent/vc/vc_ld/models/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def issuance_date(self, date: Union[str, datetime]):
if not date.tzinfo:
date = date.replace(tzinfo=tz.UTC)
date = date.isoformat()


self._issuance_date = date

Expand Down Expand Up @@ -289,7 +288,6 @@ def proof(self, proof: LDProof):
def __eq__(self, o: object) -> bool:
"""Check equality."""
if isinstance(o, VerifiableCredential):

return (
self.context == o.context
and self.id == o.id
Expand Down

0 comments on commit 262ae0a

Please sign in to comment.