(
self, start_connection: Any, ClientRequestMock: Any
)
| 661 | spec_set=True, |
| 662 | ) |
| 663 | def test_https_connect_ssl_error( |
| 664 | self, start_connection: Any, ClientRequestMock: Any |
| 665 | ) -> None: |
| 666 | proxy_req = ClientRequest( |
| 667 | "GET", URL("http://proxy.example.com"), loop=self.loop |
| 668 | ) |
| 669 | ClientRequestMock.return_value = proxy_req |
| 670 | |
| 671 | proxy_resp = ClientResponse( |
| 672 | "get", |
| 673 | URL("http://proxy.example.com"), |
| 674 | request_info=mock.Mock(), |
| 675 | writer=None, |
| 676 | continue100=None, |
| 677 | timer=TimerNoop(), |
| 678 | traces=[], |
| 679 | loop=self.loop, |
| 680 | stream_writer=mock.create_autospec( |
| 681 | AbstractStreamWriter, spec_set=True, instance=True |
| 682 | ), |
| 683 | session=mock.Mock(), |
| 684 | ) |
| 685 | proxy_req.send = mock.AsyncMock(return_value=proxy_resp) |
| 686 | proxy_resp.start = mock.AsyncMock(return_value=mock.Mock(status=200)) |
| 687 | |
| 688 | async def make_conn(): |
| 689 | return aiohttp.TCPConnector() |
| 690 | |
| 691 | connector = self.loop.run_until_complete(make_conn()) |
| 692 | connector._resolve_host = mock.AsyncMock( |
| 693 | return_value=[ |
| 694 | { |
| 695 | "hostname": "hostname", |
| 696 | "host": "127.0.0.1", |
| 697 | "port": 80, |
| 698 | "family": socket.AF_INET, |
| 699 | "proto": 0, |
| 700 | "flags": 0, |
| 701 | } |
| 702 | ] |
| 703 | ) |
| 704 | |
| 705 | # Called on connection to http://proxy.example.com |
| 706 | self.loop.create_connection = mock.AsyncMock( |
| 707 | return_value=(mock.Mock(), mock.Mock()), |
| 708 | ) |
| 709 | # Called on connection to https://www.python.org |
| 710 | self.loop.start_tls = mock.AsyncMock(side_effect=ssl.SSLError) |
| 711 | |
| 712 | req = ClientRequest( |
| 713 | "GET", |
| 714 | URL("https://www.python.org"), |
| 715 | proxy=URL("http://proxy.example.com"), |
| 716 | loop=self.loop, |
| 717 | ) |
| 718 | with self.assertRaises(aiohttp.ClientConnectorSSLError): |
| 719 | self.loop.run_until_complete( |
| 720 | connector._create_connection(req, None, aiohttp.ClientTimeout()) |
nothing calls this directly
no test coverage detected