fixup coverage

This commit is contained in:
Maximilian Hils 2021-03-07 22:35:53 +01:00
parent d6cd1489d6
commit e2772f3eec
2 changed files with 18 additions and 2 deletions

View File

@ -26,10 +26,10 @@ class DestinationKnown(layer.Layer, metaclass=ABCMeta):
if self.context.options.connection_strategy == "eager": if self.context.options.connection_strategy == "eager":
err = yield commands.OpenConnection(self.context.server) err = yield commands.OpenConnection(self.context.server)
if err: if err:
self._handle_event = self.done self._handle_event = self.done # type: ignore
return err return err
self._handle_event = self.child_layer.handle_event self._handle_event = self.child_layer.handle_event # type: ignore
yield from self.child_layer.handle_event(events.Start()) yield from self.child_layer.handle_event(events.Start())
return None return None

View File

@ -276,6 +276,22 @@ def test_reverse_eager_connect_failure(tctx: Context):
) )
def test_transparent_eager_connect_failure(tctx: Context, monkeypatch):
"""Test that we recover from a transparent mode resolve error."""
tctx.options.connection_strategy = "eager"
monkeypatch.setattr(platform, "original_addr", lambda sock: ("address", 22))
assert (
Playbook(modes.TransparentProxy(tctx), logs=True)
<< GetSocket(tctx.client)
>> reply(object())
<< OpenConnection(tctx.server)
>> reply("something something")
<< CloseConnection(tctx.client)
>> ConnectionClosed(tctx.client)
)
CLIENT_HELLO = b"\x05\x01\x00" CLIENT_HELLO = b"\x05\x01\x00"
SERVER_HELLO = b"\x05\x00" SERVER_HELLO = b"\x05\x00"