Beispiel #1
0
def test_tcp(tmpdir):
    sa = streamfile.StreamFile()
    with taddons.context() as tctx:
        p = str(tmpdir.join("foo"))
        tctx.configure(sa, streamfile=p)

        tt = tflow.ttcpflow()
        sa.tcp_start(tt)
        sa.tcp_end(tt)
        tctx.configure(sa, streamfile=None)
        assert rd(p)
Beispiel #2
0
def test_configure(tmpdir):
    sa = streamfile.StreamFile()
    with taddons.context(options=options.Options()) as tctx:
        with pytest.raises(exceptions.OptionsError):
            tctx.configure(sa, streamfile=str(tmpdir))
        with pytest.raises(Exception, match="Invalid filter"):
            tctx.configure(sa, streamfile=str(tmpdir.join("foo")), filtstr="~~")
        tctx.configure(sa, filtstr="foo")
        assert sa.filt
        tctx.configure(sa, filtstr=None)
        assert not sa.filt
Beispiel #3
0
def test_tcp():
    sa = streamfile.StreamFile()
    with taddons.context() as tctx:
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")
            tctx.configure(sa, streamfile=p)

            tt = tflow.ttcpflow()
            sa.tcp_start(tt)
            sa.tcp_end(tt)
            tctx.configure(sa, streamfile=None)
            assert rd(p)
Beispiel #4
0
def test_configure():
    sa = streamfile.StreamFile()
    with taddons.context(options=options.Options()) as tctx:
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")
            with pytest.raises(exceptions.OptionsError):
                tctx.configure(sa, streamfile=tdir)
            with pytest.raises(Exception, match="Invalid filter"):
                tctx.configure(sa, streamfile=p, filtstr="~~")
            tctx.configure(sa, filtstr="foo")
            assert sa.filt
            tctx.configure(sa, filtstr=None)
            assert not sa.filt
Beispiel #5
0
def test_configure():
    sa = streamfile.StreamFile()
    with taddons.context(options=dump.Options()) as tctx:
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")
            tutils.raises(
                exceptions.OptionsError,
                tctx.configure, sa, streamfile=tdir
            )
            tutils.raises(
                "invalid filter",
                tctx.configure, sa, streamfile=p, filtstr="~~"
            )
Beispiel #6
0
def default_addons():
    return [
        onboarding.Onboarding(),
        proxyauth.ProxyAuth(),
        anticache.AntiCache(),
        anticomp.AntiComp(),
        stickyauth.StickyAuth(),
        stickycookie.StickyCookie(),
        script.ScriptLoader(),
        streamfile.StreamFile(),
        streambodies.StreamBodies(),
        replace.Replace(),
        setheaders.SetHeaders(),
        serverplayback.ServerPlayback(),
        clientplayback.ClientPlayback(),
        upstream_auth.UpstreamAuth(),
    ]
Beispiel #7
0
def test_simple(tmpdir):
    sa = streamfile.StreamFile()
    with taddons.context() as tctx:
        p = str(tmpdir.join("foo"))

        tctx.configure(sa, streamfile=p)

        f = tflow.tflow(resp=True)
        sa.request(f)
        sa.response(f)
        tctx.configure(sa, streamfile=None)
        assert rd(p)[0].response

        tctx.configure(sa, streamfile="+" + p)
        f = tflow.tflow()
        sa.request(f)
        tctx.configure(sa, streamfile=None)
        assert not rd(p)[1].response
Beispiel #8
0
def test_simple():
    sa = streamfile.StreamFile()
    with taddons.context() as tctx:
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")

            tctx.configure(sa, streamfile=p)

            f = tflow.tflow(resp=True)
            sa.request(f)
            sa.response(f)
            tctx.configure(sa, streamfile=None)
            assert rd(p)[0].response

            tctx.configure(sa, streamfile=p, streamfile_append=True)
            f = tflow.tflow()
            sa.request(f)
            tctx.configure(sa, streamfile=None)
            assert not rd(p)[1].response
Beispiel #9
0
def default_addons():
    return [
        core_option_validation.CoreOptionValidation(),
        anticache.AntiCache(),
        anticomp.AntiComp(),
        check_alpn.CheckALPN(),
        check_ca.CheckCA(),
        clientplayback.ClientPlayback(),
        disable_h2c.DisableH2C(),
        onboarding.Onboarding(),
        proxyauth.ProxyAuth(),
        replace.Replace(),
        script.ScriptLoader(),
        serverplayback.ServerPlayback(),
        setheaders.SetHeaders(),
        stickyauth.StickyAuth(),
        stickycookie.StickyCookie(),
        streambodies.StreamBodies(),
        streamfile.StreamFile(),
        upstream_auth.UpstreamAuth(),
    ]