fix tests

This commit is contained in:
Maximilian Hils 2021-06-14 12:11:57 +02:00
parent fa6e8f1e9c
commit 76f0b8f65e
6 changed files with 11 additions and 5 deletions

View File

@ -102,6 +102,7 @@ with outfile.open("w") as f, contextlib.redirect_stdout(f):
http.HttpResponseHook,
http.HttpErrorHook,
http.HttpConnectHook,
http.HttpConnectUpstreamHook,
]
)

View File

@ -20,7 +20,7 @@ from ._base import HttpCommand, HttpConnection, ReceiveHttp, StreamId
from ._events import HttpEvent, RequestData, RequestEndOfMessage, RequestHeaders, RequestProtocolError, RequestTrailers, \
ResponseData, ResponseEndOfMessage, ResponseHeaders, ResponseProtocolError, ResponseTrailers
from ._hooks import HttpConnectHook, HttpErrorHook, HttpRequestHeadersHook, HttpRequestHook, HttpResponseHeadersHook, \
HttpResponseHook
HttpResponseHook, HttpConnectUpstreamHook # noqa
from ._http1 import Http1Client, Http1Connection, Http1Server
from ._http2 import Http2Client, Http2Server
from ...context import Context

View File

@ -34,6 +34,7 @@ class HttpUpstreamProxy(tunnel.TunnelLayer):
@classmethod
def make(cls, ctx: context.Context, send_connect: bool) -> tunnel.LayerStack:
spec = ctx.server.via
assert spec
assert spec.scheme in ("http", "https")
http_proxy = connection.Server(spec.address)

View File

@ -45,9 +45,8 @@ def test_simple():
f = tflow.tflow()
f.mode = "transparent"
up.requestheaders(f)
assert "proxy-authorization" in f.request.headers
assert "authorization" in f.request.headers
f = tflow.tflow()
f.mode = "upstream"
up.http_connect(f)
up.http_connect_upstream(f)
assert "proxy-authorization" in f.request.headers

View File

@ -266,3 +266,8 @@ def test_layer_stack(tctx):
stack /= b
assert stack[0] == a
assert a.child_layer is b
stack2 = tunnel.LayerStack()
stack2 /= TChildLayer(tctx)
stack2 /= stack
assert stack2[0].child_layer is a # type: ignore

View File

@ -11,7 +11,7 @@ def test_mitmweb(event_loop, tdata):
main.mitmweb([
"--no-web-open-browser",
"-s", tdata.path(shutdown_script),
"-q", "-p", "0",
"-q", "-p", "0", "--web-port", "0",
])