MCPcopy
hub / github.com/urllib3/urllib3 / test_get_subj_alt_name

Method test_get_subj_alt_name

test/contrib/test_pyopenssl.py:92–104  ·  view source on GitHub ↗

If a certificate has two subject alternative names, cryptography raises an x509.DuplicateExtension exception.

(self, mock_warning: mock.MagicMock)

Source from the content-addressed store, hash-verified

90
91 @mock.patch("urllib3.contrib.pyopenssl.log.warning")
92 def test_get_subj_alt_name(self, mock_warning: mock.MagicMock) -> None:
93 """
94 If a certificate has two subject alternative names, cryptography raises
95 an x509.DuplicateExtension exception.
96 """
97 path = os.path.join(os.path.dirname(__file__), "duplicate_san.pem")
98 with open(path) as fp:
99 cert = load_certificate(FILETYPE_PEM, fp.read())
100
101 assert get_subj_alt_name(cert) == []
102
103 assert mock_warning.call_count == 1
104 assert isinstance(mock_warning.call_args[0][1], x509.DuplicateExtension)

Callers

nothing calls this directly

Calls 2

get_subj_alt_nameFunction · 0.90
readMethod · 0.45

Tested by

no test coverage detected