fix tests
This commit is contained in:
parent
4bcb0911a7
commit
b1d119b9ba
|
@ -6,7 +6,7 @@ import nacl.encoding
|
|||
from did import generate_keys, generate_did, get_signing_key
|
||||
from sign_vc import sign
|
||||
from sign_vp import sign_vp
|
||||
from verify_vc import verify_vc
|
||||
from verify import verify_vc
|
||||
from verify_vp import verify_vp
|
||||
from utils import now
|
||||
|
||||
|
@ -107,7 +107,7 @@ def test_verifiable_credential():
|
|||
cred = json.dumps(credential)
|
||||
|
||||
vc = sign(cred, signing_key, did)
|
||||
verified = verify_vc(vc)
|
||||
verified = verify_vc(json.dumps(vc))
|
||||
assert verified
|
||||
|
||||
|
||||
|
@ -136,6 +136,6 @@ def test_verifiable_presentation():
|
|||
holder_did = generate_did(holder_key)
|
||||
holder_signing_key = get_signing_key(holder_key)
|
||||
vp = sign_vp(holder_signing_key, holder_did, vc_json)
|
||||
verified = verify_vp(vp)
|
||||
verified = verify_vc(json.dumps(vp))
|
||||
assert verified
|
||||
|
||||
|
|
30
verify_vp.py
30
verify_vp.py
|
@ -9,6 +9,20 @@ def get_presentation(path_presentation):
|
|||
return vc
|
||||
|
||||
|
||||
def verify_vp(presentation):
|
||||
vp = json.loads(presentation)
|
||||
|
||||
if not verify_vc(presentation):
|
||||
return False
|
||||
|
||||
for vc in vp['verifiableCredential']:
|
||||
vc_str = json.dumps(vc)
|
||||
if not verify_vc(vc_str):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description='Verify a presentation')
|
||||
parser.add_argument("presentation_path")
|
||||
|
@ -16,21 +30,7 @@ def main():
|
|||
|
||||
if args.presentation_path:
|
||||
presentation = get_presentation(args.presentation_path)
|
||||
presentation_verified = verify_vc(presentation)
|
||||
if not presentation_verified:
|
||||
print(presentation_verified)
|
||||
return
|
||||
|
||||
vp = json.loads(presentation)
|
||||
for vc in vp['verifiableCredential']:
|
||||
vc_str = json.dumps(vc)
|
||||
verified = verify_vc(vc_str)
|
||||
if not verified:
|
||||
print(verified)
|
||||
return
|
||||
|
||||
print(True)
|
||||
return
|
||||
print(verify_vp(presentation))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue