mirror of https://github.com/nucypher/nucypher.git
Tests that show Bob that Bob is able to issue a WorkOrder via REST.
parent
df9f24e612
commit
c4cbff3359
|
@ -305,5 +305,19 @@ class WorkOrder(object):
|
||||||
receipt_bytes = b"wo:" + ursula_dht_key + keccak_digest(b"".join(pfrags))
|
receipt_bytes = b"wo:" + ursula_dht_key + keccak_digest(b"".join(pfrags))
|
||||||
receipt_signature = bobs_seal(receipt_bytes)
|
receipt_signature = bobs_seal(receipt_bytes)
|
||||||
bob_pubkey_sig = bytes(bobs_seal)
|
bob_pubkey_sig = bytes(bobs_seal)
|
||||||
return cls(ursula_dht_key, p_frags, receipt_bytes, receipt_signature, bob_pubkey_sig)
|
return cls(kfrag_hrac, pfrags, receipt_bytes, receipt_signature, bob_pubkey_sig, ursula_dht_key)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_rest_payload(cls, kfrag_hrac, rest_payload):
|
||||||
|
payload_splitter = BytestringSplitter(Signature, PublicKey)
|
||||||
|
signature, bob_pubkey_sig, (receipt_bytes, packed_pfrags) = payload_splitter(rest_payload, msgpack_remainder=True)
|
||||||
|
pfrags = msgpack.loads(packed_pfrags)
|
||||||
|
verified = signature.verify(receipt_bytes, bob_pubkey_sig)
|
||||||
|
if not verified:
|
||||||
|
raise ValueError("This doesn't appear to be from Bob.")
|
||||||
|
return cls(kfrag_hrac, pfrags, receipt_bytes, signature, bob_pubkey_sig)
|
||||||
|
|
||||||
|
def payload(self):
|
||||||
|
return bytes(self.receipt_signature) + self.bob_pubkey_sig + msgpack.dumps((self.receipt_bytes, msgpack.dumps(self.pfrags)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,14 @@ def test_bob_can_issue_a_work_order_to_a_specific_ursula(enacted_policy_group, a
|
||||||
assert len(bob._ursulas) == len(ursulas)
|
assert len(bob._ursulas) == len(ursulas)
|
||||||
|
|
||||||
p_frags = (b"llamas", b"dingos")
|
p_frags = (b"llamas", b"dingos")
|
||||||
work_order = bob.generate_work_order(p_frags)
|
work_orders = bob.generate_work_orders(enacted_policy_group, p_frags, num_ursulas=1)
|
||||||
|
|
||||||
|
assert len(work_orders) == 1
|
||||||
|
|
||||||
networky_stuff = MockNetworkyStuff(ursulas)
|
networky_stuff = MockNetworkyStuff(ursulas)
|
||||||
bob.issue_work_order(networky_stuff, work_order, num_ursulas=1) # Issue the work order only to the first Ursula.
|
|
||||||
|
for ursula_dht_key, work_order in work_orders.items():
|
||||||
|
bob.get_reencrypted_c_frag(networky_stuff, work_order) # Issue the work order only to the first Ursula.
|
||||||
|
|
||||||
first_ursula = bob.get_ursula(0)
|
first_ursula = bob.get_ursula(0)
|
||||||
work_orders_from_bob = first_ursula.work_orders(bob=bob)
|
work_orders_from_bob = first_ursula.work_orders(bob=bob)
|
||||||
|
|
Loading…
Reference in New Issue