diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2012-02-13 11:53:49 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2012-02-13 11:53:49 -0500 |
commit | 64eaffcc4524a6fa032a0510d4cd34a64c38e8c5 (patch) | |
tree | 7d666e558effd0f2dfef2823108137c8023ec82e /OpenSSL/test | |
parent | e0fcf51edcddac12ed57fb5ef76bfa8f342b849a (diff) | |
download | pyopenssl-64eaffcc4524a6fa032a0510d4cd34a64c38e8c5.tar.gz |
Add Connection.get_session and have the Session object actually wrap an SSL_SESSION* (though there is actually not yet any way to tell that that is the case)
Diffstat (limited to 'OpenSSL/test')
-rw-r--r-- | OpenSSL/test/test_ssl.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index 529a454..b3cb1cb 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -1428,6 +1428,51 @@ class ConnectionTests(TestCase, _LoopbackMixin): self.assertIdentical(None, server.get_peer_cert_chain()) + def test_get_session_wrong_args(self): + """ + :py:obj:`Connection.get_session` raises :py:obj:`TypeError` if called + with any arguments. + """ + ctx = Context(TLSv1_METHOD) + server = Connection(ctx, None) + self.assertRaises(TypeError, server.get_session, 123) + self.assertRaises(TypeError, server.get_session, "hello") + self.assertRaises(TypeError, server.get_session, object()) + + + def test_get_session_unconnected(self): + """ + :py:obj:`Connection.get_session` returns :py:obj:`None` when used with + an object which has not been connected. + """ + ctx = Context(TLSv1_METHOD) + server = Connection(ctx, None) + session = server.get_session() + self.assertIdentical(None, session) + + + def test_server_get_session(self): + """ + On the server side of a connection, :py:obj:`Connection.get_session` + returns a :py:class:`Session` instance representing the SSL session for + that connection. + """ + server, client = self._loopback() + session = server.get_session() + self.assertTrue(session, Session) + + + def test_client_get_session(self): + """ + On the client side of a connection, :py:obj:`Connection.get_session` + returns a :py:class:`Session` instance representing the SSL session for + that connection. + """ + server, client = self._loopback() + session = client.get_session() + self.assertTrue(session, Session) + + class ConnectionGetCipherListTests(TestCase): """ |