(self)
| 666 | self.assertEqual(timeout, ss.gettimeout()) |
| 667 | |
| 668 | def test_openssl111_deprecations(self): |
| 669 | options = [ |
| 670 | ssl.OP_NO_TLSv1, |
| 671 | ssl.OP_NO_TLSv1_1, |
| 672 | ssl.OP_NO_TLSv1_2, |
| 673 | ssl.OP_NO_TLSv1_3 |
| 674 | ] |
| 675 | protocols = [] |
| 676 | if hasattr(ssl, 'PROTOCOL_TLSv1'): |
| 677 | protocols.append(ssl.PROTOCOL_TLSv1) |
| 678 | if hasattr(ssl, 'PROTOCOL_TLSv1_1'): |
| 679 | protocols.append(ssl.PROTOCOL_TLSv1_1) |
| 680 | if hasattr(ssl, 'PROTOCOL_TLSv1_2'): |
| 681 | protocols.append(ssl.PROTOCOL_TLSv1_2) |
| 682 | protocols.append(ssl.PROTOCOL_TLS) |
| 683 | versions = [ |
| 684 | ssl.TLSVersion.SSLv3, |
| 685 | ssl.TLSVersion.TLSv1, |
| 686 | ssl.TLSVersion.TLSv1_1, |
| 687 | ] |
| 688 | |
| 689 | for option in options: |
| 690 | with self.subTest(option=option): |
| 691 | ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 692 | with self.assertWarns(DeprecationWarning) as cm: |
| 693 | ctx.options |= option |
| 694 | self.assertEqual( |
| 695 | 'ssl.OP_NO_SSL*/ssl.OP_NO_TLS* options are deprecated', |
| 696 | str(cm.warning) |
| 697 | ) |
| 698 | |
| 699 | for protocol in protocols: |
| 700 | if not has_tls_protocol(protocol): |
| 701 | continue |
| 702 | with self.subTest(protocol=protocol): |
| 703 | with self.assertWarns(DeprecationWarning) as cm: |
| 704 | ssl.SSLContext(protocol) |
| 705 | self.assertEqual( |
| 706 | f'ssl.{protocol.name} is deprecated', |
| 707 | str(cm.warning) |
| 708 | ) |
| 709 | |
| 710 | for version in versions: |
| 711 | if not has_tls_version(version): |
| 712 | continue |
| 713 | with self.subTest(version=version): |
| 714 | ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 715 | with self.assertWarns(DeprecationWarning) as cm: |
| 716 | ctx.minimum_version = version |
| 717 | version_text = '%s.%s' % (version.__class__.__name__, version.name) |
| 718 | self.assertEqual( |
| 719 | f'ssl.{version_text} is deprecated', |
| 720 | str(cm.warning) |
| 721 | ) |
| 722 | |
| 723 | def bad_cert_test(self, certfile): |
| 724 | """Check that trying to use the given client certificate fails""" |
nothing calls this directly
no test coverage detected