From bb07b1f7c52e0503054b02aeff0fdcafb18c680a Mon Sep 17 00:00:00 2001 From: vtexier <vit@free.fr> Date: Sun, 23 Sep 2018 12:32:49 +0200 Subject: [PATCH] issue #52 Fix code and tests --- duniterpy/api/ws2p/network.py | 10 +++++++++- duniterpy/documents/ws2p/heads.py | 4 ++-- duniterpy/key/verifying_key.py | 7 ++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/duniterpy/api/ws2p/network.py b/duniterpy/api/ws2p/network.py index b7fa58af..ec9b3a14 100644 --- a/duniterpy/api/ws2p/network.py +++ b/duniterpy/api/ws2p/network.py @@ -54,4 +54,12 @@ WS2P_HEADS_SCHEMA = { "required": ["heads"] } -# todo: support ws2p v1 api + +def heads(client: Client): + """ + GET Certification data over a member + + :param client: Client to connect to the api + :rtype: dict + """ + return client.get(MODULE + '/ws2p/heads', schema=WS2P_HEADS_SCHEMA) diff --git a/duniterpy/documents/ws2p/heads.py b/duniterpy/documents/ws2p/heads.py index 1f63d90b..7d020e82 100644 --- a/duniterpy/documents/ws2p/heads.py +++ b/duniterpy/documents/ws2p/heads.py @@ -22,8 +22,8 @@ class API: data = API.re_inline.match(inline) if data is None: raise MalformedDocumentError("WS2P API Document") - private = data.group(1) - public = data.group(2) + private = "" if data.group(1) is None else data.group(1) + public = "" if data.group(2) is None else data.group(2) return cls(private, public) def __str__(self) -> str: diff --git a/duniterpy/key/verifying_key.py b/duniterpy/key/verifying_key.py index ba4652a6..aa419abe 100644 --- a/duniterpy/key/verifying_key.py +++ b/duniterpy/key/verifying_key.py @@ -5,11 +5,12 @@ duniter public and private keys """ import base64 +from typing import Any + import libnacl.sign import libnacl.encode from duniterpy.documents import Document -from duniterpy.documents.ws2p.heads import HeadV2 from .base58 import Base58Encoder @@ -41,10 +42,10 @@ class VerifyingKey(libnacl.sign.Verifier): except ValueError: return False - def verify_ws2p_head(self, head: HeadV2) -> bool: + def verify_ws2p_head(self, head: Any) -> bool: """ Check specified document - :param HeadV2 head: + :param Any head: :return: """ signature = base64.b64decode(head.signature) -- GitLab