Skip to content
Snippets Groups Projects
Commit bb07b1f7 authored by Vincent Texier's avatar Vincent Texier
Browse files

issue #52 Fix code and tests

parent e685da93
No related branches found
No related tags found
No related merge requests found
...@@ -54,4 +54,12 @@ WS2P_HEADS_SCHEMA = { ...@@ -54,4 +54,12 @@ WS2P_HEADS_SCHEMA = {
"required": ["heads"] "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)
...@@ -22,8 +22,8 @@ class API: ...@@ -22,8 +22,8 @@ class API:
data = API.re_inline.match(inline) data = API.re_inline.match(inline)
if data is None: if data is None:
raise MalformedDocumentError("WS2P API Document") raise MalformedDocumentError("WS2P API Document")
private = data.group(1) private = "" if data.group(1) is None else data.group(1)
public = data.group(2) public = "" if data.group(2) is None else data.group(2)
return cls(private, public) return cls(private, public)
def __str__(self) -> str: def __str__(self) -> str:
......
...@@ -5,11 +5,12 @@ duniter public and private keys ...@@ -5,11 +5,12 @@ duniter public and private keys
""" """
import base64 import base64
from typing import Any
import libnacl.sign import libnacl.sign
import libnacl.encode import libnacl.encode
from duniterpy.documents import Document from duniterpy.documents import Document
from duniterpy.documents.ws2p.heads import HeadV2
from .base58 import Base58Encoder from .base58 import Base58Encoder
...@@ -41,10 +42,10 @@ class VerifyingKey(libnacl.sign.Verifier): ...@@ -41,10 +42,10 @@ class VerifyingKey(libnacl.sign.Verifier):
except ValueError: except ValueError:
return False return False
def verify_ws2p_head(self, head: HeadV2) -> bool: def verify_ws2p_head(self, head: Any) -> bool:
""" """
Check specified document Check specified document
:param HeadV2 head: :param Any head:
:return: :return:
""" """
signature = base64.b64decode(head.signature) signature = base64.b64decode(head.signature)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment