def bob(alice, ursulas): BOB = Bob(alice=alice) BOB.attach_server() BOB.server.listen(8475) EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)])) congregate(alice, BOB, *ursulas) return BOB
def alice(ursulas): ALICE = Alice() ALICE.attach_server() ALICE.server.listen(8471) ALICE.__resource_id = b"some_resource_id" EVENT_LOOP.run_until_complete(ALICE.server.bootstrap([("127.0.0.1", u.port) for u in ursulas])) return ALICE
def alice(ursulas, mock_policy_agent, nucypher_test_config): ALICE = Alice(network_middleware=MockNetworkyStuff(ursulas), policy_agent=mock_policy_agent, config=nucypher_test_config) ALICE.server.listen(8471) ALICE.__resource_id = b"some_resource_id" EVENT_LOOP.run_until_complete(ALICE.server.bootstrap([("127.0.0.1", u.dht_port) for u in ursulas])) ALICE.network_bootstrap([("127.0.0.1", u.rest_port) for u in ursulas]) return ALICE
def test_treasure_map_with_bad_id_does_not_propagate(idle_policy, ursulas): """ In order to prevent spam attacks, Ursula refuses to propagate a TreasureMap whose PolicyGroup ID does not comport to convention. """ illegal_policygroup_id = b"This is not a conventional policygroup id" alice = idle_policy.alice bob = idle_policy.bob treasure_map = idle_policy.treasure_map message_kit, signature = alice.encrypt_for(bob, treasure_map.packed_payload()) setter = alice.server.set(illegal_policygroup_id, message_kit.to_bytes()) _set_event = EVENT_LOOP.run_until_complete(setter) with pytest.raises(KeyError): ursulas[0].server.storage[digest(illegal_policygroup_id)]
def test_treasure_map_with_bad_id_does_not_propagate(idle_policy, ursulas): """ In order to prevent spam attacks, Ursula refuses to propagate a TreasureMap whose PolicyGroup ID does not comport to convention. """ illegal_policygroup_id = "This is not a conventional policygroup id" alice = idle_policy.alice bob = idle_policy.bob treasure_map = idle_policy.treasure_map encrypted_treasure_map, signature = alice.encrypt_for(bob, treasure_map.packed_payload()) packed_encrypted_treasure_map = msgpack.dumps(encrypted_treasure_map) # TODO: #114? Do we even need to pack here? setter = alice.server.set(illegal_policygroup_id, packed_encrypted_treasure_map) _set_event = EVENT_LOOP.run_until_complete(setter) with pytest.raises(KeyError): ursulas[0].server.storage[digest(illegal_policygroup_id)]
def bob(alice, ursulas): BOB = Bob() BOB.server.listen(8475) EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)])) return BOB