Ejemplo n.º 1
0
 def test_handshake_timeout_negative(self):
     sslcontext = test_utils.dummy_ssl_context()
     app_proto = mock.Mock()
     waiter = mock.Mock()
     with self.assertRaisesRegex(ValueError, 'a positive number'):
         sslproto.SSLProtocol(self.loop, app_proto, sslcontext, waiter,
                              ssl_handshake_timeout=-10)
Ejemplo n.º 2
0
 def ssl_protocol(self, waiter=None):
     sslcontext = test_utils.dummy_ssl_context()
     app_proto = asyncio.Protocol()
     proto = sslproto.SSLProtocol(self.loop, app_proto, sslcontext, waiter)
     self.assertIs(proto._app_transport.get_protocol(), app_proto)
     self.addCleanup(proto._app_transport.close)
     return proto
Ejemplo n.º 3
0
    def test_open_connection_no_loop_ssl(self):
        with test_utils.run_test_server(use_ssl=True) as httpd:
            conn_fut = asyncio.open_connection(
                *httpd.address,
                ssl=test_utils.dummy_ssl_context(),
                loop=self.loop)

            self._basetest_open_connection_no_loop_ssl(conn_fut)
Ejemplo n.º 4
0
 def ssl_protocol(self, *, waiter=None, proto=None):
     sslcontext = test_utils.dummy_ssl_context()
     if proto is None:  # app protocol
         proto = asyncio.Protocol()
     ssl_proto = sslproto.SSLProtocol(self.loop, proto, sslcontext, waiter,
                                      ssl_handshake_timeout=0.1)
     self.assertIs(ssl_proto._app_transport.get_protocol(), proto)
     self.addCleanup(ssl_proto._app_transport.close)
     return ssl_proto
Ejemplo n.º 5
0
 def ssl_protocol(self, *, waiter=None, proto=None):
     sslcontext = test_utils.dummy_ssl_context()
     if proto is None:  # app protocol
         proto = asyncio.Protocol()
     ssl_proto = sslproto.SSLProtocol(self.loop,
                                      proto,
                                      sslcontext,
                                      waiter,
                                      ssl_handshake_timeout=0.1)
     self.assertIs(ssl_proto._app_transport.get_protocol(), proto)
     self.addCleanup(ssl_proto._app_transport.close)
     return ssl_proto
Ejemplo n.º 6
0
        async def inner(httpd):
            reader, writer = await asyncio.open_connection(
                *httpd.address,
                ssl=test_utils.dummy_ssl_context())

            messages = []
            self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
            writer.write(b'GET / HTTP/1.0\r\n\r\n')
            data = await reader.read()
            self.assertTrue(data.endswith(b'\r\n\r\nTest message'))

            writer.close()
            with self.assertRaises(ConnectionResetError):
                await writer.drain()

            self.assertEqual(messages, [])
Ejemplo n.º 7
0
    def test_open_connection_no_loop_ssl(self):
        with test_utils.run_test_server(use_ssl=True) as httpd:
            conn_fut = asyncio.open_connection(
                *httpd.address, ssl=test_utils.dummy_ssl_context())

            self._basetest_open_connection_no_loop_ssl(conn_fut)