本文整理汇总了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;未经允许,请勿转载。 |
请发表评论