From 074adc2ce8db83c725ec23fdce9f9e06db44d2ff Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Wed, 11 Dec 2024 14:10:38 +0530 Subject: [PATCH 1/5] fix: Anoncreds schemas and validation Signed-off-by: DaevMithran --- acapy_agent/messaging/valid.py | 19 ++++++--- acapy_agent/revocation/routes.py | 46 +++++++++++----------- acapy_agent/revocation_anoncreds/routes.py | 42 ++++++++++---------- acapy_agent/wallet/did_method.py | 8 ++++ acapy_agent/wallet/routes.py | 21 +++++++++- 5 files changed, 84 insertions(+), 52 deletions(-) diff --git a/acapy_agent/messaging/valid.py b/acapy_agent/messaging/valid.py index c5026ca382..3089fd25ff 100644 --- a/acapy_agent/messaging/valid.py +++ b/acapy_agent/messaging/valid.py @@ -363,16 +363,20 @@ def __init__(self): class AnoncredsDID(Regexp): - """Validate value against indy DID.""" + """Validate value against anoncreds DID.""" + + METHOD = r"([a-zA-Z0-9_]+)" + NETWORK = r"(:[a-zA-Z0-9_.%-]+)?" # Optional network + METHOD_ID = r"([a-zA-Z0-9_.%-]+(:[a-zA-Z0-9_.%-]+)*)" EXAMPLE = "did:(method):WgWxqztrNooG92RXvxSTWv" - PATTERN = re.compile("^(did:[a-z]:.+$)?$") + PATTERN = re.compile(rf"^did:{METHOD}{NETWORK}:{METHOD_ID}") def __init__(self): """Initialize the instance.""" super().__init__( - IndyDID.PATTERN, + DIDValidation.PATTERN, error="Value {input} is not an decentralized identifier (DID)", ) @@ -381,6 +385,7 @@ class DIDValidation(Regexp): """Validate value against any valid DID spec.""" METHOD = r"([a-zA-Z0-9_]+)" + NETWORK = r"(:[a-zA-Z0-9_.%-]+)?" # Optional network METHOD_ID = r"([a-zA-Z0-9_.%-]+(:[a-zA-Z0-9_.%-]+)*)" PARAMS = r"((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)" PATH = r"(\/[^#?]*)?" @@ -388,7 +393,9 @@ class DIDValidation(Regexp): FRAGMENT = r"(\#.*)?$" EXAMPLE = "did:peer:WgWxqztrNooG92RXvxSTWv" - PATTERN = re.compile(rf"^did:{METHOD}:{METHOD_ID}{PARAMS}{PATH}{QUERY}{FRAGMENT}$") + PATTERN = re.compile( + rf"^did:{METHOD}{NETWORK}:{METHOD_ID}{PARAMS}{PATH}{QUERY}{FRAGMENT}$" + ) def __init__(self): """Initialize the instance.""" @@ -485,7 +492,7 @@ def __init__(self): """Initialize the instance.""" super().__init__( - IndyCredDefId.PATTERN, + AnoncredsCredDefId.PATTERN, error="Value {input} is not an anoncreds credential definition identifier", ) @@ -530,7 +537,7 @@ def __init__(self): """Initialize the instance.""" super().__init__( - IndySchemaId.PATTERN, + AnoncredsSchemaId.PATTERN, error="Value {input} is not an anoncreds schema identifier", ) diff --git a/acapy_agent/revocation/routes.py b/acapy_agent/revocation/routes.py index 4899e729a8..d082fc3a07 100644 --- a/acapy_agent/revocation/routes.py +++ b/acapy_agent/revocation/routes.py @@ -32,12 +32,12 @@ from ..messaging.models.openapi import OpenAPISchema from ..messaging.responder import BaseResponder from ..messaging.valid import ( - INDY_CRED_DEF_ID_EXAMPLE, - INDY_CRED_DEF_ID_VALIDATE, + ANONCREDS_CRED_DEF_ID_EXAMPLE, + ANONCREDS_CRED_DEF_ID_VALIDATE, INDY_CRED_REV_ID_EXAMPLE, INDY_CRED_REV_ID_VALIDATE, - INDY_REV_REG_ID_EXAMPLE, - INDY_REV_REG_ID_VALIDATE, + ANONCREDS_REV_REG_ID_EXAMPLE, + ANONCREDS_REV_REG_ID_VALIDATE, INDY_REV_REG_SIZE_EXAMPLE, INDY_REV_REG_SIZE_VALIDATE, UUID4_EXAMPLE, @@ -86,10 +86,10 @@ class RevRegCreateRequestSchema(OpenAPISchema): """Request schema for revocation registry creation request.""" credential_definition_id = fields.Str( - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) max_cred_num = fields.Int( @@ -143,10 +143,10 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) cred_rev_id = fields.Str( @@ -182,18 +182,18 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) cred_def_id = fields.Str( required=False, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) @@ -270,7 +270,7 @@ class PublishRevocationsSchema(OpenAPISchema): rrid2crid = fields.Dict( required=False, - keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, @@ -303,7 +303,7 @@ class ClearPendingRevocationsRequestSchema(OpenAPISchema): purge = fields.Dict( required=False, - keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, @@ -383,10 +383,10 @@ class RevRegsCreatedSchema(OpenAPISchema): rev_reg_ids = fields.List( fields.Str( - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifiers", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) ) @@ -401,7 +401,7 @@ class RevRegUpdateTailsFileUriSchema(OpenAPISchema): "description": "Public URI to the tails file", "example": ( "http://192.168.56.133:6543/revocation/registry/" - f"{INDY_REV_REG_ID_EXAMPLE}/tails-file" + f"{ANONCREDS_REV_REG_ID_EXAMPLE}/tails-file" ), }, ) @@ -412,10 +412,10 @@ class RevRegsCreatedQueryStringSchema(OpenAPISchema): cred_def_id = fields.Str( required=False, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) state = fields.Str( @@ -452,10 +452,10 @@ class RevRegIdMatchInfoSchema(OpenAPISchema): rev_reg_id = fields.Str( required=True, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation Registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) @@ -465,10 +465,10 @@ class RevocationCredDefIdMatchInfoSchema(OpenAPISchema): cred_def_id = fields.Str( required=True, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) diff --git a/acapy_agent/revocation_anoncreds/routes.py b/acapy_agent/revocation_anoncreds/routes.py index 4c5b3bd8b0..ccda33a5f1 100644 --- a/acapy_agent/revocation_anoncreds/routes.py +++ b/acapy_agent/revocation_anoncreds/routes.py @@ -38,12 +38,12 @@ from ..ledger.multiple_ledger.base_manager import BaseMultipleLedgerManager from ..messaging.models.openapi import OpenAPISchema from ..messaging.valid import ( - INDY_CRED_DEF_ID_EXAMPLE, - INDY_CRED_DEF_ID_VALIDATE, + ANONCREDS_CRED_DEF_ID_EXAMPLE, + ANONCREDS_CRED_DEF_ID_VALIDATE, INDY_CRED_REV_ID_EXAMPLE, INDY_CRED_REV_ID_VALIDATE, - INDY_REV_REG_ID_EXAMPLE, - INDY_REV_REG_ID_VALIDATE, + ANONCREDS_REV_REG_ID_EXAMPLE, + ANONCREDS_REV_REG_ID_VALIDATE, UUID4_EXAMPLE, UUID4_VALIDATE, WHOLE_NUM_EXAMPLE, @@ -99,10 +99,10 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) cred_rev_id = fields.Str( @@ -138,18 +138,18 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) cred_def_id = fields.Str( required=False, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) @@ -215,10 +215,10 @@ class RevRegsCreatedSchemaAnoncreds(OpenAPISchema): rev_reg_ids = fields.List( fields.Str( - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifiers", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) ) @@ -233,7 +233,7 @@ class RevRegUpdateTailsFileUriSchema(OpenAPISchema): "description": "Public URI to the tails file", "example": ( "http://192.168.56.133:6543/revocation/registry/" - f"{INDY_REV_REG_ID_EXAMPLE}/tails-file" + f"{ANONCREDS_REV_REG_ID_EXAMPLE}/tails-file" ), }, ) @@ -244,10 +244,10 @@ class RevRegsCreatedQueryStringSchema(OpenAPISchema): cred_def_id = fields.Str( required=False, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) state = fields.Str( @@ -284,10 +284,10 @@ class RevRegIdMatchInfoSchema(OpenAPISchema): rev_reg_id = fields.Str( required=True, - validate=INDY_REV_REG_ID_VALIDATE, + validate=ANONCREDS_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation Registry identifier", - "example": INDY_REV_REG_ID_EXAMPLE, + "example": ANONCREDS_REV_REG_ID_EXAMPLE, }, ) @@ -297,10 +297,10 @@ class RevocationCredDefIdMatchInfoSchema(OpenAPISchema): cred_def_id = fields.Str( required=True, - validate=INDY_CRED_DEF_ID_VALIDATE, + validate=ANONCREDS_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": INDY_CRED_DEF_ID_EXAMPLE, + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, }, ) @@ -348,7 +348,7 @@ class PublishRevocationsSchemaAnoncreds(OpenAPISchema): rrid2crid = fields.Dict( required=False, - keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, @@ -368,7 +368,7 @@ class PublishRevocationsResultSchemaAnoncreds(OpenAPISchema): rrid2crid = fields.Dict( required=False, - keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, diff --git a/acapy_agent/wallet/did_method.py b/acapy_agent/wallet/did_method.py index 2acf670837..1587f012c7 100644 --- a/acapy_agent/wallet/did_method.py +++ b/acapy_agent/wallet/did_method.py @@ -97,6 +97,13 @@ def holder_defined_did(self) -> HolderDefinedDid: holder_defined_did=HolderDefinedDid.NO, ) +CHEQD = DIDMethod( + name="cheqd", + key_types=[ED25519], + rotation=True, + holder_defined_did=HolderDefinedDid.ALLOWED, +) + class DIDMethods: """DID Method class specifying DID methods with supported key types.""" @@ -110,6 +117,7 @@ def __init__(self) -> None: PEER2.method_name: PEER2, PEER4.method_name: PEER4, TDW.method_name: TDW, + CHEQD.method_name: CHEQD, } def registered(self, method: str) -> bool: diff --git a/acapy_agent/wallet/routes.py b/acapy_agent/wallet/routes.py index cf539d61ac..afe6632902 100644 --- a/acapy_agent/wallet/routes.py +++ b/acapy_agent/wallet/routes.py @@ -70,7 +70,17 @@ ) from .base import BaseWallet from .did_info import DIDInfo -from .did_method import KEY, PEER2, PEER4, SOV, DIDMethod, DIDMethods, HolderDefinedDid +from .did_method import ( + KEY, + PEER2, + PEER4, + SOV, + DIDMethod, + DIDMethods, + HolderDefinedDid, + CHEQD, + TDW, +) from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError from .key_type import BLS12381G2, ED25519, KeyTypes @@ -312,7 +322,14 @@ class DIDListQueryStringSchema(OpenAPISchema): method = fields.Str( required=False, validate=validate.OneOf( - [KEY.method_name, SOV.method_name, PEER2.method_name, PEER4.method_name] + [ + KEY.method_name, + SOV.method_name, + TDW.method_name, + CHEQD.method_name, + PEER2.method_name, + PEER4.method_name, + ] ), metadata={ "example": KEY.method_name, From 87acb4368192d2f9527614d4ab0832741ab6393f Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Wed, 11 Dec 2024 14:10:38 +0530 Subject: [PATCH 2/5] fix: Anoncreds schemas and validation Signed-off-by: DaevMithran --- acapy_agent/revocation/tests/test_routes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/acapy_agent/revocation/tests/test_routes.py b/acapy_agent/revocation/tests/test_routes.py index 97f33c5cc8..f0e5f6b054 100644 --- a/acapy_agent/revocation/tests/test_routes.py +++ b/acapy_agent/revocation/tests/test_routes.py @@ -74,7 +74,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): ): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, } ) @@ -82,13 +82,15 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields({}) with self.assertRaises(test_module.ValidationError): - req.validate_fields({"rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE}) + req.validate_fields( + {"rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE} + ) with self.assertRaises(test_module.ValidationError): req.validate_fields({"cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE}) with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, } ) @@ -102,7 +104,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, } From ee41b3fe288248d662302987514006309fbed13e Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Wed, 11 Dec 2024 14:51:39 +0530 Subject: [PATCH 3/5] fix tests Signed-off-by: DaevMithran --- acapy_agent/revocation_anoncreds/tests/test_routes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/acapy_agent/revocation_anoncreds/tests/test_routes.py b/acapy_agent/revocation_anoncreds/tests/test_routes.py index 6f0ea1577b..ae8d806b1a 100644 --- a/acapy_agent/revocation_anoncreds/tests/test_routes.py +++ b/acapy_agent/revocation_anoncreds/tests/test_routes.py @@ -42,7 +42,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): ): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, } ) @@ -50,13 +50,15 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields({}) with self.assertRaises(test_module.ValidationError): - req.validate_fields({"rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE}) + req.validate_fields( + {"rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE} + ) with self.assertRaises(test_module.ValidationError): req.validate_fields({"cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE}) with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, } ) @@ -70,7 +72,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, } From 5739bcbcc58fcb4f6e0d200f05d0fcd188013c27 Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Wed, 11 Dec 2024 23:51:28 +0530 Subject: [PATCH 4/5] Move did:cheqd wallet injection to plugins Signed-off-by: DaevMithran --- acapy_agent/wallet/did_method.py | 8 -------- acapy_agent/wallet/routes.py | 12 ------------ 2 files changed, 20 deletions(-) diff --git a/acapy_agent/wallet/did_method.py b/acapy_agent/wallet/did_method.py index 1587f012c7..2acf670837 100644 --- a/acapy_agent/wallet/did_method.py +++ b/acapy_agent/wallet/did_method.py @@ -97,13 +97,6 @@ def holder_defined_did(self) -> HolderDefinedDid: holder_defined_did=HolderDefinedDid.NO, ) -CHEQD = DIDMethod( - name="cheqd", - key_types=[ED25519], - rotation=True, - holder_defined_did=HolderDefinedDid.ALLOWED, -) - class DIDMethods: """DID Method class specifying DID methods with supported key types.""" @@ -117,7 +110,6 @@ def __init__(self) -> None: PEER2.method_name: PEER2, PEER4.method_name: PEER4, TDW.method_name: TDW, - CHEQD.method_name: CHEQD, } def registered(self, method: str) -> bool: diff --git a/acapy_agent/wallet/routes.py b/acapy_agent/wallet/routes.py index afe6632902..0b33f1bd80 100644 --- a/acapy_agent/wallet/routes.py +++ b/acapy_agent/wallet/routes.py @@ -78,8 +78,6 @@ DIDMethod, DIDMethods, HolderDefinedDid, - CHEQD, - TDW, ) from .did_posture import DIDPosture from .error import WalletError, WalletNotFoundError @@ -321,16 +319,6 @@ class DIDListQueryStringSchema(OpenAPISchema): ) method = fields.Str( required=False, - validate=validate.OneOf( - [ - KEY.method_name, - SOV.method_name, - TDW.method_name, - CHEQD.method_name, - PEER2.method_name, - PEER4.method_name, - ] - ), metadata={ "example": KEY.method_name, "description": ( From 31ea8cf2a7557a6cc9c95ad895a656b911fe9b01 Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Thu, 12 Dec 2024 00:16:50 +0530 Subject: [PATCH 5/5] Revert /revocation endpoint schema to INDY Signed-off-by: DaevMithran --- acapy_agent/revocation/routes.py | 46 ++++++++++----------- acapy_agent/revocation/tests/test_routes.py | 10 ++--- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/acapy_agent/revocation/routes.py b/acapy_agent/revocation/routes.py index d082fc3a07..4899e729a8 100644 --- a/acapy_agent/revocation/routes.py +++ b/acapy_agent/revocation/routes.py @@ -32,12 +32,12 @@ from ..messaging.models.openapi import OpenAPISchema from ..messaging.responder import BaseResponder from ..messaging.valid import ( - ANONCREDS_CRED_DEF_ID_EXAMPLE, - ANONCREDS_CRED_DEF_ID_VALIDATE, + INDY_CRED_DEF_ID_EXAMPLE, + INDY_CRED_DEF_ID_VALIDATE, INDY_CRED_REV_ID_EXAMPLE, INDY_CRED_REV_ID_VALIDATE, - ANONCREDS_REV_REG_ID_EXAMPLE, - ANONCREDS_REV_REG_ID_VALIDATE, + INDY_REV_REG_ID_EXAMPLE, + INDY_REV_REG_ID_VALIDATE, INDY_REV_REG_SIZE_EXAMPLE, INDY_REV_REG_SIZE_VALIDATE, UUID4_EXAMPLE, @@ -86,10 +86,10 @@ class RevRegCreateRequestSchema(OpenAPISchema): """Request schema for revocation registry creation request.""" credential_definition_id = fields.Str( - validate=ANONCREDS_CRED_DEF_ID_VALIDATE, + validate=INDY_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, + "example": INDY_CRED_DEF_ID_EXAMPLE, }, ) max_cred_num = fields.Int( @@ -143,10 +143,10 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=ANONCREDS_REV_REG_ID_VALIDATE, + validate=INDY_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": ANONCREDS_REV_REG_ID_EXAMPLE, + "example": INDY_REV_REG_ID_EXAMPLE, }, ) cred_rev_id = fields.Str( @@ -182,18 +182,18 @@ def validate_fields(self, data, **kwargs): rev_reg_id = fields.Str( required=False, - validate=ANONCREDS_REV_REG_ID_VALIDATE, + validate=INDY_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifier", - "example": ANONCREDS_REV_REG_ID_EXAMPLE, + "example": INDY_REV_REG_ID_EXAMPLE, }, ) cred_def_id = fields.Str( required=False, - validate=ANONCREDS_CRED_DEF_ID_VALIDATE, + validate=INDY_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, + "example": INDY_CRED_DEF_ID_EXAMPLE, }, ) @@ -270,7 +270,7 @@ class PublishRevocationsSchema(OpenAPISchema): rrid2crid = fields.Dict( required=False, - keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, @@ -303,7 +303,7 @@ class ClearPendingRevocationsRequestSchema(OpenAPISchema): purge = fields.Dict( required=False, - keys=fields.Str(metadata={"example": ANONCREDS_REV_REG_ID_EXAMPLE}), + keys=fields.Str(metadata={"example": INDY_REV_REG_ID_EXAMPLE}), values=fields.List( fields.Str( validate=INDY_CRED_REV_ID_VALIDATE, @@ -383,10 +383,10 @@ class RevRegsCreatedSchema(OpenAPISchema): rev_reg_ids = fields.List( fields.Str( - validate=ANONCREDS_REV_REG_ID_VALIDATE, + validate=INDY_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation registry identifiers", - "example": ANONCREDS_REV_REG_ID_EXAMPLE, + "example": INDY_REV_REG_ID_EXAMPLE, }, ) ) @@ -401,7 +401,7 @@ class RevRegUpdateTailsFileUriSchema(OpenAPISchema): "description": "Public URI to the tails file", "example": ( "http://192.168.56.133:6543/revocation/registry/" - f"{ANONCREDS_REV_REG_ID_EXAMPLE}/tails-file" + f"{INDY_REV_REG_ID_EXAMPLE}/tails-file" ), }, ) @@ -412,10 +412,10 @@ class RevRegsCreatedQueryStringSchema(OpenAPISchema): cred_def_id = fields.Str( required=False, - validate=ANONCREDS_CRED_DEF_ID_VALIDATE, + validate=INDY_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, + "example": INDY_CRED_DEF_ID_EXAMPLE, }, ) state = fields.Str( @@ -452,10 +452,10 @@ class RevRegIdMatchInfoSchema(OpenAPISchema): rev_reg_id = fields.Str( required=True, - validate=ANONCREDS_REV_REG_ID_VALIDATE, + validate=INDY_REV_REG_ID_VALIDATE, metadata={ "description": "Revocation Registry identifier", - "example": ANONCREDS_REV_REG_ID_EXAMPLE, + "example": INDY_REV_REG_ID_EXAMPLE, }, ) @@ -465,10 +465,10 @@ class RevocationCredDefIdMatchInfoSchema(OpenAPISchema): cred_def_id = fields.Str( required=True, - validate=ANONCREDS_CRED_DEF_ID_VALIDATE, + validate=INDY_CRED_DEF_ID_VALIDATE, metadata={ "description": "Credential definition identifier", - "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, + "example": INDY_CRED_DEF_ID_EXAMPLE, }, ) diff --git a/acapy_agent/revocation/tests/test_routes.py b/acapy_agent/revocation/tests/test_routes.py index f0e5f6b054..97f33c5cc8 100644 --- a/acapy_agent/revocation/tests/test_routes.py +++ b/acapy_agent/revocation/tests/test_routes.py @@ -74,7 +74,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): ): req.validate_fields( { - "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, } ) @@ -82,15 +82,13 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields({}) with self.assertRaises(test_module.ValidationError): - req.validate_fields( - {"rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE} - ) + req.validate_fields({"rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE}) with self.assertRaises(test_module.ValidationError): req.validate_fields({"cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE}) with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, } ) @@ -104,7 +102,7 @@ async def test_validate_cred_rev_rec_qs_and_revoke_req(self): with self.assertRaises(test_module.ValidationError): req.validate_fields( { - "rev_reg_id": test_module.ANONCREDS_REV_REG_ID_EXAMPLE, + "rev_reg_id": test_module.INDY_REV_REG_ID_EXAMPLE, "cred_rev_id": test_module.INDY_CRED_REV_ID_EXAMPLE, "cred_ex_id": test_module.UUID4_EXAMPLE, }