• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tutils.tflow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中netlib.tutils.tflow函数的典型用法代码示例。如果您正苦于以下问题:Python tflow函数的具体用法?Python tflow怎么用?Python tflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tflow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_ignore_payload_params

    def test_ignore_payload_params(self):
        s = serverplayback.ServerPlayback()
        s.configure(
            options.Options(
                server_replay_ignore_payload_params=["param1", "param2"]
            ),
            []
        )

        r = tutils.tflow(resp=True)
        r.request.headers["Content-Type"] = "application/x-www-form-urlencoded"
        r.request.content = b"paramx=x&param1=1"
        r2 = tutils.tflow(resp=True)
        r2.request.headers["Content-Type"] = "application/x-www-form-urlencoded"
        r2.request.content = b"paramx=x&param1=1"
        # same parameters
        assert s._hash(r) == s._hash(r2)
        # ignored parameters !=
        r2.request.content = b"paramx=x&param1=2"
        assert s._hash(r) == s._hash(r2)
        # missing parameter
        r2.request.content = b"paramx=x"
        assert s._hash(r) == s._hash(r2)
        # ignorable parameter added
        r2.request.content = b"paramx=x&param1=2"
        assert s._hash(r) == s._hash(r2)
        # not ignorable parameter changed
        r2.request.content = b"paramx=y&param1=1"
        assert not s._hash(r) == s._hash(r2)
        # not ignorable parameter missing
        r2.request.content = b"param1=1"
        assert not s._hash(r) == s._hash(r2)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:32,代码来源:test_serverplayback.py


示例2: test_ignore_content

    def test_ignore_content(self):
        s = serverplayback.ServerPlayback()
        s.configure(options.Options(server_replay_ignore_content=False), [])

        r = tutils.tflow(resp=True)
        r2 = tutils.tflow(resp=True)

        r.request.content = b"foo"
        r2.request.content = b"foo"
        assert s._hash(r) == s._hash(r2)
        r2.request.content = b"bar"
        assert not s._hash(r) == s._hash(r2)

        s.configure(options.Options(server_replay_ignore_content=True), [])
        r = tutils.tflow(resp=True)
        r2 = tutils.tflow(resp=True)
        r.request.content = b"foo"
        r2.request.content = b"foo"
        assert s._hash(r) == s._hash(r2)
        r2.request.content = b"bar"
        assert s._hash(r) == s._hash(r2)
        r2.request.content = b""
        assert s._hash(r) == s._hash(r2)
        r2.request.content = None
        assert s._hash(r) == s._hash(r2)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:25,代码来源:test_serverplayback.py


示例3: test_server_playback_full

    def test_server_playback_full(self):
        state = flow.State()
        s = serverplayback.ServerPlayback()
        o = options.Options(refresh_server_playback = True, keepserving=False)
        m = mastertest.RecordingMaster(o, None, state)
        m.addons.add(s)

        f = tutils.tflow()
        f.response = netlib.tutils.tresp(content=f.request.content)
        s.load([f, f])

        tf = tutils.tflow()
        assert not tf.response
        m.request(tf)
        assert tf.response == f.response

        tf = tutils.tflow()
        tf.request.content = b"gibble"
        assert not tf.response
        m.request(tf)
        assert not tf.response

        assert not s.stop
        s.tick()
        assert not s.stop

        tf = tutils.tflow()
        m.request(tutils.tflow())
        assert s.stop
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:29,代码来源:test_serverplayback.py


示例4: test_ignore_host

    def test_ignore_host(self):
        sp = serverplayback.ServerPlayback()
        sp.configure(options.Options(server_replay_ignore_host=True), [])

        r = tutils.tflow(resp=True)
        r2 = tutils.tflow(resp=True)

        r.request.host = "address"
        r2.request.host = "address"
        assert sp._hash(r) == sp._hash(r2)
        r2.request.host = "wrong_address"
        assert sp._hash(r) == sp._hash(r2)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:12,代码来源:test_serverplayback.py


示例5: test_server_playback_kill

    def test_server_playback_kill(self):
        state = flow.State()
        s = serverplayback.ServerPlayback()
        o = options.Options(refresh_server_playback = True, replay_kill_extra=True)
        m = mastertest.RecordingMaster(o, None, state)
        m.addons.add(s)

        f = tutils.tflow()
        f.response = netlib.tutils.tresp(content=f.request.content)
        s.load([f])

        f = tutils.tflow()
        f.request.host = "nonexistent"
        m.request(f)
        assert f.reply.value == exceptions.Kill
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:15,代码来源:test_serverplayback.py


示例6: test_load_with_server_replay_nopop

    def test_load_with_server_replay_nopop(self):
        s = serverplayback.ServerPlayback()
        s.configure(options.Options(server_replay_nopop=True), [])

        r = tutils.tflow(resp=True)
        r.request.headers["key"] = "one"

        r2 = tutils.tflow(resp=True)
        r2.request.headers["key"] = "two"

        s.load([r, r2])

        assert s.count() == 2
        s.next_flow(r)
        assert s.count() == 2
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:15,代码来源:test_serverplayback.py


示例7: test_post_json

    def test_post_json(self):
        req_post.content = '{"name": "example", "email": "[email protected]"}'
        req_post.headers = Headers(content_type="application/json")
        flow = tutils.tflow(req=req_post)
        result = dedent("""
            import requests

            url = 'http://address/path'

            headers = {
                'content-type': 'application/json',
            }

            json = {
                "name": "example",
                "email": "[email protected]"
            }

            response = requests.request(
                method='POST',
                url=url,
                headers=headers,
                json=json,
            )

            print(response.text)
        """).strip()
        assert flow_export.python_code(flow) == result
开发者ID:NoneNotNull,项目名称:mitmproxy,代码行数:28,代码来源:test_flow_export.py


示例8: test_patch

    def test_patch(self):
        flow = tutils.tflow(req=req_patch)
        result = '    ' + """
    @task()
    def path(self):
        url = self.locust.host + '/path'
        
        headers = {
            'header': 'qvalue',
            'content-length': '7',
        }

        params = {
            'query': 'param',
        }

        data = '''content'''

        self.response = self.client.request(
            method='PATCH',
            url=url,
            headers=headers,
            params=params,
            data=data,
        )
        """.strip() + '\n'

        assert flow_export.locust_task(flow) == result
开发者ID:EdSchroedinger,项目名称:mitmproxy,代码行数:28,代码来源:test_flow_export.py


示例9: test_patch

    def test_patch(self):
        flow = tutils.tflow(req=req_patch)
        result = dedent("""
            import requests

            url = 'http://address/path'

            headers = {
                'header': 'qvalue',
                'content-length': '7',
            }

            params = {
                'query': 'param',
            }

            data = '''content'''

            response = requests.request(
                method='PATCH',
                url=url,
                headers=headers,
                params=params,
                data=data,
            )

            print(response.text)
        """).strip()
        assert flow_export.python_code(flow) == result
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:29,代码来源:test_flow_export.py


示例10: test_headers

    def test_headers(self):
        s = serverplayback.ServerPlayback()
        s.configure(options.Options(server_replay_use_headers=["foo"]), [])

        r = tutils.tflow(resp=True)
        r.request.headers["foo"] = "bar"
        r2 = tutils.tflow(resp=True)
        assert not s._hash(r) == s._hash(r2)
        r2.request.headers["foo"] = "bar"
        assert s._hash(r) == s._hash(r2)
        r2.request.headers["oink"] = "bar"
        assert s._hash(r) == s._hash(r2)

        r = tutils.tflow(resp=True)
        r2 = tutils.tflow(resp=True)
        assert s._hash(r) == s._hash(r2)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:16,代码来源:test_serverplayback.py


示例11: test_post

    def test_post(self):
        req_post.content = '''content'''
        req_post.headers = ''
        flow = tutils.tflow(req=req_post)
        result = """
from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    def on_start(self):
        ''' on_start is called when a Locust start before any task is scheduled '''
        self.path()

    @task()
    def path(self):
        url = self.locust.host + '/path'
        
        data = '''content'''

        self.response = self.client.request(
            method='POST',
            url=url,
            data=data,
        )

    ### Additional tasks can go here ###


class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 1000
    max_wait = 3000

        """.strip()

        assert flow_export.locust_code(flow) == result
开发者ID:EdSchroedinger,项目名称:mitmproxy,代码行数:35,代码来源:test_flow_export.py


示例12: test_contentview

def test_contentview(get_content_view):
    get_content_view.side_effect = ContentViewException(""), ("x", iter([]))

    o = dump.Options(flow_detail=4, verbosity=3)
    m = dump.DumpMaster(None, o, StringIO())
    m.echo_flow(tutils.tflow())
    assert "Content viewer failed" in m.outfile.getvalue()
开发者ID:keithsun80,项目名称:mitmproxy,代码行数:7,代码来源:test_dump.py


示例13: test_get

    def test_get(self):
        flow = tutils.tflow(req=req_get)
        result = """
from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    def on_start(self):
        ''' on_start is called when a Locust start before any task is scheduled '''
        self.path()

    @task()
    def path(self):
        url = self.locust.host + '/path'
        
        headers = {
            'header': 'qvalue',
            'content-length': '7',
        }

        self.response = self.client.request(
            method='GET',
            url=url,
            headers=headers,
        )

    ### Additional tasks can go here ###


class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 1000
    max_wait = 3000
        """.strip()

        assert flow_export.locust_code(flow) == result
开发者ID:EdSchroedinger,项目名称:mitmproxy,代码行数:35,代码来源:test_flow_export.py


示例14: test_hash

    def test_hash(self):
        s = serverplayback.ServerPlayback()
        s.configure(options.Options(), [])

        r = tutils.tflow()
        r2 = tutils.tflow()

        assert s._hash(r)
        assert s._hash(r) == s._hash(r2)
        r.request.headers["foo"] = "bar"
        assert s._hash(r) == s._hash(r2)
        r.request.path = "voing"
        assert s._hash(r) != s._hash(r2)

        r.request.path = "path?blank_value"
        r2.request.path = "path?"
        assert s._hash(r) != s._hash(r2)
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:17,代码来源:test_serverplayback.py


示例15: test_error

 def test_error(self):
     cs = StringIO()
     o = dump.Options(flow_detail=1)
     m = dump.DumpMaster(None, o, outfile=cs)
     f = tutils.tflow(err=True)
     m.handle_request(f)
     assert m.handle_error(f)
     assert "error" in cs.getvalue()
开发者ID:keithsun80,项目名称:mitmproxy,代码行数:8,代码来源:test_dump.py


示例16: test_post

 def test_post(self):
     flow = tutils.tflow(req=req_post)
     result = dedent("""
         POST /path HTTP/1.1\r
         host: address:22\r
         \r
         content
     """).strip()
     assert flow_export.raw_request(flow) == result
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:9,代码来源:test_flow_export.py


示例17: test_get

 def test_get(self):
     flow = tutils.tflow(req=req_get)
     result = dedent("""
         GET /path HTTP/1.1\r
         header: qvalue\r
         content-length: 7\r
         host: address:22\r
         \r
     """).strip(" ").lstrip()
     assert flow_export.raw_request(flow) == result
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:10,代码来源:test_flow_export.py


示例18: test_error

 def test_error(self):
     o = dump.Options(
         tfile=StringIO(),
         flow_detail=1
     )
     m = dump.DumpMaster(None, o)
     f = tutils.tflow(err=True)
     m.request(f)
     assert m.error(f)
     assert "error" in o.tfile.getvalue()
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:10,代码来源:test_dump.py


示例19: test_post

 def test_post(self):
     flow = tutils.tflow(req=req_post)
     result = dedent("""
         POST /path HTTP/1.1\r
         content-type: application/json\r
         host: address:22\r
         \r
         {"name": "example", "email": "[email protected]"}
     """).strip()
     assert flow_export.raw_request(flow) == result
开发者ID:NoneNotNull,项目名称:mitmproxy,代码行数:10,代码来源:test_flow_export.py


示例20: test_server_playback

    def test_server_playback(self):
        sp = serverplayback.ServerPlayback()
        sp.configure(options.Options(), [])
        f = tutils.tflow(resp=True)

        assert not sp.flowmap

        sp.load([f])
        assert sp.flowmap
        assert sp.next_flow(f)
        assert not sp.flowmap
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:11,代码来源:test_serverplayback.py



注:本文中的netlib.tutils.tflow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tutils.tmpdir函数代码示例发布时间:2022-05-27
下一篇:
Python tutils.raises函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap