Ensure get_outbound_entity checks correctly for DiasporaRelayableMixin

merge-requests/130/head
Jason Robinson 2017-05-01 22:49:34 +03:00
rodzic 999c27cd5c
commit ac2eddf23e
2 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -206,7 +206,7 @@ def get_outbound_entity(entity, private_key):
outbound = DiasporaRetraction.from_base(entity)
if not outbound:
raise ValueError("Don't know how to convert this base entity to Diaspora protocol entities.")
if issubclass(cls, DiasporaRelayableMixin) and not outbound.signature:
if isinstance(outbound, DiasporaRelayableMixin) and not outbound.signature:
# Sign by author if not signed yet. We don't want to overwrite any existing signature in the case
# that this is being sent by the parent author
outbound.sign(private_key)

Wyświetl plik

@ -221,3 +221,9 @@ class TestGetOutboundEntity(object):
def test_retraction_is_converted_to_diasporaretraction(self):
entity = Retraction()
assert isinstance(get_outbound_entity(entity, get_dummy_private_key()), DiasporaRetraction)
def test_signs_relayable_if_no_signature(self):
entity = DiasporaComment()
dummy_key = get_dummy_private_key()
outbound = get_outbound_entity(entity, dummy_key)
assert outbound.signature != ""