Try testing renegotiation some; not much luck
diff --git a/OpenSSL/ssl/connection.c b/OpenSSL/ssl/connection.c
index 5a4fab0..d53f45c 100755
--- a/OpenSSL/ssl/connection.c
+++ b/OpenSSL/ssl/connection.c
@@ -520,19 +520,18 @@
@return: True if the renegotiation can be started, false otherwise\n\
";
static PyObject *
-ssl_Connection_renegotiate(ssl_ConnectionObj *self, PyObject *args)
-{
+ssl_Connection_renegotiate(ssl_ConnectionObj *self, PyObject *args) {
int ret;
- if (!PyArg_ParseTuple(args, ":renegotiate"))
+ if (!PyArg_ParseTuple(args, ":renegotiate")) {
return NULL;
+ }
MY_BEGIN_ALLOW_THREADS(self->tstate);
ret = SSL_renegotiate(self->ssl);
MY_END_ALLOW_THREADS(self->tstate);
- if (PyErr_Occurred())
- {
+ if (PyErr_Occurred()) {
flush_error_queue();
return NULL;
}
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index 6cec75e..fe18341 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -362,21 +362,7 @@
-class ConnectionSendallTests(TestCase):
- """
- Tests for L{Connection.sendall}.
- """
- def test_wrongargs(self):
- """
- When called with arguments other than a single string,
- L{Connection.sendall} raises L{TypeError}.
- """
- connection = Connection(Context(TLSv1_METHOD), None)
- self.assertRaises(TypeError, connection.sendall)
- self.assertRaises(TypeError, connection.sendall, object())
- self.assertRaises(TypeError, connection.sendall, "foo", "bar")
-
-
+class _LoopbackMixin:
def _loopback(self):
(server, client) = socket_pair()
@@ -400,6 +386,22 @@
return server, client
+
+class ConnectionSendallTests(TestCase, _LoopbackMixin):
+ """
+ Tests for L{Connection.sendall}.
+ """
+ def test_wrongargs(self):
+ """
+ When called with arguments other than a single string,
+ L{Connection.sendall} raises L{TypeError}.
+ """
+ connection = Connection(Context(TLSv1_METHOD), None)
+ self.assertRaises(TypeError, connection.sendall)
+ self.assertRaises(TypeError, connection.sendall, object())
+ self.assertRaises(TypeError, connection.sendall, "foo", "bar")
+
+
def test_short(self):
"""
L{Connection.sendall} transmits all of the bytes in the string passed to
@@ -435,6 +437,37 @@
+class ConnectionRenegotiateTests(TestCase, _LoopbackMixin):
+ """
+ Tests for SSL renegotiation APIs.
+ """
+ def test_renegotiate_wrong_args(self):
+ connection = Connection(Context(TLSv1_METHOD), None)
+ self.assertRaises(TypeError, connection.renegotiate, None)
+
+
+# def test_renegotiate(self):
+# """
+# """
+# server, client = self._loopback()
+
+# server.send("hello world")
+# self.assertEquals(client.recv(len("hello world")), "hello world")
+
+# self.assertEquals(server.total_renegotiations(), 0)
+# self.assertTrue(server.renegotiate())
+
+# server.setblocking(False)
+# client.setblocking(False)
+# while server.renegotiate_pending():
+# client.do_handshake()
+# server.do_handshake()
+
+# self.assertEquals(server.total_renegotiations(), 1)
+
+
+
+
class ErrorTests(TestCase):
"""
Unit tests for L{OpenSSL.SSL.Error}.