If a certificate has two subject alternative names, cryptography raises an x509.DuplicateExtension exception.
(self, mock_warning: mock.MagicMock)
| 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) |
nothing calls this directly
no test coverage detected