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

Python ssl_.ssl_wrap_socket函数代码示例

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

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



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

示例1: test_ssl_wrap_socket_loads_certificate_directories

 def test_ssl_wrap_socket_loads_certificate_directories(self):
     socket = object()
     mock_context = Mock()
     ssl_wrap_socket(ssl_context=mock_context, ca_cert_dir='/path/to/pems',
                     sock=socket)
     mock_context.load_verify_locations.assert_called_once_with(
         None, '/path/to/pems')
开发者ID:Lukasa,项目名称:urllib3,代码行数:7,代码来源:test_util.py


示例2: test_ssl_wrap_socket_loads_verify_locations

 def test_ssl_wrap_socket_loads_verify_locations(self):
     socket = object()
     mock_context = Mock()
     ssl_wrap_socket(ssl_context=mock_context, ca_certs='/path/to/pem',
                     sock=socket)
     mock_context.load_verify_locations.assert_called_once_with(
         '/path/to/pem', None)
开发者ID:Lukasa,项目名称:urllib3,代码行数:7,代码来源:test_util.py


示例3: test_ssl_wrap_socket_creates_new_context

    def test_ssl_wrap_socket_creates_new_context(self,
                                                 create_urllib3_context):
        socket = object()
        ssl_wrap_socket(sock=socket, cert_reqs='CERT_REQUIRED')

        create_urllib3_context.assert_called_once_with(
            None, 'CERT_REQUIRED', ciphers=None
        )
开发者ID:encodeltd,项目名称:urllib3,代码行数:8,代码来源:test_util.py


示例4: test_ssl_wrap_socket_loads_the_cert_chain

    def test_ssl_wrap_socket_loads_the_cert_chain(self):
        socket = object()
        mock_context = Mock()
        ssl_wrap_socket(ssl_context=mock_context, sock=socket,
                        certfile='/path/to/certfile')

        mock_context.load_cert_chain.assert_called_once_with(
            '/path/to/certfile', None)
开发者ID:Lukasa,项目名称:urllib3,代码行数:8,代码来源:test_util.py


示例5: test_ssl_wrap_socket_with_no_sni

 def test_ssl_wrap_socket_with_no_sni(self):
     socket = object()
     mock_context = Mock()
     # Ugly preservation of original value
     HAS_SNI = ssl_.HAS_SNI
     ssl_.HAS_SNI = False
     ssl_wrap_socket(ssl_context=mock_context, sock=socket)
     mock_context.wrap_socket.assert_called_once_with(socket)
     ssl_.HAS_SNI = HAS_SNI
开发者ID:Lukasa,项目名称:urllib3,代码行数:9,代码来源:test_util.py


示例6: test_context_sni_with_ip_address

def test_context_sni_with_ip_address(monkeypatch, has_sni, server_hostname, uses_sni):
    monkeypatch.setattr(ssl_, 'HAS_SNI', has_sni)

    sock = mock.Mock()
    context = mock.create_autospec(ssl_.SSLContext)

    ssl_.ssl_wrap_socket(sock, server_hostname=server_hostname, ssl_context=context)

    if uses_sni:
        context.wrap_socket.assert_called_with(sock, server_hostname=server_hostname)
    else:
        context.wrap_socket.assert_called_with(sock)
开发者ID:christophermca,项目名称:dotfiles,代码行数:12,代码来源:test_ssl.py


示例7: test_ssl_wrap_socket_with_no_sni_warns

 def test_ssl_wrap_socket_with_no_sni_warns(self):
     socket = object()
     mock_context = Mock()
     # Ugly preservation of original value
     HAS_SNI = ssl_.HAS_SNI
     ssl_.HAS_SNI = False
     with patch('warnings.warn') as warn:
         ssl_wrap_socket(ssl_context=mock_context, sock=socket)
     mock_context.wrap_socket.assert_called_once_with(socket)
     ssl_.HAS_SNI = HAS_SNI
     self.assertTrue(warn.call_count >= 1)
     warnings = [call[0][1] for call in warn.call_args_list]
     self.assertTrue(SNIMissingWarning in warnings)
开发者ID:Lukasa,项目名称:urllib3,代码行数:13,代码来源:test_util.py


示例8: test_sni_missing_warning_with_ip_addresses

def test_sni_missing_warning_with_ip_addresses(monkeypatch, has_sni, server_hostname, should_warn):
    monkeypatch.setattr(ssl_, 'HAS_SNI', has_sni)

    sock = mock.Mock()
    context = mock.create_autospec(ssl_.SSLContext)

    with mock.patch('warnings.warn') as warn:
        ssl_.ssl_wrap_socket(sock, server_hostname=server_hostname, ssl_context=context)

    if should_warn:
        assert warn.call_count >= 1
        warnings = [call[0][1] for call in warn.call_args_list]
        assert SNIMissingWarning in warnings
    else:
        assert warn.call_count == 0
开发者ID:christophermca,项目名称:dotfiles,代码行数:15,代码来源:test_ssl.py


示例9: test_ssl_wrap_socket_with_no_sni_warns

 def test_ssl_wrap_socket_with_no_sni_warns(self):
     socket = object()
     mock_context = Mock()
     # Ugly preservation of original value
     HAS_SNI = ssl_.HAS_SNI
     ssl_.HAS_SNI = False
     try:
         with patch('warnings.warn') as warn:
             ssl_wrap_socket(ssl_context=mock_context, sock=socket,
                             server_hostname='www.google.com')
         mock_context.wrap_socket.assert_called_once_with(socket)
         assert warn.call_count >= 1
         warnings = [call[0][1] for call in warn.call_args_list]
         assert SNIMissingWarning in warnings
     finally:
         ssl_.HAS_SNI = HAS_SNI
开发者ID:encodeltd,项目名称:urllib3,代码行数:16,代码来源:test_util.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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