mirror of https://github.com/nucypher/nucypher.git
Mocking one layer out (setting policy) for these tests.
parent
5b63b670ae
commit
7deab1242d
|
@ -97,20 +97,25 @@ def test_alice_verifies_ursula_just_in_time(fleet_of_highperf_mocked_ursulas, hi
|
|||
def mock_set_policy(id_as_hex):
|
||||
return ""
|
||||
|
||||
def mock_receive_treasure_map(treasure_map_id):
|
||||
return Response(bytes(), status=202)
|
||||
|
||||
with NotARestApp.replace_route("receive_treasure_map", mock_receive_treasure_map):
|
||||
with NotARestApp.replace_route("set_policy", mock_set_policy):
|
||||
with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True):
|
||||
with patch('umbral.keys.UmbralPublicKey.from_bytes',
|
||||
new=actual_random_key_instead):
|
||||
with mock_cert_loading, mock_metadata_validation, mock_message_verification:
|
||||
with mock_secret_source():
|
||||
policy = highperf_mocked_alice.grant(
|
||||
highperf_mocked_bob, b"any label", m=20, n=30,
|
||||
expiration=maya.when('next week'),
|
||||
publish_treasure_map=False)
|
||||
with NotARestApp.replace_route("set_policy", mock_set_policy):
|
||||
with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True):
|
||||
with patch('umbral.keys.UmbralPublicKey.from_bytes',
|
||||
new=actual_random_key_instead):
|
||||
with mock_cert_loading, mock_metadata_validation, mock_message_verification:
|
||||
with mock_secret_source():
|
||||
policy = highperf_mocked_alice.grant(
|
||||
highperf_mocked_bob, b"any label", m=20, n=30,
|
||||
expiration=maya.when('next week'),
|
||||
publish_treasure_map=False)
|
||||
# TODO: Make some assertions about policy.
|
||||
total_verified = sum(node.verified_node for node in highperf_mocked_alice.known_nodes)
|
||||
assert total_verified == 30
|
||||
|
||||
with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True), mock_metadata_validation:
|
||||
try:
|
||||
policy.publish_treasure_map(network_middleware=highperf_mocked_alice.network_middleware)
|
||||
except Exception as e:
|
||||
raise
|
||||
|
||||
def test_mass_treasure_map_placement(highperf_mocked_alice):
|
||||
assert False
|
|
@ -399,6 +399,10 @@ class NotAPublicKey:
|
|||
self.__dict__ = _umbral_pubkey.__dict__
|
||||
self.__class__ = _umbral_pubkey.__class__
|
||||
|
||||
def to_cryptography_pubkey(self):
|
||||
self.i_want_to_be_a_real_boy()
|
||||
return self.to_cryptography_pubkey()
|
||||
|
||||
@property
|
||||
def params(self):
|
||||
# Holy heck, metamock hacking.
|
||||
|
|
Loading…
Reference in New Issue