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

Python tutils.tmpdir函数代码示例

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

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



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

示例1: test_write

 def test_write(self):
     with tutils.tmpdir() as d:
         p = os.path.join(d, "a")
         self.dummy_cycle(
             self.mkmaster(None, outfile=(p, "wb"), verbosity=0), 1, b""
         )
         assert len(list(flow.FlowReader(open(p, "rb")).stream())) == 1
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:7,代码来源:test_dump.py


示例2: test_with_ca

 def test_with_ca(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         r = certutils.dummy_cert(
             ca.default_privatekey, ca.default_ca, b"foo.com", [b"one.com", b"two.com", b"*.three.com"]
         )
         assert r.cn == b"foo.com"
开发者ID:tempbottle,项目名称:netlib,代码行数:7,代码来源:test_certutils.py


示例3: test_replay

    def test_replay(self):
        o = dump.Options(server_replay=["nonexistent"], kill=True)
        tutils.raises(dump.DumpError, dump.DumpMaster, None, o)

        with tutils.tmpdir() as t:
            p = os.path.join(t, "rep")
            self.flowfile(p)

            o = dump.Options(server_replay=[p], kill=True)
            o.verbosity = 0
            o.flow_detail = 0
            m = dump.DumpMaster(None, o)

            self.cycle(m, b"content")
            self.cycle(m, b"content")

            o = dump.Options(server_replay=[p], kill=False)
            o.verbosity = 0
            o.flow_detail = 0
            m = dump.DumpMaster(None, o)
            self.cycle(m, b"nonexistent")

            o = dump.Options(client_replay=[p], kill=False)
            o.verbosity = 0
            o.flow_detail = 0
            m = dump.DumpMaster(None, o)
开发者ID:DrakeCaraker,项目名称:mitmproxy,代码行数:26,代码来源:test_dump.py


示例4: test_sans

 def test_sans(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         c1 = ca.get_cert(b"foo.com", [b"*.bar.com"])
         ca.get_cert(b"foo.bar.com", [])
         # assert c1 == c2
         c3 = ca.get_cert(b"bar.com", [])
         assert not c1 == c3
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:8,代码来源:test_certutils.py


示例5: test_read

    def test_read(self):
        with tutils.tmpdir() as t:
            p = os.path.join(t, "read")
            self._flowfile(p)
            assert "GET" in self._dummy_cycle(0, None, "", flow_detail=1, rfile=p)

            tutils.raises(dump.DumpError, self._dummy_cycle, 0, None, "", verbosity=1, rfile="/nonexistent")
            tutils.raises(dump.DumpError, self._dummy_cycle, 0, None, "", verbosity=1, rfile="test_dump.py")
开发者ID:nask0,项目名称:mitmproxy,代码行数:8,代码来源:test_dump.py


示例6: test_create_tmp

    def test_create_tmp(self):
        with tutils.tmpdir() as d:
            ca = certutils.CertStore.from_store(d, "test")
            assert ca.get_cert(b"foo.com", [])
            assert ca.get_cert(b"foo.com", [])
            assert ca.get_cert(b"*.foo.com", [])

            r = ca.get_cert(b"*.foo.com", [])
            assert r[1] == ca.default_privatekey
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:9,代码来源:test_certutils.py


示例7: test_create_explicit

    def test_create_explicit(self):
        with tutils.tmpdir() as d:
            ca = certutils.CertStore.from_store(d, "test")
            assert ca.get_cert(b"foo", [])

            ca2 = certutils.CertStore.from_store(d, "test")
            assert ca2.get_cert(b"foo", [])

            assert ca.default_ca.get_serial_number() == ca2.default_ca.get_serial_number()
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:9,代码来源:test_certutils.py


示例8: test_overrides

    def test_overrides(self):
        with tutils.tmpdir() as d:
            ca1 = certutils.CertStore.from_store(os.path.join(d, "ca1"), "test")
            ca2 = certutils.CertStore.from_store(os.path.join(d, "ca2"), "test")
            assert not ca1.default_ca.get_serial_number() == ca2.default_ca.get_serial_number()

            dc = ca2.get_cert(b"foo.com", [b"sans.example.com"])
            dcp = os.path.join(d, "dc")
            f = open(dcp, "wb")
            f.write(dc[0].to_pem())
            f.close()
            ca1.add_cert_file(b"foo.com", dcp)

            ret = ca1.get_cert(b"foo.com", [])
            assert ret[0].serial == dc[0].serial
开发者ID:tempbottle,项目名称:netlib,代码行数:15,代码来源:test_certutils.py


示例9: test_log

    def test_log(self):
        testval = b"echo!\n"
        _logfun = tcp.log_ssl_key

        with tutils.tmpdir() as d:
            logfile = os.path.join(d, "foo", "bar", "logfile")
            tcp.log_ssl_key = tcp.SSLKeyLogger(logfile)

            c = tcp.TCPClient(("127.0.0.1", self.port))
            c.connect()
            c.convert_to_ssl()
            c.wfile.write(testval)
            c.wfile.flush()
            assert c.rfile.readline() == testval
            c.finish()

            tcp.log_ssl_key.close()
            with open(logfile, "rb") as f:
                assert f.read().count(b"CLIENT_RANDOM") == 2

        tcp.log_ssl_key = _logfun
开发者ID:bemre,项目名称:mitmproxy,代码行数:21,代码来源:test_tcp.py


示例10: test_replay

    def test_replay(self):
        cs = StringIO()

        o = dump.Options(server_replay=["nonexistent"], kill=True)
        tutils.raises(dump.DumpError, dump.DumpMaster, None, o, outfile=cs)

        with tutils.tmpdir() as t:
            p = os.path.join(t, "rep")
            self._flowfile(p)

            o = dump.Options(server_replay=[p], kill=True)
            m = dump.DumpMaster(None, o, outfile=cs)

            self._cycle(m, "content")
            self._cycle(m, "content")

            o = dump.Options(server_replay=[p], kill=False)
            m = dump.DumpMaster(None, o, outfile=cs)
            self._cycle(m, "nonexistent")

            o = dump.Options(client_replay=[p], kill=False)
            m = dump.DumpMaster(None, o, outfile=cs)
开发者ID:keithsun80,项目名称:mitmproxy,代码行数:22,代码来源:test_dump.py


示例11: test_expire

    def test_expire(self):
        with tutils.tmpdir() as d:
            ca = certutils.CertStore.from_store(d, "test")
            ca.STORE_CAP = 3
            ca.get_cert(b"one.com", [])
            ca.get_cert(b"two.com", [])
            ca.get_cert(b"three.com", [])

            assert (b"one.com", ()) in ca.certs
            assert (b"two.com", ()) in ca.certs
            assert (b"three.com", ()) in ca.certs

            ca.get_cert(b"one.com", [])

            assert (b"one.com", ()) in ca.certs
            assert (b"two.com", ()) in ca.certs
            assert (b"three.com", ()) in ca.certs

            ca.get_cert(b"four.com", [])

            assert (b"one.com", ()) not in ca.certs
            assert (b"two.com", ()) in ca.certs
            assert (b"three.com", ()) in ca.certs
            assert (b"four.com", ()) in ca.certs
开发者ID:mkagenius,项目名称:mitmproxy,代码行数:24,代码来源:test_certutils.py


示例12: test_sans_change

 def test_sans_change(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         ca.get_cert(b"foo.com", [b"*.bar.com"])
         cert, key, chain_file = ca.get_cert(b"foo.bar.com", [b"*.baz.com"])
         assert b"*.baz.com" in cert.altnames
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:6,代码来源:test_certutils.py


示例13: test_create_no_common_name

 def test_create_no_common_name(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         assert ca.get_cert(None, [])[0].cn is None
开发者ID:007durgesh219,项目名称:mitmproxy,代码行数:4,代码来源:test_certutils.py


示例14: test_write_append

 def test_write_append(self):
     with tutils.tmpdir() as d:
         p = os.path.join(d, "a.append")
         self._dummy_cycle(1, None, "", outfile=(p, "wb"), verbosity=0)
         self._dummy_cycle(1, None, "", outfile=(p, "ab"), verbosity=0)
         assert len(list(flow.FlowReader(open(p, "rb")).stream())) == 2
开发者ID:keithsun80,项目名称:mitmproxy,代码行数:6,代码来源:test_dump.py


示例15: test_create_dhparams

 def test_create_dhparams(self):
     with tutils.tmpdir() as d:
         filename = os.path.join(d, "dhparam.pem")
         certutils.CertStore.load_dhparam(filename)
         assert os.path.exists(filename)
开发者ID:bemre,项目名称:mitmproxy,代码行数:5,代码来源:test_tcp.py


示例16: test_add_cert

 def test_add_cert(self):
     with tutils.tmpdir() as d:
         certutils.CertStore.from_store(d, "test")
开发者ID:gsilverman-memeo-inc,项目名称:netlib,代码行数:3,代码来源:test_certutils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tutils.treader函数代码示例发布时间:2022-05-27
下一篇:
Python tutils.tflow函数代码示例发布时间: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