Make Ursula.rest_interface() a property. Remove Character.rest_interface

pull/1029/head
David Núñez 2019-06-17 10:41:10 +02:00
parent e1b0f3319b
commit 903b06f59e
9 changed files with 18 additions and 18 deletions

View File

@ -238,10 +238,6 @@ class Character(Learner):
def name(self):
return self.__class__.__name__
@property
def rest_interface(self):
return self.rest_server.rest_url()
@property
def stamp(self):
if self._stamp is NO_SIGNING_POWER:

View File

@ -986,11 +986,12 @@ class Ursula(Teacher, Character, Worker):
hosting_power.keypair.pubkey
)
@property
def rest_interface(self):
return self.rest_server.rest_interface
def get_deployer(self):
port = self.rest_interface().port
port = self.rest_interface.port
deployer = self._crypto_power.power_ups(TLSHostingPower).get_deployer(rest_app=self.rest_app, port=port)
return deployer
@ -1000,7 +1001,7 @@ class Ursula(Teacher, Character, Worker):
def __bytes__(self):
version = self.TEACHER_VERSION.to_bytes(2, "big")
interface_info = VariableLengthBytestring(bytes(self.rest_interface()))
interface_info = VariableLengthBytestring(bytes(self.rest_interface))
decentralized_identity_evidence = VariableLengthBytestring(self.decentralized_identity_evidence)
certificate = self.rest_server_certificate()

View File

@ -54,8 +54,8 @@ class Vladimir(Ursula):
vladimir = cls(is_me=True,
crypto_power=crypto_power,
db_filepath=cls.db_filepath,
rest_host=target_ursula.rest_interface().host,
rest_port=target_ursula.rest_interface().port,
rest_host=target_ursula.rest_interface.host,
rest_port=target_ursula.rest_interface.port,
certificate=target_ursula.rest_server_certificate(),
network_middleware=cls.network_middleware,
checksum_address=cls.fraud_address,

View File

@ -1105,8 +1105,8 @@ class Teacher:
else:
certificate_filepath = self.certificate_filepath
response_data = network_middleware.node_information(host=self.rest_interface().host,
port=self.rest_interface().port,
response_data = network_middleware.node_information(host=self.rest_interface.host,
port=self.rest_interface.port,
certificate_filepath=certificate_filepath)
version, node_bytes = self.version_splitter(response_data, return_remainder=True)
@ -1170,7 +1170,7 @@ class Teacher:
raise self.InvalidNode
def _signable_interface_info_message(self):
message = self.canonical_public_address + self.rest_interface()
message = self.canonical_public_address + self.rest_interface
return message
def _sign_and_date_interface_info(self):

View File

@ -84,3 +84,6 @@ class InterfaceInfo:
def __radd__(self, other):
return bytes(other) + bytes(self)
def __repr__(self):
return self.uri

View File

@ -34,7 +34,7 @@ class _TestMiddlewareClient(NucypherMiddlewareClient):
return response
def _get_mock_client_by_ursula(self, ursula):
port = ursula.rest_interface().port
port = ursula.rest_interface.port
return self._get_mock_client_by_port(port)
def _get_mock_client_by_url(self, url):
@ -128,10 +128,10 @@ class NodeIsDownMiddleware(MockRestMiddleware):
self.ports_that_are_down = []
def node_is_down(self, node):
self.client.ports_that_are_down.add(node.rest_interface().port)
self.client.ports_that_are_down.add(node.rest_interface.port)
def node_is_up(self, node):
self.client.ports_that_are_down.remove(node.rest_interface().port)
self.client.ports_that_are_down.remove(node.rest_interface.port)
class EvilMiddleWare(MockRestMiddleware):

View File

@ -51,7 +51,7 @@ def make_federated_ursulas(ursula_config: UrsulaConfiguration,
# Store this Ursula in our global testing cache.
port = ursula.rest_interface().port
port = ursula.rest_interface.port
MOCK_KNOWN_URSULAS_CACHE[port] = ursula
if know_each_other:
@ -92,7 +92,7 @@ def make_decentralized_ursulas(ursula_config: UrsulaConfiguration,
ursulas.append(ursula)
# Store this Ursula in our global cache.
port = ursula.rest_interface().port
port = ursula.rest_interface.port
MOCK_KNOWN_URSULAS_CACHE[port] = ursula
return ursulas

View File

@ -195,7 +195,7 @@ def test_bob_can_issue_a_work_order_to_a_specific_ursula(enacted_federated_polic
# OK, so cool - Bob has his cFrag! Let's make sure everything went properly. First, we'll show that it is in fact
# the correct cFrag (ie, that Ursula performed re-encryption properly).
for u in federated_ursulas:
if u.rest_interface().port == work_order.ursula.rest_interface().port:
if u.rest_interface.port == work_order.ursula.rest_interface.port:
ursula = u
break
else:

View File

@ -175,7 +175,7 @@ def test_anybody_can_encrypt():
def test_node_deployer(federated_ursulas):
for ursula in federated_ursulas:
deployer = ursula.get_deployer()
assert deployer.options['https_port'] == ursula.rest_interface().port
assert deployer.options['https_port'] == ursula.rest_interface.port
assert deployer.application == ursula.rest_app