当前位置: 首页>>代码示例>>Python>>正文


Python iweb.IPolicyForHTTPS方法代码示例

本文整理汇总了Python中twisted.web.iweb.IPolicyForHTTPS方法的典型用法代码示例。如果您正苦于以下问题:Python iweb.IPolicyForHTTPS方法的具体用法?Python iweb.IPolicyForHTTPS怎么用?Python iweb.IPolicyForHTTPS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.iweb的用法示例。


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

示例1: test_deprecatedDuckPolicy

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def test_deprecatedDuckPolicy(self):
        """
        Passing something that duck-types I{like} a L{web client context
        factory <twisted.web.client.WebClientContextFactory>} - something that
        does not provide L{IPolicyForHTTPS} - to L{Agent} emits a
        L{DeprecationWarning} even if you don't actually C{import
        WebClientContextFactory} to do it.
        """
        def warnMe():
            client.Agent(MemoryReactorClock(),
                         "does-not-provide-IPolicyForHTTPS")
        warnMe()
        warnings = self.flushWarnings([warnMe])
        self.assertEqual(len(warnings), 1)
        [warning] = warnings
        self.assertEqual(warning['category'], DeprecationWarning)
        self.assertEqual(
            warning['message'],
            "'does-not-provide-IPolicyForHTTPS' was passed as the HTTPS "
            "policy for an Agent, but it does not provide IPolicyForHTTPS.  "
            "Since Twisted 14.0, you must pass a provider of IPolicyForHTTPS."
        ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_agent.py

示例2: integrationTest

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def integrationTest(self, hostName, expectedAddress, addressType):
        """
        Wrap L{AgentTestsMixin.integrationTest} with TLS.
        """
        authority, server = certificatesForAuthorityAndServer(hostName
                                                              .decode('ascii'))
        def tlsify(serverFactory):
            return TLSMemoryBIOFactory(server.options(), False, serverFactory)
        def tlsagent(reactor):
            from twisted.web.iweb import IPolicyForHTTPS
            from zope.interface import implementer
            @implementer(IPolicyForHTTPS)
            class Policy(object):
                def creatorForNetloc(self, hostname, port):
                    return optionsForClientTLS(hostname.decode("ascii"),
                                               trustRoot=authority)
            return client.Agent(reactor, contextFactory=Policy())
        (super(AgentHTTPSTests, self)
         .integrationTest(hostName, expectedAddress, addressType,
                          serverWrapper=tlsify,
                          createAgent=tlsagent,
                          scheme=b'https')) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_agent.py

示例3: test_deprecatedDuckPolicy

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def test_deprecatedDuckPolicy(self):
        """
        Passing something that duck-types I{like} a L{web client context
        factory <twisted.web.client.WebClientContextFactory>} - something that
        does not provide L{IPolicyForHTTPS} - to L{Agent} emits a
        L{DeprecationWarning} even if you don't actually C{import
        WebClientContextFactory} to do it.
        """
        def warnMe():
            client.Agent(deterministicResolvingReactor(MemoryReactorClock()),
                         "does-not-provide-IPolicyForHTTPS")
        warnMe()
        warnings = self.flushWarnings([warnMe])
        self.assertEqual(len(warnings), 1)
        [warning] = warnings
        self.assertEqual(warning['category'], DeprecationWarning)
        self.assertEqual(
            warning['message'],
            "'does-not-provide-IPolicyForHTTPS' was passed as the HTTPS "
            "policy for an Agent, but it does not provide IPolicyForHTTPS.  "
            "Since Twisted 14.0, you must pass a provider of IPolicyForHTTPS."
        ) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:test_agent.py

示例4: integrationTest

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def integrationTest(self, hostName, expectedAddress, addressType):
        """
        Wrap L{AgentTestsMixin.integrationTest} with TLS.
        """
        certHostName = hostName.strip(b'[]')
        authority, server = certificatesForAuthorityAndServer(certHostName
                                                              .decode('ascii'))
        def tlsify(serverFactory):
            return TLSMemoryBIOFactory(server.options(), False, serverFactory)
        def tlsagent(reactor):
            from twisted.web.iweb import IPolicyForHTTPS
            from zope.interface import implementer
            @implementer(IPolicyForHTTPS)
            class Policy(object):
                def creatorForNetloc(self, hostname, port):
                    return optionsForClientTLS(hostname.decode("ascii"),
                                               trustRoot=authority)
            return client.Agent(reactor, contextFactory=Policy())
        (super(AgentHTTPSTests, self)
         .integrationTest(hostName, expectedAddress, addressType,
                          serverWrapper=tlsify,
                          createAgent=tlsagent,
                          scheme=b'https')) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:25,代码来源:test_agent.py

示例5: client_SSLCF

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def client_SSLCF(self, certfile):
        """Return an IPolicyForHTTPS for verifiying tests' server cert.

        Optionally configures a client cert.

        """
        from twisted.internet.ssl import (
            Certificate, PrivateCertificate, optionsForClientTLS)
        from twisted.web.iweb import IPolicyForHTTPS

        with open(self.servercert) as fp:
            servercert = Certificate.loadPEM(fp.read())
        if certfile:
            with open(self.unauth_client) as fp:
                unauth_client = PrivateCertificate.loadPEM(fp.read())
        else:
            unauth_client = None

        @implementer(IPolicyForHTTPS)
        class UnauthClientPolicyForHTTPS(object):
            def creatorForNetloc(self, hostname, port):
                return optionsForClientTLS(
                    hostname.decode('ascii'),
                    trustRoot=servercert,
                    clientCertificate=unauth_client)
        return UnauthClientPolicyForHTTPS() 
开发者ID:mozilla-services,项目名称:autopush,代码行数:28,代码来源:test_integration.py

示例6: creatorForNetloc

# 需要导入模块: from twisted.web import iweb [as 别名]
# 或者: from twisted.web.iweb import IPolicyForHTTPS [as 别名]
def creatorForNetloc(self, hostname, port):
        """Implements the IPolicyForHTTPS interace so that this can be passed
        directly to agents.
        """
        return self.get_options(hostname) 
开发者ID:matrix-org,项目名称:sygnal,代码行数:7,代码来源:context_factory.py


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