From 1bcda8071bc4726e76602bdd5e33f177f6683bd8 Mon Sep 17 00:00:00 2001 From: pstlouis Date: Thu, 4 Jan 2024 16:24:05 -0500 Subject: [PATCH 1/2] allow list or string as service type + test cases Signed-off-by: pstlouis --- pydid/service.py | 2 +- tests/test_service.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pydid/service.py b/pydid/service.py index fc79054..d7d53e6 100644 --- a/pydid/service.py +++ b/pydid/service.py @@ -17,7 +17,7 @@ class Service(Resource): """Representation of DID Document Services.""" id: DIDUrl - type: str + type: Union[str, List[str]] service_endpoint: Union[ EndpointStrings, List[Union[EndpointStrings, Mapping[str, Any]]], diff --git a/tests/test_service.py b/tests/test_service.py index f04530b..ebbc855 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -63,6 +63,11 @@ "routingKeys": ["did:example:somemediator#somekey"], }, }, + { + "id": "did:web:example.com#linked-domain", + "type": ["LinkedDomains"], + "serviceEndpoint": "https://example.com", + }, ] INVALID_SERVICES = [ @@ -81,6 +86,31 @@ "type": "LinkedDomains", "serviceEndpoint": True, }, + { + "id": "did:web:example.com#linked-domain", + "type": "", + "serviceEndpoint": "https://example.com", + }, + { + "id": "did:web:example.com#linked-domain", + "type": ["Linked Domains"], + "serviceEndpoint": "https://example.com", + }, + { + "id": "did:web:example.com#linked-domain", + "type": ["LinkedDomains", True], + "serviceEndpoint": "https://example.com", + }, + { + "id": "did:web:example.com#linked-domain", + "type": [], + "serviceEndpoint": "https://example.com", + }, + { + "id": "did:web:example.com#linked-domain", + "type": [""], + "serviceEndpoint": "https://example.com", + }, ] From 7fb49325f159890327b08fba92d7ceb579165056 Mon Sep 17 00:00:00 2001 From: pstlouis Date: Fri, 5 Jan 2024 00:23:45 -0500 Subject: [PATCH 2/2] remove added invalid services Signed-off-by: pstlouis --- tests/test_service.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/tests/test_service.py b/tests/test_service.py index ebbc855..0a4ce84 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -86,31 +86,6 @@ "type": "LinkedDomains", "serviceEndpoint": True, }, - { - "id": "did:web:example.com#linked-domain", - "type": "", - "serviceEndpoint": "https://example.com", - }, - { - "id": "did:web:example.com#linked-domain", - "type": ["Linked Domains"], - "serviceEndpoint": "https://example.com", - }, - { - "id": "did:web:example.com#linked-domain", - "type": ["LinkedDomains", True], - "serviceEndpoint": "https://example.com", - }, - { - "id": "did:web:example.com#linked-domain", - "type": [], - "serviceEndpoint": "https://example.com", - }, - { - "id": "did:web:example.com#linked-domain", - "type": [""], - "serviceEndpoint": "https://example.com", - }, ]