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):
|
def mock_set_policy(id_as_hex):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def mock_receive_treasure_map(treasure_map_id):
|
with NotARestApp.replace_route("set_policy", mock_set_policy):
|
||||||
return Response(bytes(), status=202)
|
with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True):
|
||||||
|
with patch('umbral.keys.UmbralPublicKey.from_bytes',
|
||||||
with NotARestApp.replace_route("receive_treasure_map", mock_receive_treasure_map):
|
new=actual_random_key_instead):
|
||||||
with NotARestApp.replace_route("set_policy", mock_set_policy):
|
with mock_cert_loading, mock_metadata_validation, mock_message_verification:
|
||||||
with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True):
|
with mock_secret_source():
|
||||||
with patch('umbral.keys.UmbralPublicKey.from_bytes',
|
policy = highperf_mocked_alice.grant(
|
||||||
new=actual_random_key_instead):
|
highperf_mocked_bob, b"any label", m=20, n=30,
|
||||||
with mock_cert_loading, mock_metadata_validation, mock_message_verification:
|
expiration=maya.when('next week'),
|
||||||
with mock_secret_source():
|
publish_treasure_map=False)
|
||||||
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.
|
# TODO: Make some assertions about policy.
|
||||||
total_verified = sum(node.verified_node for node in highperf_mocked_alice.known_nodes)
|
total_verified = sum(node.verified_node for node in highperf_mocked_alice.known_nodes)
|
||||||
assert total_verified == 30
|
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.__dict__ = _umbral_pubkey.__dict__
|
||||||
self.__class__ = _umbral_pubkey.__class__
|
self.__class__ = _umbral_pubkey.__class__
|
||||||
|
|
||||||
|
def to_cryptography_pubkey(self):
|
||||||
|
self.i_want_to_be_a_real_boy()
|
||||||
|
return self.to_cryptography_pubkey()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def params(self):
|
def params(self):
|
||||||
# Holy heck, metamock hacking.
|
# Holy heck, metamock hacking.
|
||||||
|
|
Loading…
Reference in New Issue