Exemplo n.º 1
0
 def test_ssl_handshake_none_sslobj(self):
     link = snakemq.link.Link()
     sock = mock.Mock()
     sock.sock._sslobj = None
     link._in_ssl_handshake.add(sock)
     link.poller = mock.Mock()
     self.assertEqual(link.ssl_handshake(sock), snakemq.link.SSL_HANDSHAKE_FAILED)
     self.assertNotIn(sock, link._in_ssl_handshake)
Exemplo n.º 2
0
 def test_ssl_handshake_none_sslobj(self):
     link = snakemq.link.Link()
     sock = mock.Mock()
     sock.sock._sslobj = None
     link._in_ssl_handshake.add(sock)
     link.poller = mock.Mock()
     self.assertEqual(link.ssl_handshake(sock),
                      snakemq.link.SSL_HANDSHAKE_FAILED)
     self.assertNotIn(sock, link._in_ssl_handshake)
Exemplo n.º 3
0
 def test_failed_handshake_cleanup(self):
     link = snakemq.link.Link()
     sock = mock.Mock()
     sock.sock._sslobj = mock.Mock()  # anything but None
     sock.sock.do_handshake.side_effect = socket.error()
     link._in_ssl_handshake.add(sock)
     link.handle_close = mock.Mock()
     link.poller = mock.Mock()
     self.assertEqual(link.ssl_handshake(sock), snakemq.link.SSL_HANDSHAKE_FAILED)
     self.assertNotIn(sock, link._in_ssl_handshake)
     self.assertEqual(link.handle_close.call_count, 1)
Exemplo n.º 4
0
 def test_failed_handshake_cleanup(self):
     link = snakemq.link.Link()
     sock = mock.Mock()
     sock.sock._sslobj = mock.Mock()  # anything but None
     sock.sock.do_handshake.side_effect = socket.error()
     link._in_ssl_handshake.add(sock)
     link.handle_close = mock.Mock()
     link.poller = mock.Mock()
     self.assertEqual(link.ssl_handshake(sock),
                      snakemq.link.SSL_HANDSHAKE_FAILED)
     self.assertNotIn(sock, link._in_ssl_handshake)
     self.assertEqual(link.handle_close.call_count, 1)
Exemplo n.º 5
0
 def test_failed_handshake_cleanup(self):
     link = snakemq.link.Link()
     sock = mock.Mock()
     sock.sock._sslobj = mock.Mock()  # anything but None
     sock.sock.do_handshake.side_effect = socket.error()
     link._in_ssl_handshake.add(sock)
     def handle_close(sock):
         # during handle_close() the socket must be still have
         # the "handshake flag"
         self.assertIn(sock, link._in_ssl_handshake)
     link.handle_close = mock.Mock(wraps=handle_close)
     link.poller = mock.Mock()
     self.assertEqual(link.ssl_handshake(sock), snakemq.link.SSL_HANDSHAKE_FAILED)
     self.assertNotIn(sock, link._in_ssl_handshake)
     self.assertEqual(link.handle_close.call_count, 1)
Exemplo n.º 6
0
    def test_failed_handshake_cleanup(self):
        link = snakemq.link.Link()
        sock = mock.Mock()
        sock.sock._sslobj = mock.Mock()  # anything but None
        sock.sock.do_handshake.side_effect = socket.error()
        link._in_ssl_handshake.add(sock)

        def handle_close(sock):
            # during handle_close() the socket must be still have
            # the "handshake flag"
            self.assertIn(sock, link._in_ssl_handshake)

        link.handle_close = mock.Mock(wraps=handle_close)
        link.poller = mock.Mock()
        self.assertEqual(link.ssl_handshake(sock),
                         snakemq.link.SSL_HANDSHAKE_FAILED)
        self.assertNotIn(sock, link._in_ssl_handshake)
        self.assertEqual(link.handle_close.call_count, 1)