Mocking one layer out (setting policy) for these tests.

pull/2140/head
jMyles 2020-04-21 10:38:25 -07:00
parent 5b63b670ae
commit 7deab1242d
2 changed files with 23 additions and 14 deletions

View File

@ -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

View File

@ -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.