From d82474a96994bd78a80ac545f02978723922adde Mon Sep 17 00:00:00 2001 From: jMyles Date: Mon, 12 Feb 2018 13:33:34 -0800 Subject: [PATCH] Showing that KFrag retrieved with Policy is among those granted. --- .../characters/test_alice_can_grant_and_revoke.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/characters/test_alice_can_grant_and_revoke.py b/tests/characters/test_alice_can_grant_and_revoke.py index de9bffa31..a579d1aae 100644 --- a/tests/characters/test_alice_can_grant_and_revoke.py +++ b/tests/characters/test_alice_can_grant_and_revoke.py @@ -8,6 +8,7 @@ from nkms.crypto.constants import PUBLIC_KEY_LENGTH from nkms.crypto.powers import SigningPower, EncryptingPower from nkms.crypto.utils import BytestringSplitter from tests.utilities import MockNetworkyStuff +from umbral.fragments import KFrag from umbral.keys import UmbralPublicKey @@ -27,8 +28,17 @@ def test_grant(alice, bob, ursulas): # Get the Policy from Ursula's datastore, looking up by hrac. proper_hrac = keccak_digest(bytes(alice.seal) + bytes(bob.seal) + uri) - kfrag_that_was_set = ursula.keystore.get_policy_contract(proper_hrac) - assert kfrag_that_was_set + retrieved_policy = ursula.keystore.get_policy_contract(proper_hrac) + + # TODO: Make this a legit KFrag, not bytes. + retrieved_k_frag = KFrag.from_bytes(retrieved_policy.k_frag) + + # TODO: Implement KFrag.__eq__ + found = False + for k_frag in policy.kfrags: + if bytes(k_frag) == bytes(retrieved_k_frag): + found = True + assert found def test_alice_can_get_ursulas_keys_via_rest(alice, ursulas):